Im documenting my endpoint with Open Api 3.0.2 and generate a swagger ui interface from the yaml. My service takes a soap response and generates a json response. The elements on the soap response however are optional.
The json is generated based on the present elements in the soap response. Is there a way to mark some of the values as optional? I was thinking about the anyOf property but it doesnt work on the components level of the yaml (at least, I coudn't get it to work). Take below example, say the json response can have all these properties but it could only have a few of them. Can I make this clearer in my yaml?
openapi: 3.0.0
...
paths:
/path:
get:
responses:
'200':
description: Success
content:
application/json:
schema:
$ref: '#/components/schemas/Product'
components:
schemas:
Product:
type: object
properties:
productid:
type: string
origin:
type: string
shortname:
type: string
names:
type: array
items:
type: string
price:
type: string
shipping:
type: string