我使用springdoc-openapi-maven-plugin来生成YAML格式的合同,并且它以某种方式为每个路径/请求参数生成null (example: null
)的示例。有办法避免吗?
openapi: 3.0.1
paths:
/myapi/v1/resource/{id}:
get:
parameters:
- name: id
in: path
required: true
schema:
type: string
example: null
- name: param1
in: query
required: true
schema:
type: string
example: null
和插件(pom.xml)
<plugin>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-maven-plugin</artifactId>
<version>1.4</version>
<configuration>
<apiDocsUrl>http://localhost:8080/v3/api-docs.yaml</apiDocsUrl>
<outputFileName>myYamlFile.yaml</outputFileName>
<outputDir>/home/</outputDir>
</configuration>
<executions>
<execution>
<id>integration-test</id>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
资源控制器(非常基本的):
@RestController
@RequestMapping("/myapi/v1/resource")
public class ResourceController {
@GetMapping("/{id}")
public ResourceDTO getResourceInfo(@PathVariable("id") String resourceId, @RequestParam(value="param1") String param1) {
[...]
}
}
编辑-example: null
的出现始于jackson-databind的升级对2.14.0
的依赖性
我使用的是旧版本的springdoc-openapu-webflux-ui。将它从1.6.5版本更改为1.6.11,并修复了它。