Swagger-editor: OAS 3.0: schema inheritance overwrites $ref definition

Created on 19 Sep 2017  路  6Comments  路  Source: swagger-api/swagger-editor

| Q | A
| ----------------------------------- | -------
| Bug or feature request? | bug
| Which Swagger/OpenAPI version? | 3.0.0
| Which Swagger-Editor version? | master
| How did you install Swagger-Editor? | npm + swaggerhub
| Which broswer & version? |safari 10.1.2
| Which operating system? | OSX

Demonstration API definition


    paths:
      /entity.json:
        get:
          tags:
            - entity
          summary: List of public entities
          operationId: listPublicEntities
          responses:
            '200':
              description: successful operation
              content:
                application/json:
                  schema:
                    $ref: '#/components/schemas/EntityListResponse'
            '400':
              description: invalid operation
              content:
                application/json:
                  schema:
                    $ref: '#/components/schemas/ExceptionResponse'

    components:
      schemas:
        Response:
          type: object
          properties:
            version:
              type: string

        ExceptionResponse:
          $ref: '#/components/schemas/Response'
    #      type: object
          properties:
            exception:
              $ref: '#/components/schemas/Exception'

        EntityListResponse:
          $ref: '#/components/schemas/Response'
    #      type: object
          properties:
            entities:
              type: array
              items: 
                $ref: '#/components/schemas/Entity'

        Exception:
          type: object
          properties:
            message:
              type: string
            type:
              type: string
            code:
              type: integer

        Entity:
          type: object
          properties:
            uuid:
              type: string
            type:
              type: string
            title:
              type: string
            active:
              type: boolean

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

Expected Behavior


EntityListResponse and ExceptionResponse should inherit version field from Response. EntityListResponse for HTTP 200 OK should not show any exception properties, but rather Entity properties.

Current Behavior


EntityListResponse for 200 OK example shows in the editor as exception:

{
  "version": "string",
  "exception": {
    "message": "string",
    "type": "string",
    "code": 0
  }
}

Possible Solution


Context


P2 validation bug 3.x

All 6 comments

Invalid. Should use allOf instead. Might still be beneficial if editor raised an error?

It should produce a validation warning that anything other than the $ref will be ignored.

Sorry of OT,

How do you guys get source that support openapi 3.0?
I tried checking out master, branch v/3.1.10, tags v3.1.* After run, all of them don't support openapi 3.0 and throw out error

Schema error
should NOT have additional properties
additionalProperty: openapi

@hungnd, make sure your openapi property is openapi: "3.0.0". If that doesn't solve your problem, feel free to open a new issue and we'll help out there.

@shockey thank for your response. I wrote openapi: "**3.0**"then it caused that error.
I don't want to open a new issue before I sure it's a bug or just my mistake. Thank you again. Problem solved!

Closing, we produce validation warnings for this now:

image

Was this page helpful?
0 / 5 - 0 ratings