I have openapi requirements
components:
schemas:
UserGet:
allOf:
- $ref: '#/components/schemas/myElements'
UserPost:
allOf:
- $ref: '#/components/schemas/myElements'
myElements:
type: array
items:
allOf:
- $ref: 'myEnumItems'
myEnumItems:
type: String
enum:
- 'state1'
- 'state2'
UserGet
and UserPost
using myElements
schema.
Problem is myElements
have myEnumItems
with enum
state1
and state2
, which I want to restrict new user can POST only any of two values ['state1','state2']
, but in GET request there may be already available data in db for existing users for example 'state3'
. Since 'state3'
is not in enum
, for GET this use case will fail.
I am looking for idea to overcome this issue.
I am using https://swagger.io/docs/specification/paths-and-operations/ as reference.
It looks similar to Re-using model with different required properties but readOnly is not working for me. I am not sure which part I am missing.