我尝试使用swagger-maven-plugin生成以下内容的swagger.json:
@Timed
@Path("_list")
@POST
@Produces(UTF8JSON)
@Consumes(UTF8JSON)
@ApiOperation(value = "List", produces = UTF8JSON, notes = "List the Scenes, given the filters", consumes = UTF8JSON, response = Scene.class)
@ApiResponses(value =
{@ApiResponse(code = 200, message = "Successful operation", response = Scene.class, responseContainer = "Object"),
@ApiResponse(code = 500, message = "Server Error.", response = Error.class),
@ApiResponse(code = 400, message = "Bad request.", response = Error.class)})
public Response list(
// --------------------------------------------------------
// ----------------------- FORM -----------------------
// --------------------------------------------------------
@ApiParam(name = "pretty", value = Documentation.FORM_PRETTY,
allowMultiple = false,
defaultValue = "false",
required = true,
type = "Search")
@QueryParam(value = "pretty") Boolean pretty,
// --------------------------------------------------------
// ----------------------- SEARCH -----------------------
// --------------------------------------------------------
@ApiParam(name = "search",
value = "The search",
allowMultiple = false,
required = true)
@QueryParam(value = "search")
Search search
) throws InterruptedException, ExecutionException, IOException, NotFoundException, IllegalArgumentException {
然后在Maven中我简单地设置:
<plugin>
<groupId>com.github.kongchen</groupId>
<artifactId>swagger-maven-plugin</artifactId>
<version>${swagger-maven-plugin.version}</version>
<configuration>
<apiSources>
<apiSource>
<locations>
<location>com.my.project.rest.server</location>
</locations>
<info>
<title>${swagger.rest.title}</title>
<version>${project.version}</version>
</info>
<swaggerDirectory>${project.build.directory}</swaggerDirectory>
</apiSource>
</apiSources>
</configuration>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
我的问题是,在生成的swagger.json中,不存在Search对象定义。当我使用swagger-codegen-maven-plugin生成客户端代码时,由于缺少搜索,我无法请求。
当我查看swagger运行时生成的swagger.json时,定义尚可。我想让它也生成输入参数对象是什么?
谢谢。