Open NogaB opened 7 years ago
Hi, I have a similar problem. We used swagger with this configuration without any problem. Now I updated the plugin to the new version and the doc is not created correctly. Also the json in "api-docs" doesn't contain any API. The code is available here. Any idea?
@mcicolella looks like you are using a fairly outdated version (3.0.0), latest is 3.1.5
@danieleorler updated to 3.1.5 but the build fails Failed to execute goal com.github.kongchen:swagger-maven-plugin:3.1.5:generate (default) on project restapi-v3: Unable to parse configuration of mojo com.github.kongchen:swagger-maven-plugin:3.1.5:generate for parameter locations: Cannot assign configuration entry 'locations' with value 'com.freedomotic.plugins.devices.restapiv3.resources' of type java.lang.String to property of type java.util.List
@mcicolella yeah the location definition has changed a bit:
from:
<locations>com.freedomotic.plugins.devices.restapiv3.resources</locations>
to
<locations>
<location>com.freedomotic.plugins.devices.restapiv3.resources</location>
</locations>
We have the same problem. And it does not help by updating to 3.1.5. It simply does not recognize all the annotations I had.
<plugin>
<groupId>com.github.kongchen</groupId>
<artifactId>swagger-maven-plugin</artifactId>
<version>3.1.5</version>
<configuration>
<apiSources>
<apiSource>
<info>
<title>API for Presto Manager</title>
<version>v1</version>
<description>Swagger specification for REST API</description>
</info>
<springmvc>false</springmvc>
<basePath>/v1</basePath>
<swaggerDirectory>doc/</swaggerDirectory>
<locations>
<location>presto-manager-agent.src.main.java.com.teradata.prestomanager.agent.api</location>
<location>presto-manager-controller.src.main.java.com.teradata.prestomanager.controller.api</location>
</locations>
</apiSource>
</apiSources>
</configuration>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
Since it looks like you are using Jax/RS, try instead of @RequestMapping(value = "/")
@RequestMapping(path = "/")
Thanks @thlaegler! I'm using Spring Boot and it works when I use value
attribute instead of path
: @RequestMapping(value = "suggestion/{term}"
Hi, Even Changing to value its not working, Do u have any working example of spring boot with static doc generation
The code is proprietary, so I cannot give you the original one. But I can give you a simplified and modified version. The controller class basically looks like this:
@RestController
@RequestMapping(value = "/{languageTag}")
public class MyService {
...
@RequestMapping(value = "/{term}", produces = MediaType.APPLICATION_JSON_UTF8_VALUE, method = RequestMethod.GET)
@ApiOperation(value = "Applies ...", response = MyServiceResult.class)
@ApiResponses({
@ApiResponse(code = 400, message = ERROR_CODE_MESSAGE_BAD_REQUEST, response = ApiError.class),
@ApiResponse(code = 500, message = ERROR_CODE_MESSAGE_INTERNAL_ERROR, response = ApiError.class)
})
public HttpEntity<MyServiceResult> serviceMethod(
@PathVariable
@ApiParam(value = "The ...",
example = "en-US",
name = "languageTag")
final String languageTag,
@PathVariable
@ApiParam(value = "The ...",
example = "word",
name = "term")
final String term) {
...
If this doesn't work for you then estimatedly it's caused by your different Maven dependency configuration or by the Swagger plugin version you use.
Thanks, that helps
Hi, I get build success, but a very partial json swagger is create. Namely it look like my @ApiOperation annotation is completely missed or ignored. When I compile I see the following print:
--- swagger-maven-plugin:3.1.4:generate (default) @ backend --- [INFO] Reflections took 126 ms to scan 1 urls, producing 9 keys and 12 values [INFO] Reflections took 5 ms to scan 1 urls, producing 9 keys and 12 values [INFO] Reflections took 5 ms to scan 1 urls, producing 9 keys and 12 values [INFO] Reflections took 5 ms to scan 1 urls, producing 9 keys and 12 values
Using