2

I'm getting 406 Not Acceptable responses when I'm trying to use the externalValue property in an example object on the swaggerhub mocked server.
Am I doing something wrong or this feature is not implemented on the swaggerhub mocking server?

API snippet

paths:
  /test:
    get:
      responses:
        "200":
          description: OK!
          content:
            application/json:
              schema:
                type: string
                format: binary
              examples:
                example:
                  externalValue: "https://jsonplaceholder.typicode.com/todos/1"
            application/pdf:
              schema:
                type: string
                format: binary
              examples:
                sampleFile:
                  externalValue: "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"

Postman API call

postman call

open api documentation

examples externalValue property

simecek
  • 23
  • 2
  • 4

1 Answers1

1

SwaggerHub mock server only supports JSON, XML, and YAML responses. If you request any other media types (e.g. Accept: application/pdf or Accept: image/png), a 406 response is returned.

SwaggerHub mock server does NOT support externalValue for sample responses. The mock ignores those examples and generates sample responses by other means, e.g. based on the response schema.


From the documentation (emphasis mine):

  • Generates JSON, XML and YAML responses based on response schemas and examples.
  • Supports enum, default, example, and examples (the first example is returned), except for externalValue examples.
Helen
  • 87,344
  • 17
  • 243
  • 314
  • I saw this documentation you linked in but I thought JSON, XML and YAML responses are mentioned there only because of response Content-Type you can set as default. Thank you kindly for your explanation. – simecek Sep 02 '22 at 12:35