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 and blank query parameter examples are parsed to null #1375

Closed
mih-kopylov opened this issue May 16, 2020 · 1 comment · Fixed by #1376
Closed

Empty and blank query parameter examples are parsed to null #1375

mih-kopylov opened this issue May 16, 2020 · 1 comment · Fixed by #1376
Assignees

Comments

@mih-kopylov
Copy link
Contributor

Empty and blank query parameter examples are parsed to null, while it's expected them to be parsed to a valid empty or blank string respectively.

openapi: 3.0.2
info:
  title: Example references
  version: 1.0.0
paths:
  /foo:
    get:
      parameters:
        - name: paramName
          in: query
          example: " "
      responses:
        '200':
          description: success

result.getOpenAPI().getPaths().get("/foo").getGet().getParameters().get(0).getExample() returns null while I expect it to return " "

The same is with an empty string.

@mih-kopylov
Copy link
Contributor Author

The reason seems to be in OpenAPIDeserializer#getAnyExample

            if (example.getNodeType().equals(JsonNodeType.STRING)) {
                String value = getString(nodeKey, node, false, location, result);
                //it checks a string for not blank
                if (StringUtils.isNotBlank(value)) {
                    return value;
                }
            }

@mih-kopylov mih-kopylov changed the title Empty and blank examples are parsed to null Empty and blank query parameter examples are parsed to null May 16, 2020
mih-kopylov added a commit to mih-kopylov/swagger-parser that referenced this issue May 16, 2020
Empty and blank query parameter examples were parsed to null.
Now they are parsed to an empty and blank string respectively.
gracekarina added a commit that referenced this issue May 25, 2020
@gracekarina gracekarina self-assigned this May 25, 2020
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 a pull request may close this issue.

2 participants