Open gigaga opened 4 years ago
You are using invalid references, your discriminator should look something like this:
discriminator:
propertyName: pet_type
mapping:
dog: "#/components/schemas/Dog"
cat: "#/components/schemas/Cat"
lizard: "#/components/schemas/Lizard"
Thanks @mohdzohlof. Indeed like that but it should work in implicit way too (https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#discriminator-object). Also, by using mapping in external reference context, it does not work too :(
It works fine when using full URI reference
openapi: 3.0.0
########## INFO ##########
info:
title: Test
description: Specifications of test bounded context
version: 1.0.0
paths:
/pet:
put:
tags:
- Pet
description: Test
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/Pet"
description: Capture that has to be applied to transaction
responses:
"200":
description: The transaction captured.
content:
application/json:
schema:
$ref: "#/components/schemas/Pet"
components:
schemas:
Pet:
type: object
required:
- pet_type
properties:
pet_type:
type: string
discriminator:
propertyName: pet_type
mapping:
dog: "#/components/schemas/Dog"
cat: "#/components/schemas/Cat"
lizard: "#/components/schemas/Lizard"
Dog:
allOf:
- $ref: "#/components/schemas/Pet"
- type: object
# all other properties specific to a `Dog`
properties:
bark:
type: string
Cat:
allOf:
- $ref: "#/components/schemas/Pet"
- type: object
# all other properties specific to a `Cat`
properties:
name:
type: string
Lizard:
allOf:
- $ref: "#/components/schemas/Pet"
- type: object
# all other properties specific to a `Lizard`
properties:
lovesRocks:
type: boolean
Hello,
Try it by using external file like this : pet.yaml#/Pet
Best regards,
Yes that's a bug in the tool, check #862 and check https://github.com/Redocly/redoc/issues/862#issuecomment-491631228 for a workaround
Hi,
Firstly, congratulations for your tool. It is really the best viewer that I could have used!
From redoc v2.0.0-rc.18, I have a problem with discriminator & mapping fields of OpenAPI 3 Indeed, below, we can see my screenshot from the following specs file: