在使用swagger时,如何让Azure API Management记录请求的正文?

我们使用swagger 2.0来记录我们在Azure API管理后面的Azure中托管的.Net Web API.我无法获取文档来详细说明作为正文的一部分发布的复杂对象. Azure根本没有显示有关该对象的详细信息,因此我必须自己记录它们.下面是我导入Azure API Management的json文件.

{
    "swagger": "2.0",
    "info": {
        "version": "1.0.0",
        "title": "Hotel Search",
        "description": "The seodecnvewjkl"
    },
    "basePath": "/v1",
    "consumes": [
        "application/xml",
        "application/json"
    ],
    "produces": [
        "application/xml",
        "application/json"
    ],
    "schemes": [
        "http",
        "https"
    ],
    "paths": {
        "/hotels/search": {
            "post": {
                "operationId": "searchCommand",
                "description": "Searches for hotels",
                "parameters": [
                    {
                        "name": "hotelSearchRq",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/HotelSearchRq"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "schema": {
                            "title": "HotelSearchRs",
                            "$ref": "#/definitions/HotelSearchRs"
                        }
                    },
                    "400": {
                        "description": "Bad Request"
                    },
                    "404": {
                        "description": "Unauthorised"
                    }
                }
            },
            "get": {
                "operationId": "searchQuery",
                "parameters": [
                    {
                        "name": "CorrelationId",
                        "in": "query",
                        "type": "string"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Successful response"
                    }
                }
            }
        }
    },
    "definitions": {
        "StayDetail": {
            "type": "object",
            "properties": {
                "NumberOfGuests": {
                    "type": "integer"
                },
                "CheckinDate": {
                    "type": "string",
                    "format": "date",
                    "description": "the date that the stay starts from"
                }
            }
        },
        "HotelSearchCriteria": {
            "type": "object",
            "properties": {
                "MaximumResults": {
                    "type": "integer",
                    "format": "int64"
                },
                "StayDetails": {
                    "$ref": "#/definitions/StayDetail"
                }
            }
        },
        "HotelSearchRq": {
            "type": "object",
            "properties": {
                "CustomerTransactionIdentifier": {
                    "type": "string",
                    "description": "The customers transaction identifier"
                },
                "search_criteria": {
                    "$ref": "#/definitions/HotelSearchCriteria"
                }
            }
        },
        "HotelSearchRs": {
            "type": "object"
        }
    }
}

Azure Api Management operation screen

有人可以帮助我如何从swagger文档自动记录身体?

最佳答案 目前,来自Swagger文档的请求和响应正文信息未显示在开发人员门户文档中.

这已不再是这种情况.样本和架构显示在开发人员门户中.

点赞