"Empty" swagger.json File
See original GitHub issueI am using version 3.1.0 of the swagger-maven-plugin with the following configuration:
<plugin>
<groupId>com.github.kongchen</groupId>
<artifactId>swagger-maven-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<apiSources>
<apiSource>
<springmvc>true</springmvc>
<locations>my.api.location</locations>
<schemes>http</schemes>
<host>myhost</host>
<basePath>/api</basePath>
<info>
<title>Title</title>
<version>v1</version>
<description>Description</description>
</info>
<swaggerDirectory>my/directory</swaggerDirectory>
</apiSource>
</apiSources>
</configuration>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
When I run mvn compile
the swagger.json file generated contains only the basic information, IE the info, host, basepath, and schemes. It does not contain any information about my API.
I am using io.swagger v1.5.3
The annotations is similar to this
@API(value = "value", tags = {"tag"}, hidden = false)
When checking the debug logs I see the following message:
[INFO] Reflections took 136 ms to scan 1 urls, producing 38 keys and 349 values
I am able to compile the example project with the correct swagger.json so it shouldn’t be an issue due to my maven version.
Am I missing something or could this be a bug.
Issue Analytics
- State:
- Created 7 years ago
- Comments:21 (7 by maintainers)
Top GitHub Comments
So my problem was that I didn’t have a
@ApiOperation
on my methods. If anyone else is having this problem, ensure you have@RequestMapping
on all methods AND your class, and that you have@ApiOperation
for every method, not just@ApiResponse
I was experiencing the same in a multi module maven setup. In my case what fixed it was to add the direct dependency from the module where the plugin is defined to the module containing the resources. It didn’t pick it up through the transitive dependency. Don’t know if this is a bug or the expected behavior. My 2 cents, hope it helps you.