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

Swagger Version 2.0.X annotations are not supported #655

Open
choesang opened this issue Aug 7, 2018 · 9 comments
Open

Swagger Version 2.0.X annotations are not supported #655

choesang opened this issue Aug 7, 2018 · 9 comments

Comments

@choesang
Copy link

choesang commented Aug 7, 2018

I am using the following versions of swagger and swagger-maven-plugin. You can see below my configuration and the swagger.json file. It is clearly missing many of the fields defined in the annotation.

Is it possible that the current version of the maven plugin does not support Version 2?
Is there any plans to support them in the future?

swagger-maven-plugin 3.1.7
swagger-core 2.0.2

pom.xml

<dependency>
            <groupId>io.swagger.core.v3</groupId>
            <artifactId>swagger-core</artifactId>
            <scope>compile</scope>
            <version>2.0.2</version>
 </dependency>

<profile>
            <id>apidoc</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.github.kongchen</groupId>
                        <artifactId>swagger-maven-plugin</artifactId>
                        <version>3.1.7</version>
                        <configuration>
                            <apiSources>
                                <apiSource>
                                    <info>
                                        <title>x API</title>
                                        <version>${project.version}</version>
                                        <description>
                                            Here you will find all the endpoints provided by the platform and
                                            how to interact with them.
                                        </description>
                                        <contact>
                                            <name>Choesang</name>
                                            <email>[email protected]</email>
                                            <url>http://www.x.com</url>
                                        </contact>
                                    </info>
                                    <schemes>
                                        <scheme>http</scheme>
                                        <scheme>https</scheme>
                                    </schemes>
                                    <locations>com.x.platform.api</locations>
                                    <host>localhost:8080</host>
                                    <basePath>/platform-web/api</basePath>
                                    <templatePath>${basedir}/src/main/resources/swagger/strapdown.html.hbs
                                    </templatePath>
                                    <outputPath>${project.build.directory}/apidocs/strapdown.html</outputPath>
                                    <swaggerDirectory>${project.build.directory}/apidocs</swaggerDirectory>
                                </apiSource>
                            </apiSources>
                        </configuration>
                        <executions>
                            <execution>
                                <phase>install</phase>
                                <goals>
                                    <goal>generate</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
            <activation>
                <property>
                    <name>!no-swagger</name>
                </property>
            </activation>
        </profile>

Resource class

   @POST
    @Path("/{id}/stop")
    @Produces(MediaType.APPLICATION_JSON)
    @Operation(summary = "Stop job with given id", responses = {
        @ApiResponse(responseCode = "202", description = "Successfully stopped the job"),
        @ApiResponse(responseCode = "500", description = "Internal messaging error"),
        @ApiResponse(responseCode = "404", description = "Job could not be found,Job-Id")
    })
    public Response stopJob(@Context final UriInfo uriInfo,
     @Parameter(description = "jobId", required = true) @PathParam("id") final String jobId) {
        return Response.accepted().location(uriInfo.getRequestUri()).build();
    }

swagger.json

"/jobs/{id}/stop" : {
      "post" : {
        "operationId" : "stopJob",
        "produces" : [ "application/json" ],
        "parameters" : [ {
          "name" : "id",
          "in" : "path",
          "required" : true,
          "type" : "string"
        } ],
        "responses" : {
          "default" : {
            "description" : "successful operation"
          }
        }
      }
    }
@choesang
Copy link
Author

choesang commented Aug 7, 2018

I just saw that the current swagger-maven-plugin is built on swagger 1.5.18. Are there any plans to support the latest swagger 2.0.x ?

@choesang choesang changed the title Swagger Version 2.0.X annotations are not generated in JSON file Swagger Version 2.0.X annotations are not supported Aug 7, 2018
@florian-trimble
Copy link

Yeah, this would be great to have for us as well! :)

@blackat
Copy link

blackat commented Jan 8, 2019

Hello,
try to have a look at swagger-maven-plugin

According to the description

provides a maven plugin to resolve an OpenAPI definition at build time (using swagger-jaxrs2).

Update: I have tried right now and it works, I can then display the json in the swagger-ui as well, I am using

<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-maven-plugin</artifactId>
<version>2.0.6</version>

@blackat
Copy link

blackat commented Jan 14, 2019

Small remark, please note that

<groupId>com.github.kongchen</groupId>
<artifactId>swagger-maven-plugin</artifactId>
<version>3.1.7</version>

This plugin is not the one implemented along with the swagger version 2.0.X, check please the groupId tag.

@devutkarsh
Copy link

@blackat
I am using Spring REST(not JAX-RS) and trying to generate the OPEN API 3.0 YAML specification file. The swagger-maven-plugin under groupId io.swagger.core.v3 works well for generating the OPEN API definitions, but not reading Operations and Paths annotation as it's not JAX-RS?
Is there a workaround to generate OPENAPI 3.0 spec file instead of Swagger 2.0 spec file using com.github.kongchen swagger-maven-plugin?

@nashley
Copy link

nashley commented May 13, 2019

@devutkarsh It doesn't look like OpenAPI 3.0 is supported yet. Check out #550.

@ataraxus
Copy link

Is there any alternative? since we upgraded our swagger deps, the specs generated are now not working anymore. Operations missing....

@priyansh490
Copy link

After experimenting, I found swagger-maven-plugin this plugin is useful as of now as a replacement.

I hope this helps.

@marcogrcr
Copy link

marcogrcr commented Mar 28, 2024

If you're looking for OpenAPI 3.x support, see: #550 (comment)

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

8 participants