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 response body fails validation #101

Open
klausbadelt opened this issue Feb 9, 2021 · 1 comment · May be fixed by #133
Open

Empty response body fails validation #101

klausbadelt opened this issue Feb 9, 2021 · 1 comment · May be fixed by #133
Milestone

Comments

@klausbadelt
Copy link

Validation fails on 204 response, which has empty string as body.

Example:

paths:
  /health_check:
    get:
      description: Health check
      responses:
        '204':
          description: OK

Code

OpenAPIParser.load 'openapi.yml'
request_operation = root.request_operation :get, '/health_check'
validatable_response_body = OpenAPIParser::RequestOperation::ValidatableResponseBody.new(204, "", {})
response_validate_options = OpenAPIParser::SchemaValidator::ResponseValidateOptions.new
request_operation.validate_response_body(validatable_response_body, response_validate_options)

Expected result is truth-y, but actual result is nil.

This is btw similar to a bug in openapi-library/OpenAPIValidators#54.

@ota42y
Copy link
Owner

ota42y commented Mar 27, 2021

But I think it is better to return true when the validation was passed so we should change return value :)

@ota42y ota42y added this to the 1.0.0 milestone May 2, 2021
tristanoneil pushed a commit to tristanoneil/openapi_parser that referenced this issue Mar 30, 2022
As mentioned in ota42y#101 it makes more sense to return true from this method
when validation passes instead of nil.
@tristanoneil tristanoneil linked a pull request Mar 30, 2022 that will close this issue
tristanoneil pushed a commit to tristanoneil/openapi_parser that referenced this issue Mar 30, 2022
As mentioned in ota42y#101 it makes more sense to return true from this method
when validation passes instead of nil.
tristanoneil pushed a commit to tristanoneil/openapi_parser that referenced this issue Mar 30, 2022
As mentioned in ota42y#101 it makes more sense to return true from this method
when validation passes instead of nil.
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