springdoc-openapi
springdoc-openapi copied to clipboard
Add support for Jakarta EE
Is your feature request related to a problem? Please describe. When using springdoc-openapi-ui, one gets a dependency to the old javax-apis through the version of swagger-core that is included (via springdoc-common).
Describe the solution you'd like It seems swagger has solved this by publishing separate artifacts suffixed with jakarta (See https://github.com/swagger-api/swagger-core/pull/3881). It would be nice if one could do the same with springdoc, or if possible solve it in some other way, so as not have to manually exclude the javax-swagger-versions and include the jakarta-swagger versions a la
implementation(
'io.swagger.core.v3:swagger-annotations-jakarta:2.1.11',
'io.swagger.core.v3:swagger-integration-jakarta:2.1.11',
'io.swagger.core.v3:swagger-models-jakarta:2.1.11'
)
implementation('org.springdoc:springdoc-openapi-ui:1.5.11') {
exclude(group: 'io.swagger.core.v3', module: 'swagger-annotations')
exclude(group: 'io.swagger.core.v3', module: 'swagger-integration')
exclude(group: 'io.swagger.core.v3', module: 'swagger-models')
}
I'm not well enough versed in all the possibilities of configuring dependencies in maven to come up with the best solution to this, but it would be nice if it could be solved somehow, as jakarta.* is where the development will continue.
@abrudin,
Thank you for your proposal. What is sure, is that once the support will be fully available in spring 6, the support should also be available in springdoc-openapi.
I think the straightforward solution, is to have separate dependencies: one dedicated for jakarta support and another one for javax.
Don't hesitate to propose a PR, if you have any solutions in mind.
This feature, should anyway be supported and will be added for the next springdoc major release.
1st milestone of Spring Boot 3 with support for Jakarta EE 9 is available.
just found this issue after upgrading to Spring Boot 3.0 M1 .. OpenAPI crashes by trying to use Reflection for javax Classes (like Servlet) .. which our now gone / replaced by the jakarta ee namespace ..
SpringDoc Version is 1.6.4
at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:461) ~[spring-core-6.0.0-M2.jar:6.0.0-M2]
... 90 common frames omitted
Caused by: java.lang.ClassNotFoundException: javax.servlet.http.HttpServletRequest at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641) ~[na:na] at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188) ~[na:na] at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520) ~[na:na]
Hi @goafabric,
The support has been added in springdoc-openapi 2
branch.
For now we will Support Jakarta EE 9
and Spring-Boot 3
.
springdoc-openapi v2
will require Java 17
as a minimum version and Spring Boot 3.x
springdoc-openapi v2
will be released once spring-Boot 3
goes G.A.
This is the link for the demos code:
- https://github.com/springdoc/springdoc-openapi-demos/tree/2.x
If you want to give it a try, this is a first version of the documentation updated here:
- https://springdoc.org/v2/
And this is the migration steps:
- https://github.com/springdoc/springdoc-openapi-demos/wiki/springdoc-openapi-2.x-migration-guide
Note: spring-cloud
and spring-native
are not yet ready for spring-boot 3 support.
Please feel free to use and test the latest SNAPSHOT: springdoc-openapi v2.0.0-SNAPSHOT
.
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
<version>2.0.0-SNAPSHOT</version>
</dependency>
Don't hesitate to provide your comments in this ticket.
@bnasslahsen Will you release milestones until Spring Boot 3 goes GA or do we have to use snapshots until then?
@juergenzimmermann,
Ofc we will release milestones until then. We will try to stick to spring-boot ones. We just need to the SNAPSHOT version enough stable to release it!
Don't hesitate, to give it a try and share your comments.
I just upgraded using springdoc-openapi-starter-webflux-ui
and it works fine. Thank you for supporting Jakarta EE 9.
@bnasslahsen works like a charm .. yeah i know about spring-native .. its not even supported by the spring people thx for your extraordinary fast support for all things spring
@juergenzimmermann,
FYI, springdoc-openapi v2.0.0-M1
has been released.
Thank you @bnasslahsen
Hi @goafabric,
The support has been added in
springdoc-openapi 2
branch. For now we will SupportJakarta EE 9
andSpring-Boot 3
.springdoc-openapi v2
will requireJava 17
as a minimum version andSpring Boot 3.x
springdoc-openapi v2
will be released oncespring-Boot 3
goes G.A.This is the link for the demos code:
- https://github.com/springdoc/springdoc-openapi-demos/tree/2.x
If you want to give it a try, this is a first version of the documentation updated here:
- https://springdoc.org/v2/
And this is the migration steps:
- https://github.com/springdoc/springdoc-openapi-demos/wiki/springdoc-openapi-2.x-migration-guide
Note:
spring-cloud
andspring-native
are not yet ready for spring-boot 3 support.Please feel free to use and test the latest SNAPSHOT:
springdoc-openapi v2.0.0-SNAPSHOT
.<dependency> <groupId>org.springdoc</groupId> <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId> <version>2.0.0-SNAPSHOT</version> </dependency>
Don't hesitate to provide your comments in this ticket.
Thank you so much!!!
Thank @bnasslahsen for your efforts!
I'm experiencing org.springdoc:springdoc-openapi-starter-webmvc-ui:2.0.0-M2
.
Hi there, I'm experiencing this same issue. Here is the exception:
Caused by: java.lang.ClassNotFoundException: javax.validation.constraints.Min
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
... 120 common frames omitted
This is something quite needed for one of the modules I'm working on. When do you reckon a release will be available to use?
If you look at the link above, you'll see what is happening. It seems like springdoc is still using the old javax validations and is not providing support to jakarta yet.
@juergenzimmermann,
Please:
- Read https://springdoc.org/v2/, to check for latest current release version.
- Read the migration steps: https://github.com/springdoc/springdoc-openapi-demos/wiki/springdoc-openapi-2.x-migration-guide
And then, if you still have any comment, make sure you provide a Minimal, Reproducible Example - with HelloController that reproduces the problem.
Is there any way to convince springdoc to still use javax annotations? I would like to avoid the extra dependency but it decides to try to use jakarta.annotation.Generated
over the javax one (I assume this is on your side and not openapi codegens)
Is there any way to convince springdoc to still use javax annotations? I would like to avoid the extra dependency but it decides to try to use
jakarta.annotation.Generated
over the javax one (I assume this is on your side and not openapi codegens)
- springdoc 1.x supports already
javax annotations
. This is the version to use with spring-boot 2.x. - springdoc 2.x will support
jakarta annotations
and will only support spring-boot 3.x which depends onjakarta annotations
as well.
@bnasslahsen has org.springdoc:springdoc-openapi-starter-webmvc-ui:2.0.0-M5
already support for native images in boot 3.0 ?
because last time i tried i could not get it working
thank u
@goafabric,
The native support is added to the v2.0.0-M7-SNAPSHOT, which now fully supports spring-boot 3.0.0-M5
.
If you have some time, do not hesitate to test it before the next release.
For the OpenAPI REST endpoints, you just need to build your application with the spring native
profile.
For the UI, you will have to add springdoc.enable-native-support=true
. This is mainly related to https://github.com/webjars/webjars-locator-core/issues/96
@bnasslahsen works like a charm ! thank you very much and as always for all your efforts
@bnasslahsen
With a more complex project with jpa I get the error below. But there is an easy fix by registering a reflection hint. Maybe you can also incorporate that. Thank u
---fix ---
hints.reflection().registerType(java.lang.Module.class, MemberCategory.INVOKE_DECLARED_METHODS);
-- error --
Caused by: java.lang.IllegalArgumentException: Method "getLayer" could not be invoked: java.lang.NoSuchMethodException: Could not find method java.lang.Module.getLayer [498](https://github.com/goafabric/person-service/actions/runs/3258901614/jobs/5351332317#step:6:500) at nonapi.io.github.classgraph.reflection.ReflectionUtils.invokeMethod(ReflectionUtils.java:231) ~[na:na] [499](https://github.com/goafabric/person-service/actions/runs/3258901614/jobs/5351332317#step:6:501) at nonapi.io.github.classgraph.classpath.ModuleFinder.findModuleRefsFromCallstack(ModuleFinder.java:227) ~[na:na] [500](https://github.com/goafabric/person-service/actions/runs/3258901614/jobs/5351332317#step:6:502) at nonapi.io.github.classgraph.classpath.ModuleFinder.<init>(ModuleFinder.java:284) ~[na:na] [501](https://github.com/goafabric/person-service/actions/runs/3258901614/jobs/5351332317#step:6:503) at nonapi.io.github.classgraph.classpath.ClasspathFinder.<init>(ClasspathFinder.java:164) ~[na:na] [502](https://github.com/goafabric/person-service/actions/runs/3258901614/jobs/5351332317#step:6:504) at io.github.classgraph.Scanner.<init>(Scanner.java:166) ~[na:na] [503](https://github.com/goafabric/person-service/actions/runs/3258901614/jobs/5351332317#step:6:505) at io.github.classgraph.ClassGraph.scanAsync(ClassGraph.java:1531) ~[na:na] [504](https://github.com/goafabric/person-service/actions/runs/3258901614/jobs/5351332317#step:6:506) at io.github.classgraph.ClassGraph.scanAsync(ClassGraph.java:1559) ~[na:na] [505](https://github.com/goafabric/person-service/actions/runs/3258901614/jobs/5351332317#step:6:507) at io.github.classgraph.ClassGraph.scan(ClassGraph.java:1584) ~[na:na] [506](https://github.com/goafabric/person-service/actions/runs/3258901614/jobs/5351332317#step:6:508) at io.github.classgraph.ClassGraph.scan(ClassGraph.java:1623) ~[na:na] [507](https://github.com/goafabric/person-service/actions/runs/3258901614/jobs/5351332317#step:6:509) at io.github.classgraph.ClassGraph.scan(ClassGraph.java:1636) ~[na:na] [508](https://github.com/goafabric/person-service/actions/runs/3258901614/jobs/5351332317#step:6:510) at org.webjars.WebJarAssetLocator.scanForWebJars(WebJarAssetLocator.java:188) ~[na:na]
@goafabric,
Good hint! I have also found it for spring-data-rest. I have moved it to to the common hints!
@bnasslahsen tried out RC1 this morning .. unfortunately it does not only need graalvm 22.3 which is currently only provided by liberica and no paketo build (just to let you know)
it also needs additional hints .. but then it works again:
hints.reflection().registerType(java.lang.Module.class, MemberCategory.INVOKE_DECLARED_METHODS); hints.reflection().registerType(java.lang.ModuleLayer.class, MemberCategory.INVOKE_DECLARED_METHODS); hints.reflection().registerType(java.lang.module.Configuration.class, MemberCategory.INVOKE_DECLARED_METHODS); hints.reflection().registerType(java.lang.module.ResolvedModule.class, MemberCategory.INVOKE_DECLARED_METHODS);
Is there a version of springdoc-openapi-webmvc-core somewhere that supports this change?
Hi @goafabric,
The support has been added in
springdoc-openapi 2
branch. For now we will SupportJakarta EE 9
andSpring-Boot 3
.springdoc-openapi v2
will requireJava 17
as a minimum version andSpring Boot 3.x
springdoc-openapi v2
will be released oncespring-Boot 3
goes G.A.This is the link for the demos code:
* https://github.com/springdoc/springdoc-openapi-demos/tree/2.x
If you want to give it a try, this is a first version of the documentation updated here:
* https://springdoc.org/v2/
And this is the migration steps:
* https://github.com/springdoc/springdoc-openapi-demos/wiki/springdoc-openapi-2.x-migration-guide
Note:
spring-cloud
andspring-native
are not yet ready for spring-boot 3 support.Please feel free to use and test the latest SNAPSHOT:
springdoc-openapi v2.0.0-SNAPSHOT
.<dependency> <groupId>org.springdoc</groupId> <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId> <version>2.0.0-SNAPSHOT</version> </dependency>
Don't hesitate to provide your comments in this ticket.
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'webConversionServiceProvider' defined in class path resource [org/springdoc/core/configuration/SpringDocConfiguration$WebConversionServiceConfiguration.class]: Failed to instantiate [org.springdoc.core.providers.WebConversionServiceProvider]: Factory method 'webConversionServiceProvider' threw exception with message: class org.springframework.boot.autoconfigure.web.format.WebConversionService cannot be cast to class java.util.List (org.springframework.boot.autoconfigure.web.format.WebConversionService is in unnamed module of loader 'app'; java.util.List is in module java.base of loader 'bootstrap')
I get the error like this
@rzaayshan,
Make sure you read the Contribution guidelines
As mentionned, in the guidelines above, if you feel you are facing an issue, make sure you provide a Minimal, Reproducible Example - with HelloController that reproduces the problem.
The springdoc-openapi v2 has been released as spring-boot v3 is now GA. The documentation of the springdoc-openapi v2, has been updated accordingly as well.