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

JaxRS Server still use Swagger v2 as dependency #27

Open
jmini opened this issue May 13, 2018 · 5 comments
Open

JaxRS Server still use Swagger v2 as dependency #27

jmini opened this issue May 13, 2018 · 5 comments

Comments

@jmini
Copy link
Member

jmini commented May 13, 2018

Generated JaxRS Server uses this library as dependency:

    <dependency>
      <groupId>io.swagger</groupId>
      <artifactId>swagger-jersey2-jaxrs</artifactId>
      <version>1.5.15</version>
    </dependency>

It should be:

    <dependency>
      <groupId>io.swagger.core.v3</groupId>
      <artifactId>swagger-jaxrs2</artifactId>
      <version>2.0.1</version>
    </dependency>

Of course the templates need to be changed in order to adopt the new notation and annotations...


The most visible impact is on the capability for the server to self describe itself.

When you run mvn clean package jetty:run inside the samples/server/petstore/jaxrs/jersey2/ folder and then call http://localhost:8080/v2/swagger.yaml, you obtain the corresponding spec:

swagger: "2.0"
info:
  ...
host: "petstore.swagger.io:80"
basePath: "/v2"
tags:
...
schemes:
- "http"
paths:
  /another-fake/dummy:
    patch:
      ...
  /fake/outer/boolean:
    post:
      tags:
      - "fake"
      summary: ""
      description: "Test serialization of outer boolean types"
      operationId: "fakeOuterBooleanSerialize"
      consumes:
      - "*/*"
      produces:
      - "*/*"
      parameters:
      - in: "body"
        name: "body"
        description: "Input boolean as post body"
        required: false
        schema:
          type: "boolean"
      responses:
        200:
          description: "Output boolean"
          schema:
            type: "boolean"
  /fake/outer/composite:
    post:
      ...
  /fake/outer/number:
    ...

The big next step for the JaxRS generators will be to generate code that will be using Swagger v3 artefacts. Then the page to call to get the spec will be http://localhost:8080/v2/openapi.yaml

@jmini
Copy link
Member Author

jmini commented Jun 12, 2018

Input @wing328:

I think that's a breaking change because users using the auto-generated code before will find the app not working after the big dependency change with the new auto-generated code.

I will try to propose something for 4.0.0-SNAPSHOT

@mohanaraosv
Copy link

So then it doesn't support OpenAPI 3.0.0 or is it fixed in any other PR.

@jmini
Copy link
Member Author

jmini commented Jan 24, 2020

@mohanaraosv:
OpenAPI generator supports OpenAPI v3 (you can use this as input file). Some code generators (like the jaxrs server generator in this case) produce code that rely on Swagger v2 libraries…

As explained in this issue, it is just a matter of fixing the generator.

@dummyalias
Copy link

dummyalias commented Feb 28, 2020

I have tried updating the version for the jaxrs-* generators, but gave up halfway, because the task became too overwhelming for me. You can see my efforts in the last commits of this branch: https://github.com/dummyalias/openapi-generator/commits/feature/swagger2_jaxrs . The changes are still untested and the following is still missing (as far as I can tell):

  • More adaptations for @ApiParam (e.g. extracting @DefaultValue)
  • Fixing all imports (ideally even avoid wildcards)
  • Fix pom.xml, gradle config, ...

Maybe someone with more experience can use my efforts when fixing this issue.

@nikosmoum
Copy link

Any updates on this?

wing328 pushed a commit that referenced this issue Feb 4, 2021
update with upstream master
aserkes added a commit to aserkes/openapi-generator that referenced this issue Aug 5, 2022
…enAPITools#27)

Serialization (JSON-B vs Jackson) for Helidon  SE Server generator

Signed-off-by: aserkes <andrii.serkes@oracle.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants