4

我们正在使用 swagger 2.0 来记录我们在 Azure API 管理后面托管在 Azure 中的 .Net Web API。我在获取文档以详细说明作为正文的一部分发布的复杂对象时遇到了麻烦。Azure 根本没有显示有关该对象的任何细节,这让我不得不自己记录它们。下面是我导入 Azure API 管理的 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 管理操作画面

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

4

1 回答 1

1

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

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

于 2015-11-27T23:29:42.730 回答