모델은 변수 및 속성이있는 java의 POJO 클래스와 비슷합니다. 모델 섹션에서는 사용자 정의 클래스를 정의 할 수 있으며 데이터 유형으로 참조 할 수 있습니다.
{
"models": {
"Pet": {
"id": "Pet",
"properties": {
"id": {
"type": "long"
},
"status": {
"allowableValues": {
"valueType": "LIST",
"values": [
"available",
"pending",
"sold"
]
},
"description": "pet status in the store",
"type": "string"
},
"name": {
"type": "string"
},
"photoUrls": {
"items": {
"type": "string"
},
"type": "Array"
}
}
}
}}
다음과 같이 모델에 정의되어있는 다음 매개 변수 섹션에서
{
"path": "/pet.{format}",
"description": "Operations about pets",
"operations": [
{
"httpMethod": "POST",
"summary": "Add a new pet to the store",
"responseClass": "void",
"nickname": "addPet",
"parameters": [
{
"description": "Pet object that needs to be added to the store",
"paramType": "body",
"required": true,
"allowMultiple": false,
"dataType": "Pet"
}
],
"errorResponses": [
{
"code": 405,
"reason": "Invalid input"
}
]
}
아래에 표시되는 경우 모델에 대한 자세한 내용은 Swagger PetStore example
S 모델은 수업과 비슷합니다.