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

Supporting jakarta namespace #3836

Closed
mzhafez opened this issue Dec 16, 2020 · 18 comments
Closed

Supporting jakarta namespace #3836

mzhafez opened this issue Dec 16, 2020 · 18 comments

Comments

@mzhafez
Copy link

mzhafez commented Dec 16, 2020

Are there any plans to support jakarta namespace (jakarta ee 9) in swagger? With each passing day there are more libraries that have migrated to the jakarta namespace which is incompatible with javax namespace.

The namespace incompatibility will slowly lead to developers having to choose between using swagger or remaining on older versions of libraries that are still compatible with jakarta.

For example, the latest version of Jetty supports Jakarta namespace and is now incompatible with the javax namespace which means that one cannot upgrade to the latest version of Jetty and continue using swagger.

@frantuma
Copy link
Member

This is a quite delicate issue and has not been decided yet, and any comment or contribution in this area are more than welcome, however IMO the best direction and the current plan (no ETA yet) is aiming for support of both javax and jakarta namespaces at least for the short - medium term (until things stabilize).

The idea is to have parallel releases of original (let's say javax based) and modified (jakarta based) artifacts, using either direct bytecode manipulation and/or existing specific tools (e.g.
https://github.com/eclipse/transformer), with minor refactoring beforehand (e.g. hardcoded javax etc).

A more comprehensive solution - again depending on how things evolve - would include refactoring the next major version to introduce a compatibility layer, this would however need much more effort than artifact transformation at build/deploy time.

I would say that in any case it's not an option to maintain 2 parallel major release lines for javax and jakarta, if not based on artifact transformation.

Again and as always contributions are appreciated.

@frantuma
Copy link
Member

frantuma commented Jan 5, 2021

see also #3849 (comment)

@strangelookingnerd
Copy link
Contributor

See my PR #3852

@frantuma I see your reasoning regarding the support of both namespaces and agree that it would be good from a maintainers POV. However I feel that neither transformer nor a compatibility layer are good solutions from a users perspective.
Looking at Swaggers main dependencies and how they solved this:

JAXB: Clear cut with v3.0.0
Jersey: Clear cut with v3.0.0
Jakarta WS: Clear cut with v3.0.0
Jackson: Supporting both namespaces with shaded JARs (ugly in my opinion). They now provide different JARs seperated by classifier. This is a pain to work with.

I personally would prefer to maintain two major releases for the time being and deprecate the javax version as soon as reasonable.
The future will be jakarta if we like it or not ;)

I'm really willing to support you on this, so please let me know if this is a step towards a solution or not.

@frantuma
Copy link
Member

frantuma commented Jan 8, 2021

@strangelookingnerd thanks a lot for your contribution in this area!

We are still identifying the best achievable solution, considering both user experience and maintenance effort, and while I see your point in having 2 "clean" separate release lines until javax fades away, we still think that this would mean considerable maintenance effort and duplication, and we still think that an artifact transformation within the same release lines makes more sense for this project.

I feel we are more in a position like Jackson's, as its maintainer says in a comment for a slightly related ticket, and their solution seems to address similar problems, until next major release.

I can understand that it doesn't look so clean, but I'd say this whole thing has not been really "clean" from the start..

Can you maybe elaborate on This is a pain to work with.? Just to have a broader view on impact.



I am adding here as reference a set of links related to Jackson work in this area for 2.12 (shading with package renaming and different classifier), even though probably the eclipse transformer tool gets a bit further (e.g. OSGi related changes, etc)

and

and

and

https://github.com/search?q=org%3AFasterXML+jakarta

@strangelookingnerd
Copy link
Contributor

strangelookingnerd commented Jan 8, 2021

I feel it's hard to work with the BOMs and transitive dependencies. For example:

https://github.com/strangelookingnerd/swagger-core/commit/364d5cb6b0c026a33f391479c18011e8e1b57b16?branch=364d5cb6b0c026a33f391479c18011e8e1b57b16&diff=split#diff-efd347097616fc97c8d51278e2eaa1c78fb3effd19ff3c167e907572b4db58d3R203-R229

Maybe I did it all wrong but to my understanding:

<dependency>
            <groupId>com.fasterxml.jackson.jaxrs</groupId>
            <artifactId>jackson-jaxrs-json-provider</artifactId>
            <version>${jackson-version}</version>
            <classifier>jakarta</classifier>
</dependency>

still has transitive dependencies to the "non-jakarta" modules and I would not know how they could change that to be fair.
Shaded JARs are shady...(yes I went there, sorry)...and always come at a cost. Identifying and fixing problems in the transitive dependencies is never fun.

Thinking of a clean solution for a transformation to achieve what was done in my PR gives me a major headache. But maybe thats just me.

@frantuma
Copy link
Member

frantuma commented Jan 8, 2021

This is good feedback, thanks. I will analyze this a bit more and share some thoughts probably next week, whatever additional comment/thought in the meantime is welcome, particularly on further drawbacks of the transform solution.

@mzhafez
Copy link
Author

mzhafez commented Feb 12, 2021

Any updates on this?

@frantuma
Copy link
Member

Jakarta support is planned for upcoming release, probably within next week; we have also considered @strangelookingnerd input and work on this, and we dropped idea to take Jackson path with classifier.

The planned solution still makes use of transformers, but providing a separate artifactId (with -jakarta suffix, e.g. swagger-core-jakarta) along with its own POM with correct dependency hierarchy.

In the medium term we will probably have the default artifacts supporting jakarta, and maintaining a transformed version for javax.

Will keep updates in this ticket

@strangelookingnerd
Copy link
Contributor

@frantuma This is great news and +1 for the planned solution. Any way I could contribute?

@frantuma
Copy link
Member

@strangelookingnerd thanks! I'll ping when I have the PR ready / merged, what will be missing is possibly some swagger-jakarta-test module providing tests for the jakarta versions and/or one or more samples added to https://github.com/swagger-api/swagger-samples/tree/2.0/java with some jakarta env, e.g. Jersey, Grizzly, etc

(The PR will introduce a new module swagger-project-jakarta holding in turn the set of jakarta modules swagger-annotations-jakarta, swagger-models-jakarta, etc..)

@frantuma
Copy link
Member

please see #3881 implementing what mentioned above.

@frantuma
Copy link
Member

Closing as Jakarta artifacts are available since version 2.1.7, see wiki, maven readme and gradle readme.

@cowtowncoder
Copy link

FWTW, Jackson 2.13 drops classifier path and does a full fork instead, so that there are 2 modules on

https://github.com/FasterXML/jackson-modules-base/

namely

  1. "jackson-module-jaxb-annotations" for old javax/jaxb annotations
  2. "jackson-module-jakarta-xmlbind-annotations" for new jakarta xmlbind annotations

These live in different Java packages (as well as have different Maven coordinates), so upgrade would not be fully transparent to users; but on plus side both can co-exist if need be.

I assume it is also possible to just use (1) and do fancy auto-magic bytecode manipulation. But thought I'd mention the new alternative in case it might be of interest, one Jackson 2.13 gets released (within a month or two).

@frantuma
Copy link
Member

frantuma commented Jul 5, 2021

@cowtowncoder Thanks for the heads up! Reopening ticket to keep track of work needed when updating to Jackson 2.1.3+

@frantuma frantuma reopened this Jul 5, 2021
@jsikkes
Copy link

jsikkes commented Aug 17, 2021

The current version of the swagger-jaxrs2-jakarta module is referencing the the jackson module with the 'jakarta' classifier.

It seems that the publication of this artifact is revoked, breaking the module.

As a workaround, i'm currently ignoring the dependency and manually importing it.

    implementation group: 'com.fasterxml.jackson.jakarta.rs', name: 'jackson-jakarta-rs-json-provider', version: '2.13.0-rc1'

    implementation (group: 'io.swagger.core.v3', name: 'swagger-jaxrs2-jakarta', version: '2.1.10') {
        exclude group: 'com.fasterxml.jackson.jaxrs', module: 'jackson-jaxrs-json-provider'
    }

@frantuma
Copy link
Member

@jsikkes not sure what you mean by "revoked"; 2.12.1 (to 2.12.4) version with jakarta artifact is available on maven central, and as mentioned by Tatu above, it's 2.13 which drops classifier.

@michael-schnell
Copy link

In "io.swagger.core.v3:swagger-core:2.2.9" I see still the dependencies to "javax.validation.constraints" and "javax.xml.bind.annotation" which should be replaced by their "jakarta" counterparts.

@frantuma
Copy link
Member

As mentioned in wiki the jackarta artifacts are using the jakarta suffix, e.g. swagger-core-jakarta

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants