openapi-spec-validator icon indicating copy to clipboard operation
openapi-spec-validator copied to clipboard

Invalid URL error is cryptic

Open strets123 opened this issue 6 years ago • 1 comments

When I validate a spec containing a $ref pointing to a file then I get an error like

jsonschema.exceptions.RefResolutionError: unknown url type: '../shared.yaml'

At the jsonschema level this makes some sense but clearly there is something I can do about it as an opeanapi validator user. Therefore I argue we should catch and reraise a separate exception telling the user to pass in a filename in the format file://myfile.yaml

Where shouild such handling go? In this method?

https://github.com/p1c2u/openapi-spec-validator/blob/f13bd8c4e05f8c2ab1c54c6021897d8ad99f29f9/openapi_spec_validator/validators.py#L48

strets123 avatar Nov 14 '19 13:11 strets123

I believe it should be handled by 3tf party libraries/projects that use openapi-spec-validator. We can't tell openapi validator user that he should use file:// because it depends on which handlers you use.

p1c2u avatar Jan 13 '20 13:01 p1c2u