question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Swagger Version 2.0.X annotations are not supported

See original GitHub issue

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>choesang@x.com</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"
          }
        }
      }
    }

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:8

github_iconTop GitHub Comments

11reactions
fsteinle-transporeoncommented, Aug 13, 2018

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

7reactions
choesangcommented, 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 ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

OpenAPI Specification - Version 2.0 - Swagger
Version 2.0 specification defines a set of files required to describe an API. These files can then be used by the Swagger-UI project...
Read more >
java - Swagger 2 Issue - Spring Boot - Stack Overflow
The springfox plugin is not compatible with PathPattern-based matching in Spring MVC which has replaced the previous Ant-based matching in ...
Read more >
Guide - 7.10.12.2 Migrating to OpenApi 3.0 and Swagger 2.X ...
Product To Version ... document shows major differences between swagger-annotations 1.5.x and 2.x. ... Only if the decorated getter is not an array...
Read more >
Solved: Question about Swagger 2.X Annotations
May I use the @RequestBody annotation to. ... Is swagger definition available? ... 2.JPG. I use this code ,but not working.
Read more >
Using OpenAPI and Swagger UI - Quarkus
There are some MicroProfile OpenAPI annotations which describe global API ... The value / is not allowed as it blocks the application from...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found