-
Notifications
You must be signed in to change notification settings - Fork 9.2k
Closed
Description
swagger-api/swagger-editor#1212 seem to imply that the following is legal in Open API v2 and v3.
(This is a little different than the example in the git issue because the one there is not technically correct)
Foo:
type: object
properties:
req2:
type: string
req3:
type: string
opt1:
type: string
opt2:
type: string
Bar:
allOf:
- $ref: '#/definitions/Foo'
- type: object
required:
- req1
- req2
- req3
properties:
req1:
type: string
But I am wondering if anyone knows whether adding a discriminator into the mix changes the behavior.
FooType:
type: string
enum:
- a
- b
- c
Foo:
type: object
properties:
id:
type: string
Bar:
allOf:
- $ref: '#/definitions/Foo'
- type: object
discriminator: foo_type
required:
- foo_type
properties:
foo_type:
$ref: '#/definitions/FooType'
optional1:
type: string
FooBar:
allOf:
- $ref: '#/definitions/Bar'
- type: object
required:
- optional1
properties:
optional2:
type: string
#1428 provides a lot of good information, but does not seem to explain this particular scenario - FooBar declares a property in the "required" list that exists in one of the other objects.
Is the above spec valid? Would it set "optional1" as required in FooBar and not required in Bar?
Thanks for any clarification.
languitar and hajjimurad
Metadata
Metadata
Assignees
Labels
No labels