swagger-codegen - 如何为生成的 C# SDK 方法提供正文



我正在使用来自 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) .

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

您可以将

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

最新更新