Skip to content
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

Closed

Conversation

Korbeil
Copy link
Contributor

@Korbeil Korbeil commented Apr 23, 2020

Q A
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tickets N/A
License MIT
Doc PR N/A

#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.

@Korbeil Korbeil changed the title Better nullable fields declaration in exported Swagger Better nullable properties in exported OpenAPI Apr 23, 2020
@Korbeil Korbeil force-pushed the feature/add-nullable-to-property branch 5 times, most recently from ba308b4 to 2fc14d6 Compare April 23, 2020 17:44
@Korbeil Korbeil changed the title Better nullable properties in exported OpenAPI [WIP] Better nullable properties in exported OpenAPI Apr 23, 2020
@Korbeil Korbeil force-pushed the feature/add-nullable-to-property branch from 2fc14d6 to bf4b2b0 Compare April 23, 2020 21:21
@Korbeil Korbeil changed the title [WIP] Better nullable properties in exported OpenAPI [WIP] Better nullable properties in exported JSON Schema / OpenAPI Apr 23, 2020
@Korbeil Korbeil changed the title [WIP] Better nullable properties in exported JSON Schema / OpenAPI Better nullable properties in exported JSON Schema / OpenAPI Apr 23, 2020
@@ -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);
Copy link
Contributor Author

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.

@Korbeil Korbeil changed the title Better nullable properties in exported JSON Schema / OpenAPI Better null handling in exported JSON Schema / OpenAPI Apr 23, 2020
@Korbeil Korbeil force-pushed the feature/add-nullable-to-property branch 3 times, most recently from 82ba090 to a2cfac2 Compare April 23, 2020 21:59
@Korbeil Korbeil changed the title Better null handling in exported JSON Schema / OpenAPI Adjust null handling in exported JSON Schema / OpenAPI Apr 24, 2020
@soyuka soyuka requested a review from teohhanhui April 28, 2020 08:47
Base automatically changed from master to main January 23, 2021 21:59
@alanpoulain alanpoulain force-pushed the feature/add-nullable-to-property branch from a2cfac2 to ede900f Compare March 4, 2021 16:15
@alanpoulain alanpoulain force-pushed the feature/add-nullable-to-property branch from ede900f to 84e09da Compare March 9, 2021 10:05
@alanpoulain
Copy link
Member

Should it be really the case though?
If a property is not required but has a default value, it shouldn't be nullable, isn't it?

@stale
Copy link

stale bot commented Nov 4, 2022

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.

@stale stale bot added the wontfix label Nov 4, 2022
@stale
Copy link

stale bot commented Jan 3, 2023

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.

@stale stale bot added the stale label Jan 3, 2023
@stale stale bot closed this Jan 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants