Swagger-editor: OAS 3.0: Editor reports validation error on 'content' property under responses status code

Created on 20 Dec 2017  路  4Comments  路  Source: swagger-api/swagger-editor

| Q | A
| ----------------------------------- | -------
| Bug or feature request? | Bug
| Which Swagger/OpenAPI version? | 3.0
| Which Swagger-Editor version? | 3.1.20
| How did you install Swagger-Editor? | git clone + npm start
| Which broswer & version? | Chromium 63
| Which operating system? | Linux Mint

Demonstration API definition


swagger: "2.0"
info:
  description: "my api"
  version: "0.1.0"
  title: "my apiI"
host: "my.api.com"
basePath: "/myapi"
tags:
- name: "tag1"
schemes:
- "https"
paths:
  /thing:
    post:
      tags:
      - "tag1"
      summary: ""
      description: ""
      operationId: "op1"
      consumes:
      - "application/json"
      produces:
      - "application/json"
      - "application/json+problem"
      parameters:
      - in: "body"
        name: "body"
        description: ""
        required: true
        schema:
          $ref: "#/definitions/RequestBody"
      responses:
        '400':
          description: ""
          content:
            application/json+problem:
              schema:
                $ref: "#/definitions/ErrorResponse"

Configuration (browser query string, constructor, config.yaml)

all default, no query string

Expected Behavior



There should not be validation error AND there should be auto complete on "content" property

Current Behavior



Validation error : "Schema error at paths['/thing'].post.responses['400']
should NOT have additional properties
additionalProperty: content, description"

Context



Trying to use OAS 3 response objects

support 3.x

Most helpful comment

You pointed the right mistake of mine... thank you :)
Sorry for late posting, I wanted to test something else before coming back to you.
Using openapi: '3.0.0' and doing some changes made it work !

Problem solved.

All 4 comments

@gnieutin the error is valid, it occurs because you are mixing Swagger 2.0 and OpenAPI 3.0 syntax. The content keyword is part of OpenAPI 3.0, it's not supported in Swagger 2.0.

You need to change your response definition to:

      responses:
        '400':
          description: ""
          schema:
            $ref: "#/definitions/ErrorResponse"

This guide describes the 2.0 syntax for responses: https://swagger.io/docs/specification/2-0/describing-responses/

Thanks @hkosova, didn't notice the swagger: "2.0".

Moving this to support!

Closing due to inactivity.

This is simply to keep our issue tracker clean - feel free to comment if there are any further thoughts or concerns, and we'll be happy to reopen this issue.

You pointed the right mistake of mine... thank you :)
Sorry for late posting, I wanted to test something else before coming back to you.
Using openapi: '3.0.0' and doing some changes made it work !

Problem solved.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ChristineBoersen picture ChristineBoersen  路  3Comments

weldpua2008 picture weldpua2008  路  6Comments

variable picture variable  路  4Comments

Andriy-Kulak picture Andriy-Kulak  路  3Comments

confuser picture confuser  路  6Comments