Skip to content

Deprecate spec_base_uri #859

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

Merged
merged 1 commit into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions openapi_core/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ def __init__(

@classmethod
def from_dict(
cls, data: Schema, config: Optional[Config] = None
cls, data: Schema, config: Optional[Config] = None, base_uri: str = ""
) -> "OpenAPI":
sp = SchemaPath.from_dict(data)
sp = SchemaPath.from_dict(data, base_uri=base_uri)
return cls(sp, config=config)

@classmethod
Expand All @@ -110,9 +110,12 @@ def from_file_path(

@classmethod
def from_file(
cls, fileobj: SupportsRead, config: Optional[Config] = None
cls,
fileobj: SupportsRead,
config: Optional[Config] = None,
base_uri: str = "",
) -> "OpenAPI":
sp = SchemaPath.from_file(fileobj)
sp = SchemaPath.from_file(fileobj, base_uri=base_uri)
return cls(sp, config=config)

def _get_version(self) -> SpecVersion:
Expand All @@ -133,7 +136,8 @@ def check_spec(self) -> None:
try:
validate(
self.spec.contents(),
base_uri=self.config.spec_base_uri,
base_uri=self.config.spec_base_uri
or self.spec.accessor.resolver._base_uri, # type: ignore[attr-defined]
cls=cls,
)
except ValidatorDetectError:
Expand Down
2 changes: 1 addition & 1 deletion openapi_core/configurations.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Config(UnmarshallerConfig):
spec_validator_cls
Specifincation validator class.
spec_base_uri
Specification base uri.
Specification base uri. Deprecated, use base_uri parameter in OpenAPI.from_dict and OpenAPI.from_file if you want to define it.
request_validator_cls
Request validator class.
response_validator_cls
Expand Down
Loading