Skip to content

Commit 8d7bfe7

Browse files
committed
Deprecate spec_base_uri
1 parent 012416b commit 8d7bfe7

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

openapi_core/app.py

+9-5
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,9 @@ def __init__(
8989

9090
@classmethod
9191
def from_dict(
92-
cls, data: Schema, config: Optional[Config] = None
92+
cls, data: Schema, config: Optional[Config] = None, base_uri: str = ""
9393
) -> "OpenAPI":
94-
sp = SchemaPath.from_dict(data)
94+
sp = SchemaPath.from_dict(data, base_uri=base_uri)
9595
return cls(sp, config=config)
9696

9797
@classmethod
@@ -110,9 +110,12 @@ def from_file_path(
110110

111111
@classmethod
112112
def from_file(
113-
cls, fileobj: SupportsRead, config: Optional[Config] = None
113+
cls,
114+
fileobj: SupportsRead,
115+
config: Optional[Config] = None,
116+
base_uri: str = "",
114117
) -> "OpenAPI":
115-
sp = SchemaPath.from_file(fileobj)
118+
sp = SchemaPath.from_file(fileobj, base_uri=base_uri)
116119
return cls(sp, config=config)
117120

118121
def _get_version(self) -> SpecVersion:
@@ -133,7 +136,8 @@ def check_spec(self) -> None:
133136
try:
134137
validate(
135138
self.spec.contents(),
136-
base_uri=self.config.spec_base_uri,
139+
base_uri=self.config.spec_base_uri
140+
or self.spec.accessor.resolver._base_uri,
137141
cls=cls,
138142
)
139143
except ValidatorDetectError:

openapi_core/configurations.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class Config(UnmarshallerConfig):
2828
spec_validator_cls
2929
Specifincation validator class.
3030
spec_base_uri
31-
Specification base uri.
31+
Specification base uri. Deprecated, use base_uri parameter in OpenAPI.from_dict and OpenAPI.from_file if you want to define it.
3232
request_validator_cls
3333
Request validator class.
3434
response_validator_cls

0 commit comments

Comments
 (0)