fix to accept multitype param for nullable #51
Open
HajimeMat-AVAP wants to merge 3 commits intoreinfi:mainfrom
Open
fix to accept multitype param for nullable #51HajimeMat-AVAP wants to merge 3 commits intoreinfi:mainfrom
HajimeMat-AVAP wants to merge 3 commits intoreinfi:mainfrom
Conversation
To Accept openapi type like ``` - string - null ``` becouse API DOG generate like this if i allow null to params. logic is like if type is array and just have a 2 choice and 1 is "null" that means the type is the onather nullable. so I changed
…able Update TypeResolver.php
Owner
|
Could you please add a test case to TypeResolverTest and also in the acceptance.yml one test object. |
reinfi
requested changes
Aug 8, 2024
src/Generator/TypeResolver.php
Outdated
| $type = match ($schema->type) { | ||
| $schemaType = $schema->type; | ||
| if (is_array($schema->type) && count($schema->type) == 2 && in_array("null", $schema->type)) { | ||
| $schemaType = current( array_filter($schema->type, fn ($x) => $x !== 'null')); |
Owner
There was a problem hiding this comment.
please add typings to inner function, because $x can only be string
and also please to use short variable names like $x, $type would be suitable
src/Generator/TypeResolver.php
Outdated
| $type = match ($schema->type) { | ||
| $schemaType = $schema->type; | ||
| if (is_array($schema->type) && count($schema->type) == 2 && in_array("null", $schema->type)) { | ||
| $schemaType = current( array_filter($schema->type, fn ($x) => $x !== 'null')); |
Owner
There was a problem hiding this comment.
But does that mean, that the nullable type is not detected correctly because in the PropertyResolver you do not check again for the nullable type?
Author
There was a problem hiding this comment.
you are right, I wanted to check the property if it's nullable. but I could not found the way to check again.
Author
|
I'm tring to write a test code but currentry facing this error I will work on later. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
To Accept openapi type like
becouse API DOG generate like this if i allow null to params.
logic is like
if type is array and just have a 2 choice and 1 is "null" that means the type is the onather nullable.
so I changed