open-traffic-generator / openapiart

OpenAPI artifact generator
MIT License
6 stars 4 forks source link

Schema validation errors are not helpful to pinpoint exact line which has the bad keyword/typo. #460

Open apratimmukherjee opened 7 months ago

apratimmukherjee commented 7 months ago
type: int [ instead of integer ] 
max : 200 [ instead of maximum: 200] 

Instead of pointing to line with issue, it gives this stacktrace which is not helpful.

validating C:\Users\apukherj\models\artifacts\openapi.yaml...
Traceback (most recent call last):
  File "C:\Users\apukherj\models\build.py", line 30, in <module>
    openapiart.OpenApiArt(
  File "C:\Users\apukherj\models\env\Lib\site-packages\openapiart\openapiart.py", line 62, in __init__
    self._bundle()
  File "C:\Users\apukherj\models\env\Lib\site-packages\openapiart\openapiart.py", line 97, in _bundle
    self._bundler.bundle()
  File "C:\Users\apukherj\models\env\Lib\site-packages\openapiart\bundler.py", line 124, in bundle
    self._validate_file()
  File "C:\Users\apukherj\models\env\Lib\site-packages\openapiart\bundler.py", line 427, in _validate_file
    openapi_spec_validator.validate_v3_spec(yobject)
  File "C:\Users\apukherj\models\env\Lib\site-packages\openapi_spec_validator\shortcuts.py", line 7, in validate
    return validator_callable(spec, spec_url=spec_url)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\apukherj\models\env\Lib\site-packages\openapi_spec_validator\validators.py", line 48, in validate
    raise err
openapi_spec_validator.exceptions.OpenAPIValidationError: {'required': True, 'content': {'application/json': {'schema': {'$ref': '#/components/schemas/Config', 'x-scope': ['']}}}} is not valid under any of the given schemas

Failed validating 'oneOf' in schema['properties']['paths']['patternProperties']['^\\/']['patternProperties']['^(get|put|post|delete|options|head|patch|trace)$']['properties']['requestBody']:
    {'oneOf': [{'$ref': '#/definitions/RequestBody'},
               {'$ref': '#/definitions/Reference'}]}

On instance['paths']['/config']['post']['requestBody']:
    {'content': {'application/json': {'schema': {'$ref': '#/components/schemas/Config',
                                                 'x-scope': ['']}}},
     'required': True}