6

I'm trying to create example responses for an endpoint with Swagger 2.0.

    200:
      description: Successful response
      schema:
        type: object
        $ref: "#/definitions/User"
      examples:
        application/vnd.api+json:
            - data:
                attributes:
                  full_name: John Appleseed
            - data:
                attributes:
                  full_name: Mike Appleseed

My api consumes and produces application/vnd.api+json, but it won't recognize it. If I delete the examples, my spec works. Any idea how to specify it?

error

Salsaparapizza
  • 169
  • 1
  • 2
  • 9
  • 1
    This is due to a bug that existed in the JSON Schema used for validation. While it's been fixed, it would take a few days until the editor is updated with it. – Ron Aug 03 '15 at 21:45

1 Answers1

9

It is not fully implemented yet, although you can define one single example like this:

   responses:
    "200":
      description: Successful response
      schema: 
        $ref: '#/definitions/User'
      examples:
        application/json:
          data:
            id: 1
            attributes:
              attr1: value1
              attr2: value2

there is one bug related with the mime-type, you cannot use dots thats why I did not put application/vnd.api+json