วิธีสามารถตั้งค่าคุณสมบัติของฟอรืมต้องรายการของข้อความรายการ<ข้อความ>

0

คำถาม

ฉันพยายามที่จะสร้าง springDoc งฟอรืมเอกสารคู่มือ,และฉันอยากจะเป็นตัวแทนของข้อมูลแบบนี้ List<String> elements; มีบางคุณสมบัติเหมือน minSize และ MaxSize/ความยาวแม็กซ์ความยาวสำหรับค่าอยู่ในรายการ ฉันพยายามกับเรื่องนี้

@Schema(required = true, minLength = 12,maxLength = 20)
List<String> elements;

แล้ว

@Size(min=10,max=20)
List<String> elements;

ผลลัพธ์:

"Products": {
  "title": "Products",
  "type": "object",
  "properties": {
    "elements": {
      "type": "array",
      "items": {
        "type": "string"
      }
    }
  }
}

รู้ไหมว่าจะมีผล:

"Products": {
    "title": "Products",
    "type": "object",
    "properties": {
        "elements": {
            "type": "array",
            "items": {
                "type": "string",
                "maxLength": 20,
                "minLength": 5
            }
        }
    }
}
annotations spring-boot swagger
2021-11-23 15:30:04
1
0

ฉันคิดว่า @ArraySchema คือสิ่งที่คุณกำลังมองหาตาม:

@Schema(minItems = 12, maxItems = 20)
List<String> elements;

@Schema คือที่จะใช้สำหรับคนที่ไม่ใช่อาเรย์ส่วนประกอบแล้ว @ArraySchema คือที่จะใช้สำหรับอาเรย์ส่วนประกอบ. ทั้งสองไม่สามารถ coexist.

2021-11-23 17:53:56

ในภาษาอื่นๆ

หน้านี้อยู่ในภาษาอื่นๆ

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................

ดังอยู่ในนี้หมวดหมู่

ดังคำถามอยู่ในนี้หมวดหมู่