Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature]: Auto-detect base_uri when using OpenAPI.from_file_path #801

Open
jonathanberthias opened this issue Mar 1, 2024 · 0 comments

Comments

@jonathanberthias
Copy link
Contributor

Suggested Behavior

When I create an OpenAPI instance with a multi-file schema, I find myself writing:

spec_path = "path/to/spec.yaml"
openapi = openapi_core.OpenAPI.from_file_path(
    spec_path,
    config=openapi_core.Config(spec_base_uri=Path(spec_path).as_uri()),
)

This feels redundant as the implementation for SchemaPath.from_file_path also loads the base_uri, but that information is then lost:
https://github.com/p1c2u/jsonschema-path/blob/f35bd22aa5a0b86fa4c194e47a29aa46908b0d10/jsonschema_path/paths.py#L86

Why is this needed?

Ideally I would write the above as:

spec_path = "path/to/spec.yaml"
openapi = openapi_core.OpenAPI.from_file_path(spec_path)

and the spec_base_uri would be correctly set.

The base_uri is technically available but is private, e.g.:

base_uri = openapi.spec.accessor.resolver._base_uri

References

No response

Would you like to implement a feature?

None

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant