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

Response HTTP status is not enclosed in quotation marks in YAML format #139

Closed
uladzimir-tsyperman opened this issue Jul 14, 2020 · 4 comments
Assignees
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@uladzimir-tsyperman
Copy link

HTTP status in responses section is not enclosed in quotation marks as it is required by OpenAPI 3 specification: https://swagger.io/specification/#responses-object

Actual:

      responses:
        200:
          description: "200"

To be:

      responses:
        "200":
          description: "200"
@ozscheyge
Copy link
Contributor

ozscheyge commented Jul 14, 2020

Hey @uladzimir-tsyperman ,

thanks for the report! Relevant quote from the spec:

This field MUST be enclosed in quotation marks (for example, "200") for compatibility between JSON and YAML.

@ozscheyge ozscheyge added bug Something isn't working good first issue Good for newcomers labels Jul 14, 2020
@ozscheyge
Copy link
Contributor

ozscheyge commented Jul 15, 2020

This seems to be an (upstream) serialization issue.

We are correctly passing HTTP status as Strings to the OpenAPI 3 model classes, see: https://github.com/ePages-de/restdocs-api-spec/blob/master/restdocs-api-spec-openapi3-generator/src/main/kotlin/com/epages/restdocs/apispec/openapi3/OpenApi3Generator.kt#L300

Seems to be a similar issue to this upstream issue.

        return if (yamlFormats.contains(format)) {
            Yaml.pretty().apply {
                (factory as YAMLFactory).configure(YAMLGenerator.Feature.MINIMIZE_QUOTES, false)
            }.writeValueAsString(openApi)
        } else {
            Json.pretty().writeValueAsString(openApi)
        }

in https://github.com/ePages-de/restdocs-api-spec/blob/master/restdocs-api-spec-openapi3-generator/src/main/kotlin/com/epages/restdocs/apispec/openapi3/ApiSpecificationWriter.kt might do the trick. But first I'd suggest to bump the io.swagger.core.v3:swagger-core version to see if this has been addressed in the meantime.

@ozscheyge
Copy link
Contributor

ozscheyge commented Jul 15, 2020

022cfe4 (version bump) seems to have solved it.

Before I was getting:

      responses:
        200:
          description: "200"
          headers:
            SIGNATURE:
              description: This is some signature

After the version bump:

      responses:
        "200":
          description: "200"
          headers:
            SIGNATURE:
              description: This is some signature

@ozscheyge ozscheyge self-assigned this Jul 15, 2020
@ozscheyge
Copy link
Contributor

Fixed with https://github.com/ePages-de/restdocs-api-spec/releases/tag/0.9.11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants