Swagger minLength:1是否意味着OpenAPI规范中需要它?
考虑这个OAS3规范(Swagger minLength:1是否意味着OpenAPI规范中需要它?,swagger,openapi,Swagger,Openapi,考虑这个OAS3规范(testMinMax3.yaml): 即使未根据openapi规范(1)设置字段,非空(也称为minLength:1)是否意味着必需?或者,这是否仅适用于用户提供的字段值(2)?否 minLength和required是单独的约束条件minLength意味着如果提供了字符串值,其长度必须是minLength或更多。要添加到这个答案中,请考虑以下场景:架构如何定义属性不能提供或仅当其长度至少为n个字符时才有效? openapi: 3.0.1 info: title: Op
testMinMax3.yaml
):
即使未根据openapi规范(1)设置字段,非空(也称为minLength:1
)是否意味着必需
?或者,这是否仅适用于用户提供的字段值(2)?否
minLength
和required
是单独的约束条件minLength
意味着如果提供了字符串值,其长度必须是minLength
或更多。要添加到这个答案中,请考虑以下场景:架构如何定义属性不能提供或仅当其长度至少为n
个字符时才有效?
openapi: 3.0.1
info:
title: OpenAPI Test
description: Test
license:
name: Apache-2.0
url: http://www.apache.org/licenses/LICENSE-2.0.html
version: 1.0.0
servers:
- url: http://localhost:9999/v2
paths:
/ping:
post:
summary: test
description: test it
operationId: pingOp
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/SomeObj'
required: true
responses:
200:
description: OK
content: {}
components:
schemas:
SomeObj:
type: string
minLength: 1
maxLength: 3