domaindrivendev/Swashbuckle.AspNetCore

[Bug]: Record nullable property (reference type) not marked as nullable in generated open api specification

panky98 opened this issue · 4 comments

Describe the bug

I have a record which have nullable reference type property:
image

In generated open api specification that property is not marked as nullable:
image

Expected behavior

Property to have nullable: true

Actual behavior

Property is not marked as nullable.

Steps to reproduce

No response

Exception(s) (if any)

No response

Swashbuckle.AspNetCore version

6.2.3

.NET Version

7.0

Anything else?

/

Please update to the latest release of Swashbuckle.AspNetCore, 6.6.2, and see if this is still an issue or not.

Hi @martincostello, thanks for suggestion. I have already tried that, still the same thing unfortunately

It's a dupe of #1303, ref siblings are not allowed on OpenApi 3.0.1
So you should use UseAllOfToExtendReferenceSchemas, this changes the schema a bit putting the allOf on the schemas and setting the nullable

Thanks @jgarciadelanoceda! I have wrote a ISchemaFilter as a workaround doing the same thing.. but not necessary apparently