swagger.json 仕様がどのように機能するかを理解するのに忙しい (私の場合は api.json)。調査中に、GET リクエストを処理する方法の例を多数見つけることができましたが、POST などについては何も見つかりませんでした。私の当面の必要性は POST 部分を実装することですが、コードをコピーして貼り付け、試行錯誤に頼って機能させるのではなく、これをよりよく理解する必要があると感じています. Swagger.io Web サイトのコンテンツは初心者向けではありません。以下のコード例で何が起こっているのか、特に「get:」の後に誰かが説明できますか?
{
"swagger": "2.0",
"info": {
"version": "v1",
"title": "FoodTrucks",
"description": "An TryApp sample API App where you can find Food trucks."
},
"host": "microsoft-apiapp1fe6951749ff4b76b8cc9194bc29ba61.azurewebsites.net:443",
"schemes": ["http", "https"],
"basePath": "/api/data",
"paths": {
"/foodtrucks": {
"get": {
"tags": ["FoodTrucks"],
"operationId": "getFoodTrucks",
"consumes": [],
"produces": ["application/json",
"text/json",
"application/xml",
"text/xml"],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/Restaurant"
}
}
}
},
"deprecated": false
}
},
"/foodtrucks/{id}": {
"get": {
"tags": ["FoodTrucks"],
"operationId": "getFoodTruckDetails",
"consumes": [],
"produces": ["application/json",
"text/json",
"application/xml",
"text/xml"],
"parameters": [{
"name": "id",
"in": "path",
"required": true,
"type": "integer",
"format": "int32"
}],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/Restaurant"
}
}
}
},
"deprecated": false
}
}
},
"definitions": {
"Restaurant": {
"type": "object",
"properties": {
"id": {
"format": "int32",
"type": "integer"
},
"name": {
"type": "string"
},
"likes": {
"format": "int32",
"type": "integer"
},
"savory": {
"type": "boolean"
},
"sweet": {
"type": "boolean"
},
"vegetarian": {
"type": "boolean"
},
"bookable": {
"type": "boolean"
},
"city": {
"type": "string"
}
}
}
}
}
簡単な POST の例も教えてください。