anyOf in OpenAPI 3.0
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
anyOf in OpenAPI 3.0
Hi experts,
I am facing issue on defining the AnyOf in YAML Open API 3.0 version.
sample:
weight:
description: >-
Please enter the weight information for line item. Either a
netValue or grossValue must be provided for the line item.
type: object
properties:
netValue:
description: Please enter the net weight value
type: number
minimum: 0
maximum: 999999999999
multipleOf: 0.001
example: 10
grossValue:
description: Please enter the gross weight value
type: number
minimum: 0
maximum: 999999999999
multipleOf: 0.001
example: 10
additionalProperties: false
anyOf:
- netValue
- grossValue
I am facing issue on anyOf which keep mentioned need to be an object for the netValue and grossValue.
What is the best way for me to proceed?
Appreciate inputs.
Thanks.
- Labels:
-
Swagger Editor
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Try this:
anyOf:
- required: [netValue]
- required: [grossValue]
Note that "anyOf" means either or both properties should be present. If just one of these properties should be present (i.e. they are musually exclusive), use "oneOf" instead.
Helen Kosova
SmartBear Documentation Team Lead
________________________
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
