Skip to content

Annotating generic file response #143

@Johoseph

Description

@Johoseph

Hello! Is there an established way to annotate a generic file response? I am currently facilitating this using the OpenAPI decorator as below:

@Get("/file")
@OpenAPI({
  responses: {
    "200": {
      description: "File response",
      content: {
        "application/octet-stream": {
          schema: {
            type: "file",
          },
        },
      },
    },
  },
})

Which does render the response I am looking for, however since no @ResponseSchema decorator has been specified, swagger also includes a blank application/json response option (which is not correct).

image

I have tried using the ResponseSchema decorator, rather than my current implementation, but specifying a contentType of application/octet-stream produces the following error:

C:\Users\JosephMoroney\Documents\FR2\ex-api\node_modules\routing-controllers-openapi\src\decorators.ts:133
        source.responses[statusCode]?.content[contentType].schema
                                                           ^
TypeError: Cannot read properties of undefined (reading 'schema')

Any thoughts/ideas would be appreciated!

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