Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not possible to set responseType to blob #767

Open
kispuding opened this issue Jun 7, 2024 · 0 comments
Open

Not possible to set responseType to blob #767

kispuding opened this issue Jun 7, 2024 · 0 comments

Comments

@kispuding
Copy link

Hi, I am experiencing an issue when trying to generate client from drf's @extend_schema decorator. My endpoint returns a response which contains an xlsx file, I am only able to process that if I set the generated client's responseType manually to blob, but it is set incorrectly to json.
I've found many suggestions to set x-in-file in the decorator, I even tried to set it as header, but none of the suggestions works.
Here is how I currently specify the response in extend_schema decorator:
`
responses={

        200: {
            'x-is-file': 'true',
            'content': {
                'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet': {
                    'schema': {
                        'type': 'string',
                        'format': 'binary'
                    }
                }
            },
            'headers': {
                'x-is-file': {
                    'description': 'Indicates if the response is a file',
                    'type': 'string',
                    'example': 'true'
                }
            },
        }
    }`

and this is generated:

`
this.request<File, any>({

   path: '/api/v1/object/export/',
    method: "GET",
    query: query,
    secure: true,
    format: "json",
    ...params,
  }),`

Rewriting this manually to:
`this.request<File, any>({

    path: '/api/v1/object/export/',
    method: "GET",
    query: query,
    secure: true,
    format: "blob",
    ...params,
  }),`

works as intended.
Any ideas where the problem should be?
Many thanks in advance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant