-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Closed
Labels
Description
Description of the problem/issue
Using oneOf in an OAS 3.1 @Schema annotation results in an additional $ref in the root of the property.
This happens both when using two classes, and with one class, and allowing null as property value.
Expected behaviour is that $refs would only be used inside the oneOf array.
Affected Version
2.2.36
Steps to Reproduce
Allowing myProperty to be one of two classes:
Using:
@Schema(oneOf = {SomeDto.class, OtherDto.class})Actual outcome:
components:
schemas:
MyDto:
type: object
properties:
myProperty:
$ref: "#/components/schemas/SomeDto"
oneOf:
- $ref: "#/components/schemas/SomeDto"
- $ref: "#/components/schemas/OtherDto"Expected outcome:
components:
schemas:
MyDto:
type: object
properties:
myProperty:
oneOf:
- $ref: "#/components/schemas/SomeDto"
- $ref: "#/components/schemas/OtherDto"Allowing myProperty to be a class or null:
Using:
@Schema(oneOf = {SomeDto.class}, types = {"object", "null"})Actual outcome:
components:
schemas:
MyDto:
type: object
properties:
myProperty:
type:
- object
- "null"
$ref: "#/components/schemas/SomeDto"
oneOf:
- $ref: "#/components/schemas/SomeDto"Expected outcome:
components:
schemas:
MyDto:
type: object
properties:
myProperty:
type:
- object
- "null"
oneOf:
- $ref: "#/components/schemas/SomeDto"