考虑这个 OAS3 规范 ( testMinMax3.yaml):
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
Run Code Online (Sandbox Code Playgroud)
非空(又名minLength: 1)是否意味着required即使未根据 openapi 规范 (1) 设置字段?或者仅当用户提供该字段的值时才适用(2)?
Hel*_*len 12
不。
minLength和required是单独的约束。minLength意味着如果提供了字符串值,则其长度必须等于minLength或大于。
| 归档时间: |
|
| 查看次数: |
6797 次 |
| 最近记录: |