逆引き的な話
環境
openapi: 3.0.0
書き方
type: string と同じ並びで以下のように記述する
minLength: 1 maxLength: 100
※もちろん両方揃っている必要はない
ユースケースと例
例えば「ニックネームは2文字以上8文字以下」としたい場合は以下のように設定する。
components:
schemas:
User:
type: object
description: "ユーザーを表すオブジェクト"
properties:
name:
description: ユーザ名
type: string
example: 鈴木太郎
nickname:
description: ニックネーム
type: string
minLength: 2
maxLength: 8