question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

OAS 3.0: schema inheritance overwrites $ref definition

See original GitHub issue
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

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
shockeycommented, 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.

1reaction
webroncommented, Sep 19, 2017

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

OpenAPI Specification - Version 3.0.3 - Swagger
Tooling which supports OAS 3.0 SHOULD be compatible with all OAS 3.0.* versions. ... to reference those parts as follows from the JSON...
Read more >
OpenAPI Specification v3.0.3 | Introduction, Definitions, & More
The OpenAPI Specification (OAS) defines a standard, programming language-agnostic interface description for HTTP APIs.
Read more >
Is there a way to override properties' description and example ...
Note that the following two definitions are identical: Duck: allOf: - $ref: '#/components/schemas/Pet' - type: object properties: no_legs: ...
Read more >
Designing REST API with Open API Specification (OAS) v2.0 ...
The schema folder under openapi-3.0 contains the specification file spec.json defined in accordance with OAS v3.0.
Read more >
Schema (swagger-annotations 2.1.10 API) - javadoc.io
The annotation may be used to define a Schema for a set of elements of the ... is provided as value of implementation()...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found