springdoc-openapi
springdoc-openapi copied to clipboard
Build(Test) error on version 2.3.0 with JDK 21
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:
On JDK 17 build passes without a problem.
@vojkog,
Can you Provide a Minimal, Reproducible Example - with HelloController that reproduces the problem ?
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.:
-
Check the JDK version: springdoc-openapi>
java -version
java version "21" 2023-09-19 -
Execute only the "problematic" SpringDocApp193Test test: springdoc-openapi>
mvn test -Dtest=SpringDocApp193Test "-Dsurefire.failIfNoSpecifiedTests=false"
Minimal Reproducible Example
- Clone the repository:
git clone https://github.com/springdoc/springdoc-openapi.git
- Install SDKMAN.
- Install Maven, Java 17 and Java 21:
sdk install maven &&
sdk install java 17.0.10-tem &&
sdk install java 21.0.2-tem
- 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"
}
}
}
}
}
}
@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?
@bnasslahsen here is the PR to fix the issue described above. Could you please check it? Thanks in advance!