Skip to content

Question: How can I get the raw response body without decoding? #2552

@MisterMX

Description

@MisterMX

Problem statement

I have an API endpoint that returns a response body in application/json, application/x-yaml or application/gzip based on the type of data behind it. Currently the generated client always decodes the response based on its MIME type. However, the content is very dynamic and I just need it as a blob.

Is there a way to receive the raw content of the response body as byte[]?

Swagger specification

swagger: '2.0'
info:
  title: My API
paths:
  /my-endpoint:
    get:
      consumes:
        - application/json
      produces:
        - application/x-yaml
        - application/gzip
        - application/json
      summary: Get the resource
      responses:
        '200':
          # what to put here?
        '404':
          description: Not Found

Environment

swagger version: v0.26.1
go version: 1.16.2
OS: Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions