我在Swagger中有一系列参数
"parameters": [
{
"name": "username",
"description": "Fetch username by username/email",
"required": false,
"type": "string",
"paramType": "query"
},
{
"name": "site",
"description": "Fetch username by site",
"required": false,
"type": "string",
"paramType": "query"
},
{
"name": "survey",
"description": "Fetch username by survey",
"required": false,
"type": "string",
"paramType": "query"
}
],
Run Code Online (Sandbox Code Playgroud)
必须填写一个参数但是哪个参数无关紧要,其他参数可以留空.有没有办法在Swagger中表现出来?
我有一个使用 Java 11 的 Spring Boot (2.4.0) REST 服务。端点和对象是使用 openapi-generator-maven-plugin v5.0.1 从 OpenAPI 3.0.3 文件生成的
在 API 中,有一个 GET 请求需要两个查询参数。其中至少必须有一名在场。此示例提到使用 minProperties。尽管我已在 OpenAPI 文件中指定了minProperties,但自动生成的对象不会验证这一点。有办法让它发挥作用吗?
OpenAPI 3.3 代码片段:
parameters:
- in: query
name: id
required: true
style: form
explode: true
schema:
title: EntityId
type: object
properties:
businessId:
type: string
nonBusinessId:
type: string
minProperties: 1
additionalProperties: false
Run Code Online (Sandbox Code Playgroud)
openapi-generator-maven-plugin 配置文件:
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>5.0.1</version>
<executions>
<execution>
<id>generate-api</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${project.build.directory}/swagger/apis/api.yaml</inputSpec>
<generatorName>spring</generatorName>
<apiPackage>com.acme.api</apiPackage>
<modelPackage>com.acme.api.dto</modelPackage>
<configOptions>
<dateLibrary>java8</dateLibrary>
<interfaceOnly>true</interfaceOnly>
<java8>true</java8>
<useBeanValidation>true</useBeanValidation> …Run Code Online (Sandbox Code Playgroud)