skryukov / openapi_validator

OpenApi v3 validator
MIT License
1 stars 1 forks source link

Unclear error message when required property does not received #13

Closed sas145alex closed 4 years ago

sas145alex commented 4 years ago

Unclear error message when required property does not received

Steps to reproduce:


schema:
  type: object
  required:
    - some_field
/statistics/specializations should return valid response with code 200 on `GET /api/v1/statistics/specializations/meta`
     Failure/Error: skip_error = processor.options[:response] && defined_properties[property]["writeOnly"]

     NoMethodError:
       undefined method `[]' for nil:NilClass
     # /bundle/gems/openapi_validator-0.4.1/lib/openapi_validator/schema/required_attribute.rb:19:in `block in validate'
     # /bundle/gems/openapi_validator-0.4.1/lib/openapi_validator/schema/required_attribute.rb:11:in `each'
     # /bundle/gems/openapi_validator-0.4.1/lib/openapi_validator/schema/required_attribute.rb:11:in `validate'
     # /bundle/gems/json-schema-2.8.1/lib/json-schema/schema/validator.rb:25:in `block in validate'
     # /bundle/gems/json-schema-2.8.1/lib/json-schema/schema/validator.rb:23:in `each'
     # /bundle/gems/json-schema-2.8.1/lib/json-schema/schema/validator.rb:23:in `validate'
     # /bundle/gems/json-schema-2.8.1/lib/json-schema/schema.rb:33:in `validate'
     # /bundle/gems/json-schema-2.8.1/lib/json-schema/validator.rb:115:in `validate'
     # /bundle/gems/json-schema-2.8.1/lib/json-schema/validator.rb:256:in `validate!'
     # /bundle/gems/json-schema-2.8.1/lib/json-schema/validator.rb:273:in `fully_validate'
     # /bundle/gems/openapi_validator-0.4.1/lib/openapi_validator/response_validators/json_validator.rb:13:in `validate'
     # /bundle/gems/openapi_validator-0.4.1/lib/openapi_validator/response_validator.rb:36:in `validate_response'
     # /bundle/gems/openapi_validator-0.4.1/lib/openapi_validator/response_validator.rb:18:in `call'
     # /bundle/gems/openapi_validator-0.4.1/lib/openapi_validator/response_validator.rb:14:in `call'
     # /bundle/gems/openapi_validator-0.4.1/lib/openapi_validator/request_validator.rb:31:in `validate_response'
     # /bundle/gems/openapi_rspec-0.4/lib/openapi_rspec/request_validator.rb:31:in `matches?'
     # /bundle/gems/openapi_rspec-0.4/lib/openapi_rspec/module_helpers.rb:9:in `block in validate_code
sas145alex commented 4 years ago

Was fixed in https://github.com/medsolutions/openapi_validator/pull/10