Open AurelienPillevesse opened 8 months ago
I think we need a way to differentiate between requests & responses.
For requests (incoming schemas) we should check if this serializer context option is set https://symfony.com/doc/current/components/serializer.html#require-all-properties. Without this option nullable properties are not required to be present.
For responses (outgoing schemas) we should check if this serializer context option is set https://symfony.com/doc/current/components/serializer.html#skipping-null-values. With this option nullable properties are not required to be present.
@DjordyKoert I don't understand.
In the response case, if my property is nullable, I would like to see it required in my schema. The expected value is string or null.
After, I use the generated json schema in a package for generating api. My logo property is nullable and should not be undefinable :
export interface Site {
logo?: string | null;
}
Should be :
export interface Site {
logo: string | null;
}
In my Symfony application, I have a controller which returns an output. Fields in this output which are not nullable are required in the OpenAPI documentation expect my nullable field in the same class (
attribute3
). Strange thing is that they are all in the constructor. In my opinion, therequired
forattribute3
is missing.Don't know if it's a bug. Here is the code.
This is the Output class in my API.
This is the code in my controller :
In my OpenAPI documentation: