Invalid URL error is cryptic

Open
#86 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
python
Domain
api

Research direction

Start in openapi_spec_validator/validators.py around line 48, where validation handles a spec containing a file-based $ref. Trace how jsonschema.exceptions.RefResolutionError is surfaced. Done means users receive a separate, actionable exception explaining that the filename should use the file://myfile.yaml format.

Written by the indexing model from the issue text.

Description

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

Dominant language
Python
Stars
409
Forks
73
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from python-openapi/openapi-spec-validator

All issues in python-openapi/openapi-spec-validator

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.