Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build(Test) error on version 2.3.0 with JDK 21 #2442

Open
vojkog opened this issue Dec 3, 2023 · 4 comments
Open

Build(Test) error on version 2.3.0 with JDK 21 #2442

vojkog opened this issue Dec 3, 2023 · 4 comments
Labels
incomplete incomplete description: Make sure you Provide a Minimal, Reproducible Example - with HelloController

Comments

@vojkog
Copy link

vojkog commented Dec 3, 2023

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.

@bnasslahsen
Copy link
Contributor

@vojkog,

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

@bnasslahsen bnasslahsen added the incomplete incomplete description: Make sure you Provide a Minimal, Reproducible Example - with HelloController label Dec 4, 2023
@vojkog
Copy link
Author

vojkog commented Dec 5, 2023

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"

@codespearhead
Copy link
Contributor

codespearhead commented Mar 19, 2024

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
Copy link
Contributor

codespearhead commented Apr 1, 2024

@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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
incomplete incomplete description: Make sure you Provide a Minimal, Reproducible Example - with HelloController
Projects
None yet
Development

No branches or pull requests

3 participants