cancel
Showing results for 
Search instead for 
Did you mean: 

Cannot add "content" to the "responses"

SOLVED
Highlighted
New Contributor

Cannot add "content" to the "responses"

When I try to the "content" under "responses" I get the error:

 

responses['200'] should NOT have additional properties additionalProperty: content, description

 

Even though I copied the code straight out of the Swagger example:

 

responses:
 200:
  description: "Got form"
   content:
    application/json:
     schema:
      type: object
      properties:
       id:
        type: integer
        description: The user ID.

 

It doesn't like the content field, what am I doing wrong?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Moderator

Re: Cannot add "content" to the "responses"

Hi vmcg105,

 

Is your spec in the OpenAPI 3.0 or Swagger 2.0 format?

 

If you use OpenAPI 3.0, add quotes around "200" and make sure description and content have the indentation.

 

If it's Swagger 2.0, use the following instead. See Describing Responses for more examples.

paths:
  /something:
    get:
      produces:
        - application/json
      responses:
        200:
          description: "Got form"
          schema:
            type: object
            properties:
              id:
                type: integer
                description: The user ID.

 


Helen Kosova
SmartBear Documentation Team Lead
________________________
Learn SmartBear products in a fun and easy way and prove your knowledge!
>>Participate in the TechCorner Challenge today

View solution in original post

3 REPLIES 3
Highlighted
Moderator

Re: Cannot add "content" to the "responses"

Hi vmcg105,

 

Is your spec in the OpenAPI 3.0 or Swagger 2.0 format?

 

If you use OpenAPI 3.0, add quotes around "200" and make sure description and content have the indentation.

 

If it's Swagger 2.0, use the following instead. See Describing Responses for more examples.

paths:
  /something:
    get:
      produces:
        - application/json
      responses:
        200:
          description: "Got form"
          schema:
            type: object
            properties:
              id:
                type: integer
                description: The user ID.

 


Helen Kosova
SmartBear Documentation Team Lead
________________________
Learn SmartBear products in a fun and easy way and prove your knowledge!
>>Participate in the TechCorner Challenge today

View solution in original post

Highlighted
New Contributor

Re: Cannot add "content" to the "responses"

Is there a good example of the 3.0?

When I switch my doc to point to 3.0 I get this:

Schema error at swagger

should be equal to one of the allowed values allowedValues: 2.0

Highlighted
Moderator

Re: Cannot add "content" to the "responses"

3.0 specs use

openapi: 3.0.0

not

swagger: "3.0"

 

We have a 3.0 syntax guide here:
https://swagger.io/docs/specification/basic-structure/
and the response syntax guide:
https://swagger.io/docs/specification/describing-responses/

 

Hope this helps!


Helen Kosova
SmartBear Documentation Team Lead
________________________
Learn SmartBear products in a fun and easy way and prove your knowledge!
>>Participate in the TechCorner Challenge today
New Here?
Join us and watch the welcome video:
Announcements