Skip to content

library generates a broken file #56

Description

@delasource

My swaggerfile accepts a parameter of type "multipart/form-data". I generate my client class like:

$ react-query-swagger /tanstack /input:http://localhost:5103/swagger/hubapi-v1/swagger.json /output:src/api/QueryClient.ts /template:fetch

The generated code contains the following method in QueryClient.ts (default output file):

uploadTaskAttachment(taskId: number, uploadTaskAttachmentRequest: Blob): Promise<UploadTaskAttachmentResponse> {
    let url_ = this.baseUrl + "/api/tasks/{taskId}/attachments/upload";
    ...

which is valid.

However, the generated "Query.ts" file contains an import of the Blob-type, which is invalid code, as "Types" does not contain the definition of Blob. Blob is a standard type that should not be ex nor imported.

import * as Types from '../QueryClient';

...

type UploadTaskAttachment__MutationParameters = UploadTaskAttachmentQueryParameters & {
  uploadTaskAttachmentRequest: Types.Blob;
}

This may be an issue in NSwag but i'm not sure. Maybe i have another problem in my swagger file. Any hints would be helpful, thanks.

It only happens with multipart/form-data. Other content-types result in (proper) application/json-requests.

swagger json
    "/api/tasks/{taskId}/attachments/upload": {
      "post": {
        "tags": [
          "Api"
        ],
        "summary": "Upload an attachment file for a task",
        "operationId": "UploadTaskAttachment",
        "parameters": [
          {
            "name": "taskId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "requestBody": {
          "x-name": "UploadTaskAttachmentRequest",
          "description": "",
          "content": {
            "multipart/form-data": {
              "schema": {
                "$ref": "#/components/schemas/UploadTaskAttachmentRequest"
              }
            }
          },
          "required": true,
          "x-position": 1
        },

... 

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions