springdoc-openapi icon indicating copy to clipboard operation
springdoc-openapi copied to clipboard

Build(Test) error on version 2.3.0 with JDK 21

Open vojkog opened this issue 1 year ago • 5 comments

SpringDocApp193Test.java fails with JDK 21

Version:

	<artifactId>springdoc-openapi</artifactId>
	<version>2.3.0</version>

mvn clean package fails with:

java.lang.AssertionError: components.schemas.Books.allOf[1].properties
Unexpected: first
 ; components.schemas.Books.allOf[1].properties
Unexpected: last
 ; components.schemas
Unexpected: Book

Screenshot:

image

On JDK 17 build passes without a problem.

vojkog avatar Dec 03 '23 11:12 vojkog

@vojkog,

Can you Provide a Minimal, Reproducible Example - with HelloController that reproduces the problem ?

bnasslahsen avatar Dec 04 '23 21:12 bnasslahsen

Thank you, @bnasslahsen, for your response.

I'm sorry if I wasn't specific enough. I discussed building this project from the source when the testing machine was on the JDK 21. e.g.:

  1. Check the JDK version: springdoc-openapi>java -version java version "21" 2023-09-19

  2. Execute only the "problematic" SpringDocApp193Test test: springdoc-openapi>mvn test -Dtest=SpringDocApp193Test "-Dsurefire.failIfNoSpecifiedTests=false"

vojkog avatar Dec 05 '23 06:12 vojkog

Minimal Reproducible Example

  1. Clone the repository:
git clone https://github.com/springdoc/springdoc-openapi.git
  1. Install SDKMAN.
  2. Install Maven, Java 17 and Java 21:
sdk install maven &&
sdk install java 17.0.10-tem &&
sdk install java 21.0.2-tem
  1. Run that specific test:
  • Happy path:
sdk default java 17.0.10-tem &&
mvn test -Dtest=SpringDocApp193Test "-Dsurefire.failIfNoSpecifiedTests=false"  > happy_path.log 2>&1
  • Error path:
sdk default java 21.0.2-tem &&
mvn test -Dtest=SpringDocApp193Test "-Dsurefire.failIfNoSpecifiedTests=false"  > error_path.log 2>&1

Logs

Test case (Java 21)

Git Diff

Running it under Java 21 will generate more lines in the spec file.

{
    "components": {
        "schemas": {
+           "Book": {
+               "type": "object",
+               "properties": {
+                   "title": {
+                       "type": "string"
+                   }
+               },
+               "description": "Represents a Book."
+           },
            "Books": {
                "type": "array",
                "description": "Represents a list of Books.",
                "properties": {
                    "empty": {
                        "type": "boolean"
+                   },
+                   "first": {
+                       "$ref": "#/components/schemas/Book"
+                   },
+                   "last": {
+                       "$ref": "#/components/schemas/Book"
                    }
                }
            }
        }
    }
}

codespearhead avatar Mar 19 '24 17:03 codespearhead

@bnasslahsen I've just updated my previous answer.

The first and last seem to come from the additions to the List interface delivered in Java 21.

As for the other section of the git diff, shouldn't the Book schema be expected to be included in the response?

codespearhead avatar Apr 01 '24 16:04 codespearhead

@bnasslahsen here is the PR to fix the issue described above. Could you please check it? Thanks in advance!

dgswan avatar Aug 05 '24 15:08 dgswan