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

Empty strings #1619

Merged
merged 4 commits into from
Oct 19, 2021
Merged

Empty strings #1619

merged 4 commits into from
Oct 19, 2021

Conversation

gracekarina
Copy link
Contributor

Allow Empty strings as valid when deserializing a specification.

Unverified

This user has not yet uploaded their public signing key.
@gracekarina gracekarina requested a review from frantuma October 12, 2021 21:27
return deserialize(rootNode,path, true);
}

public SwaggerParseResult deserialize(JsonNode rootNode, String path, boolean allowEmptyStrings) {
Copy link
Member

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

Comment on lines 399 to 401
if (result.isAllowEmptyStrings() && value != null) {
tag.setName(value);
}
Copy link
Member

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)) {
Copy link
Member

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))) {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants