我不能理解为什么swagger-maven-plugin不能在Spring Boot中生成参数定义。 json看起来像这样
"parameters" : [ {
"name" : "targetFilterSaveRqDto",
"in" : "query",
"required" : true,
"type" : "ref"
} ],
我希望它看起来像这样。带有对模式的引用
"parameters" : [ {
"in" : "body",
"name" : "body",
"description" : "DTO",
"required" : true,
"schema" : {
"$ref" : "#/definitions/TargetFilterSaveRqDto"
}
} ],
我在这样的春季启动应用中使用swagger-maven-plugin
<plugin>
<groupId>com.github.kongchen</groupId>
<artifactId>swagger-maven-plugin</artifactId>
<version>3.1.7</version>
<configuration>
<skipSwaggerGeneration>${swagger.skipGeneration}</skipSwaggerGeneration>
<apiSources>
<apiSource>
<springmvc>true</springmvc>
<locations>
<location>${swagger.api.package}</location>
</locations>
<schemes>
<schema>http</schema>
<schema>https</schema>
</schemes>
<host>${swagger.api.url.host}:${swagger.api.url.port}</host>
<basePath>${swagger.api.url.base}</basePath>
<info>
<title>${swagger.api.title}</title>
<version>${swagger.api.version}</version>
<description>${swagger.api.description}</description>
<contact>
<email>support@stream.ru</email>
<url>http://stream.ru</url>
</contact>
<license>
<name>Company Licence</name>
</license>
</info>
<securityDefinitions>
<securityDefinition>
<name>basicAuth</name>
<type>basic</type>
</securityDefinition>
</securityDefinitions>
<outputFormats>json,yaml</outputFormats>
<swaggerDirectory>${swagger.directory}/desc</swaggerDirectory>
</apiSource>
</apiSources>
</configuration>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
在控制器中看起来
@PostMapping("/filter")
@ApiOperation()
public void createTargetFilter(
@ApiParam(value = "TargetFilterSaveRqDto", required = true) @RequestParam TargetFilterSaveRqDto targetFilterSaveRqDto
) throws JsonProcessingException {