swagger-codegen - 如何为生成的 C# SDK 方法提供主体?

swagger-codegen - How do I supply a body to the generated C# SDK method?

我正在使用来自 https://hub.docker.com/r/jimschubert/swagger-codegen-cli/ which pulls swagger-codegen from the master branch before it runs. I tried grabbing the recently documented (official) swagger-codegen-cli from https://hub.docker.com/r/swaggerapi/swagger-codegen-cli/ 的(非官方)swagger-codegen-cli Docker 容器,但它目前似乎不可用。

与非官方 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"
                    }
                }
            }
        }
    }
},

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

对我可能忽略或做错的事情有什么建议吗?

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