Swagger-codegen: Spring Server codegen - swagger-2.0 basePath not generated

Created on 5 Sep 2016  路  3Comments  路  Source: swagger-api/swagger-codegen

Description

@RequestMapping annotation is not generated in spring server code generation.
basePath is properly defined in swagger.yaml file.

Swagger-codegen version

Swagger codegen version :
swagger-codegen-maven-plugin: 2.2.1 and also tired with 2.2.2-SNAPSHOT

Swagger declaration file content or url

https://gist.github.com/tdhancii/1d0dde04413b6d98a76598a549a68985

Command line used for generation

Used Maven plugin to generate code
<plugin> <groupId>io.swagger</groupId> <artifactId>swagger-codegen-maven-plugin</artifactId> <version>2.2.1</version> <executions> <execution> <id>generate-sources</id> <phase>generate-sources</phase> <goals> <goal>generate</goal> </goals> <configuration> <inputSpec>src/main/resources/swagger.yaml</inputSpec> <apiPackage>co.test.swagger.api</apiPackage> <modelPackage>co.test.swagger.model</modelPackage> <language>spring</language> <environmentVariables> <models></models> <apis></apis> <supportingFiles>HomeController.java,SwaggerDocumentationConfig.java</supportingFiles> </environmentVariables> </configuration> </execution> </executions> </plugin>

Steps to reproduce

just generate the code using maven plugin and check the DomainApi.java class. You will see that there is not path mapping annotation for basePath: v1 defined in the swagger spec

Bug Spring

Most helpful comment

How can the context v1 or v2 (which can both be contained in the same Spring instance) be set in application.properties (which is common to all endpoints in the Spring instance) ?
And what if the same Spring instance handles other URLs than just the Swagger-managed API ?

All 3 comments

Thanks for the update

How can the context v1 or v2 (which can both be contained in the same Spring instance) be set in application.properties (which is common to all endpoints in the Spring instance) ?
And what if the same Spring instance handles other URLs than just the Swagger-managed API ?

Was this page helpful?
0 / 5 - 0 ratings