OpenAPI で $ref で参照した schema に nullable:true を追加する
code:api.yml
schema:
Hoge:
type: string
enum:
- foo
- bar
であるとき、場合によっては nullable: true としたい
code: api.yml
paths:
/api:
post:
requestBody:
content:
application/json:
schema:
type: object
properties:
hoge:
nullable: true
allOf:
- $ref: "#components/schema/Hoge"
のように allOf を使うとマージできる
参考: https://stackoverflow.com/questions/40920441/how-to-specify-a-property-can-be-null-or-a-reference-with-swagger