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

1
  • 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. Commented Aug 3, 2015 at 21:45

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

1 Comment

Couldn't you use quotes?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.