Skip to content

Discriminator: how properly detect valid reference #2520

Description

@Logioniz

Suppose we have such OpenAPI document which served by location http://example.com/openapi/desc

servers:
- url: 'http://example.com/'components:
schemas:
Pet:
type: objectrequired:
- petTypeproperties:
petType:
type: stringdiscriminator:
propertyName: petTypemapping:
dog: DogCat:
allOf:
- $ref: '#/components/schemas/Pet'
- type: object# all other properties specific to a `Cat`properties:
name:
type: stringDog:
allOf:
- $ref: '#/components/schemas/Pet'
- type: object# all other properties specific to a `Dog`properties:
bark:
type: stringLizard:
allOf:
- $ref: '#/components/schemas/Pet'
- type: object# all other properties specific to a `Lizard`properties:
lovesRocks:
type: boolean

it is not clear what mean Dog in the mapping subscheme.
Variants:

  1. http://example.com/openapi/Dog (accroding to base uri http://example.com/openapi/desc)
  2. #/components/schemas/Dog

If i have subschema in another url (http://example.com/openapi/Dog) thеn Dog is relative link.
If i have subschema in components thеn Dog is #/components/schemas/Dog (which is also a relative link, but different)

How to correctly determine that Dog is a relative link or subschema in #/components/schema?

Sorry for bad english.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions