swagger-parser
swagger-parser copied to clipboard
Dereference discriminator mappings
I've noticed that the swagger-parser
doesn't dereference discriminator mappings. I realize that is not part of the JSON schema spec, but it is part of the OpenAPI spec. Are there plans to add this functionality?
Here is an example. The $ref
is dereferenced just fine, but the mappings are ignored.
I realize this would probably break a lot of libraries that are using this tool, so if it's implemented I think an option to enable or disable would be best.
openapi: '3.0.0'
info:
title: ''
version: ''
paths:
/:
get:
responses:
200:
description: ''
content:
application/json:
schema:
$ref: '#/components/schemas/OneOf'
components:
schemas:
OneOf:
oneOf:
- $ref: '#/components/schemas/A'
- $ref: '#/components/schemas/B'
discriminator:
propertyName: type
mapping:
A: '#/components/schemas/A'
B: '#/components/schemas/B'
A:
type: object
properties:
type:
type: string
a:
type: boolean
B:
type: object
properties:
type:
type: string
b:
type: boolean
You can't really dereference them. Since discriminator
only works if you have referenceable schemas, the right way to go would be to drop discriminator
during dereferencing, otherwise the resulting OpenAPI doc would be invalid.