Skip to content

Conversation

@gracekarina
Copy link
Contributor

Allow Empty strings as valid when deserializing a specification.

@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
Contributor

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
Contributor

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!


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
Contributor

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.

3 participants