Skip to content

Fix relative schema file paths on Windows - #2132

Open
WenJing95 wants to merge 1 commit into
spec-first:mainfrom
WenJing95:fix/windows-relative-schema-refs
Open

Fix relative schema file paths on Windows#2132
WenJing95 wants to merge 1 commit into
spec-first:mainfrom
WenJing95:fix/windows-relative-schema-refs

Conversation

@WenJing95

Copy link
Copy Markdown

Fixes #2109.

Relative schema references such as ./schema.yaml receive a malformed UNC prefix on Windows because FileHandler builds a host prefix even when the URI has no host. Only add that prefix when a host is present, so relative references resolve from the working directory while UNC file URIs retain their host.

Changes proposed in this pull request:

  • Cover relative references through FileHandler and resolve_refs.
  • Verify absolute file URIs with escaped spaces and Windows UNC path conversion.

Validation on Windows 11 / Python 3.12.7:

  • The two new relative-reference cases fail before the fix and pass afterward.
  • pytest tests/test_references.py tests/test_operation2.py tests/test_json_validation.py -q: 42 passed.
  • Black, isort, and flake8 checks pass for the changed files.

The existing test_api.py::test_relative_refs cases fail on both the base and this branch: their Windows drive path is used as a URI base, causing urljoin to discard the specification directory.

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 this pull request may close these issues.

_uri_to_path produces erroneous result on windows

1 participant