Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OAS 3.0: schema inheritance overwrites $ref definition #1498

Closed
andig opened this issue Sep 19, 2017 · 6 comments
Closed

OAS 3.0: schema inheritance overwrites $ref definition #1498

andig opened this issue Sep 19, 2017 · 6 comments

Comments

@andig
Copy link

andig commented Sep 19, 2017

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

@andig
Copy link
Author

andig commented Sep 19, 2017

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

@webron
Copy link
Contributor

webron commented Sep 19, 2017

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

@hungnd
Copy link

hungnd commented Nov 1, 2017

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

@shockey
Copy link
Contributor

shockey commented Nov 1, 2017

@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.

@hungnd
Copy link

hungnd commented Nov 2, 2017

@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!

@shockey
Copy link
Contributor

shockey commented Jun 12, 2018

Closing, we produce validation warnings for this now:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants