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

Boolean type should not have a format (OAS) #1463

Closed
ozraza opened this issue Jun 16, 2020 · 5 comments · Fixed by #1466 or #1597
Closed

Boolean type should not have a format (OAS) #1463

ozraza opened this issue Jun 16, 2020 · 5 comments · Fixed by #1466 or #1597

Comments

@ozraza
Copy link
Contributor

ozraza commented Jun 16, 2020

🐛 Bug Report

According to OAS specifications, boolean types should not have a format. Presence of format for boolean results in IBM OpenAPI Validator failing on boolean type/format verification. Turning off invalid_type_format_pair schema rule is not an option as it disables the data type/format rules.

https://github.com/grpc-ecosystem/grpc-gateway/blob/master/protoc-gen-swagger/genswagger/template.go#L68

Prerequisities

To Reproduce

  1. Define a message with a boolean type
message Test {
    bool field = 1;
}
  1. Generate swagger.json file using protoc-gen-swagger

  2. Perform openapi validation
    lint-openapi <path-to-swagger.json>

  3. See error

  Message :   Schema of type boolean should not have a format.
  Path    :   definitions.<definition>.properties.<message-param>.type
  Line    :   172

Expected behavior

Boolean format is not present to comply with OAS specifications thereby allowing openapi validation to pass.

Actual Behavior

Boolean format is present thereby causing openapi validation to fail.

Your Environment

MacOS Catalina 10.15.4

@achew22
Copy link
Collaborator

achew22 commented Jun 16, 2020

@ozraza very interesting. We generate OpenAPI v2 definitions, is this also true for the v2 spec?

@ozraza
Copy link
Contributor Author

ozraza commented Jun 16, 2020

@achew22 yes, this is also the case for the v2 spec. As far as I am aware, OpenAPI has never leveraged the format field for boolean types.

@achew22
Copy link
Collaborator

achew22 commented Jun 16, 2020

I believe the fix here is as simple as updating our internal mapping to reflect the correct value. Would you be willing to send in a PR to address this?

@ozraza
Copy link
Contributor Author

ozraza commented Jun 16, 2020

Yes, I am willing to submit a PR with the fix.

@ozraza
Copy link
Contributor Author

ozraza commented Jun 17, 2020

PR is open for review: #1466

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