0

我正在使用来自https://hub.docker.com/r/jimschubert/swagger-codegen-cli/的(非官方)swagger-codegen-cli Docker 容器,它在运行之前从主分支中提取 swagger-codegen。我尝试从https://hub.docker.com/r/swaggerapi/swagger-codegen-cli/获取最近记录的(官方)swagger-codegen-cli ,但目前似乎不可用。

与非官方 cli 一样,我从 swagger 文档中生成了一个 C# SDK,其中包含以下内容:

/api/customer/{zoneId}/files/cover/gallery: {
    get: {
        tags: [
            "FileUpload"
        ],
        summary: "Get all files in customer cover gallery",
        operationId: "FileUpload_GetCustomerCoverFiles",
        consumes: [ ],
        produces: [
            "application/json",
            "text/json"
        ],
        parameters: [
            {
                name: "zoneId",
                in: "path",
                description: "",
                required: true,
                type: "integer",
                format: "int32"
            }
        ],
        responses: {
            200: {
                description: "OK",
                schema: {
                    type: "array",
                    items: {
                        $ref: "#/definitions/FileUploadGalleryItemModel"
                    }
                }
            }
        }
    },
    post: {
        tags: [
            "FileUpload"
        ],
        summary: "Upload file to customer cover gallery",
        operationId: "FileUpload_CreateCustomerCoverGalleryItem",
        consumes: [
            "application/octet-stream"
        ],
        produces: [
            "application/json",
            "text/json"
        ],
        parameters: [
            {
                name: "zoneId",
                in: "path",
                description: "",
                required: true,
                type: "integer",
                format: "int32"
            },
            {
                name: "payload",
                in: "body",
                description: "",
                required: true,
                type: "byte[]",
                format: "binary"
            }
        ],
        responses: {
            200: {
                description: "OK",
                schema: {
                    type: "array",
                    items: {
                        $ref: "#/definitions/FileUploadGalleryItemModel"
                    }
                }
            }
        }
    }
},

“有效负载”是在请求的正文中提供的,但是我看不到任何方法可以将正文提供给 SDK 中生成的具有以下签名的方法:public List<FileUploadGalleryItemModel> FileUploadCreateCustomerCoverGalleryItem (int? zoneId).

关于我可能忽略或做错的任何建议?

4

1 回答 1

2

您可以将文档记录payload为文件(表单参数),例如https://github.com/swagger-api/swagger-codegen/blob/master/modules/swagger-codegen/src/test/resources/2_0/petstore.yaml# L269-L273,您将在自动生成的文档中找到示例代码(请查看自动生成的 README.md 作为起点)

于 2017-02-15T17:08:01.043 回答