cebe / php-openapi

Read and write OpenAPI yaml/json files and make the content accessible in PHP objects.
MIT License
464 stars 87 forks source link

Allow nullable references #184

Closed provokateurin closed 1 year ago

kynx commented 1 year ago

Are you sure the spec allows this? My understanding of the Reference Object is that it doesn't:

This object cannot be extended with additional properties and any properties added SHALL be ignored.

FWIW, I seem to recall an ugly hack to work around this restriction. Something like:

NullableThingy:
    nullable: true
    oneOf:
        - $ref: "#/components/schemas/Thingy"
provokateurin commented 1 year ago

Note that this restriction on additional properties is a difference between Reference Objects and Schema Objects that contain a $ref keyword.

I see, so my problem actually seems to be that something gets interpreted as a Reference object instead of as a Schema object (since that allows nullable together with $ref).

provokateurin commented 1 year ago

Ok this is a specific bug in my application. Thanks for your help!