-
-
Notifications
You must be signed in to change notification settings - Fork 887
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adjust null handling in exported JSON Schema / OpenAPI #3518
Adjust null handling in exported JSON Schema / OpenAPI #3518
Conversation
ba308b4
to
2fc14d6
Compare
2fc14d6
to
bf4b2b0
Compare
@@ -214,7 +214,7 @@ private function buildPropertySchema(Schema $schema, string $definitionName, str | |||
$className = $valueType->getClassName(); | |||
} | |||
|
|||
$valueSchema = $this->typeFactory->getType(new Type($builtinType, $type->isNullable(), $className, $isCollection), $format, $propertyMetadata->isReadableLink(), $serializerContext, $schema); | |||
$valueSchema = $this->typeFactory->getType(new Type($builtinType, !$propertyMetadata->isRequired() || $type->isNullable(), $className, $isCollection), $format, $propertyMetadata->isReadableLink(), $serializerContext, $schema); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Being nullable is not enought here, we also need to check if the property is required.
If it's not required, it means this property should be nullable.
82ba090
to
a2cfac2
Compare
a2cfac2
to
ede900f
Compare
ede900f
to
84e09da
Compare
Should it be really the case though? |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
#3402 was a really good start to have a better null handling in exported schema.
But actually we should use required attribute as a condition for nullability.
A non-required property should be nullable.