Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

216
Vistas
Describe response type application/pdf in openapi-generator-cli

I have API endpoint, that returns pdf file. Trying to describe something like this:

  /SupportingDocument/document/{documentId}:
    get:
      tags: [Company, Document]
      operationId: getDocument
      summary: Get document by id
      security:
        - JWTAuth: []
      parameters:
        - in: path
          name: documentId
          required: true
          schema: { type: string }
      responses:
        200:
          description: A PDF file
          content:
            application/pdf:
              schema:
                type: string
                format: binary
        404: { $ref: '#/components/responses/InternalServerError' }
        500: { $ref: '#/components/responses/InternalServerError' }

But generator ends up with

...
            return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
                if (response.status >= 200 && response.status < 300) {
                    return response.json(); // trying to return json, but this is pdf file starting from "%...."
                } else {
                    throw response;
                }
            });

And then i catch error like "Unexpected token % at position 0...". How can i describe it right?

UPD: I need it to work something like this:

            return fetch(basePath + localVarFetchArgs.url, localVarFetchArgs.options).then((response) => {
                if (response.status >= 200 && response.status < 300) {
                    return response; // just response, not json
                } else {
                    throw response;
                }
            });
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda