-
Notifications
You must be signed in to change notification settings - Fork 533
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
Empty strings #1619
Empty strings #1619
Conversation
return deserialize(rootNode,path, true); | ||
} | ||
|
||
public SwaggerParseResult deserialize(JsonNode rootNode, String path, boolean allowEmptyStrings) { |
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.
It makes probably sense to pass directly ParseOptions options
to deserializer as other future options could be meaningful
if (result.isAllowEmptyStrings() && value != null) { | ||
tag.setName(value); | ||
} |
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.
This applies to all similar code change: with the change if flag is false no value will be set, even when present and not empty!
@@ -396,12 +397,12 @@ public Tag getTag(ObjectNode obj, String location, ParseResult result) { | |||
Tag tag = new Tag(); | |||
|
|||
String value = getString("name", obj, true, location, result); | |||
if (result.isAllowEmptyStrings() && value != null) { | |||
if (result.isAllowEmptyStrings() && value != null || !result.isAllowEmptyStrings() && !StringUtils.isBlank(value)) { |
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.
I would add parenthesis for clarity:
if ((result.isAllowEmptyStrings() && value != null) || (!result.isAllowEmptyStrings() && !StringUtils.isBlank(value))) {
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.
done
Allow Empty strings as valid when deserializing a specification.