4
4
from typing import Optional
5
5
from typing import Union
6
6
7
+ from jsonschema_path import SchemaPath
7
8
from openapi_core .exceptions import SpecError
8
9
from openapi_core .finders import SpecClasses
9
10
from openapi_core .finders import SpecFinder
85
86
}
86
87
87
88
88
- def get_classes (spec : Spec ) -> SpecClasses :
89
+ def get_classes (spec : SchemaPath ) -> SpecClasses :
89
90
return SpecFinder (SPECS ).get_classes (spec )
90
91
91
92
92
93
def unmarshal_apicall_request (
93
94
request : Request ,
94
- spec : Spec ,
95
+ spec : SchemaPath ,
95
96
base_url : Optional [str ] = None ,
96
97
cls : Optional [RequestUnmarshallerType ] = None ,
97
98
** unmarshaller_kwargs : Any ,
98
99
) -> RequestUnmarshalResult :
99
100
if not isinstance (request , Request ):
100
101
raise TypeError ("'request' argument is not type of Request" )
101
- if not isinstance (spec , Spec ):
102
- raise TypeError ("'spec' argument is not type of Spec " )
102
+ if not isinstance (spec , SchemaPath ):
103
+ raise TypeError ("'spec' argument is not type of SchemaPath " )
103
104
if cls is None :
104
105
classes = get_classes (spec )
105
106
cls = classes .request_unmarshaller_cls
@@ -113,15 +114,15 @@ def unmarshal_apicall_request(
113
114
114
115
def unmarshal_webhook_request (
115
116
request : WebhookRequest ,
116
- spec : Spec ,
117
+ spec : SchemaPath ,
117
118
base_url : Optional [str ] = None ,
118
119
cls : Optional [WebhookRequestUnmarshallerType ] = None ,
119
120
** unmarshaller_kwargs : Any ,
120
121
) -> RequestUnmarshalResult :
121
122
if not isinstance (request , WebhookRequest ):
122
123
raise TypeError ("'request' argument is not type of WebhookRequest" )
123
- if not isinstance (spec , Spec ):
124
- raise TypeError ("'spec' argument is not type of Spec " )
124
+ if not isinstance (spec , SchemaPath ):
125
+ raise TypeError ("'spec' argument is not type of SchemaPath " )
125
126
if cls is None :
126
127
classes = get_classes (spec )
127
128
cls = classes .webhook_request_unmarshaller_cls
@@ -139,15 +140,15 @@ def unmarshal_webhook_request(
139
140
140
141
def unmarshal_request (
141
142
request : AnyRequest ,
142
- spec : Spec ,
143
+ spec : SchemaPath ,
143
144
base_url : Optional [str ] = None ,
144
145
cls : Optional [AnyRequestUnmarshallerType ] = None ,
145
146
** unmarshaller_kwargs : Any ,
146
147
) -> RequestUnmarshalResult :
147
148
if not isinstance (request , (Request , WebhookRequest )):
148
149
raise TypeError ("'request' argument is not type of (Webhook)Request" )
149
- if not isinstance (spec , Spec ):
150
- raise TypeError ("'spec' argument is not type of Spec " )
150
+ if not isinstance (spec , SchemaPath ):
151
+ raise TypeError ("'spec' argument is not type of SchemaPath " )
151
152
if isinstance (request , WebhookRequest ):
152
153
if cls is None or issubclass (cls , WebhookRequestUnmarshaller ):
153
154
return unmarshal_webhook_request (
@@ -179,7 +180,7 @@ def unmarshal_request(
179
180
def unmarshal_apicall_response (
180
181
request : Request ,
181
182
response : Response ,
182
- spec : Spec ,
183
+ spec : SchemaPath ,
183
184
base_url : Optional [str ] = None ,
184
185
cls : Optional [ResponseUnmarshallerType ] = None ,
185
186
** unmarshaller_kwargs : Any ,
@@ -188,8 +189,8 @@ def unmarshal_apicall_response(
188
189
raise TypeError ("'request' argument is not type of Request" )
189
190
if not isinstance (response , Response ):
190
191
raise TypeError ("'response' argument is not type of Response" )
191
- if not isinstance (spec , Spec ):
192
- raise TypeError ("'spec' argument is not type of Spec " )
192
+ if not isinstance (spec , SchemaPath ):
193
+ raise TypeError ("'spec' argument is not type of SchemaPath " )
193
194
if cls is None :
194
195
classes = get_classes (spec )
195
196
cls = classes .response_unmarshaller_cls
@@ -204,7 +205,7 @@ def unmarshal_apicall_response(
204
205
def unmarshal_webhook_response (
205
206
request : WebhookRequest ,
206
207
response : Response ,
207
- spec : Spec ,
208
+ spec : SchemaPath ,
208
209
base_url : Optional [str ] = None ,
209
210
cls : Optional [WebhookResponseUnmarshallerType ] = None ,
210
211
** unmarshaller_kwargs : Any ,
@@ -213,8 +214,8 @@ def unmarshal_webhook_response(
213
214
raise TypeError ("'request' argument is not type of WebhookRequest" )
214
215
if not isinstance (response , Response ):
215
216
raise TypeError ("'response' argument is not type of Response" )
216
- if not isinstance (spec , Spec ):
217
- raise TypeError ("'spec' argument is not type of Spec " )
217
+ if not isinstance (spec , SchemaPath ):
218
+ raise TypeError ("'spec' argument is not type of SchemaPath " )
218
219
if cls is None :
219
220
classes = get_classes (spec )
220
221
cls = classes .webhook_response_unmarshaller_cls
@@ -233,7 +234,7 @@ def unmarshal_webhook_response(
233
234
def unmarshal_response (
234
235
request : AnyRequest ,
235
236
response : Response ,
236
- spec : Spec ,
237
+ spec : SchemaPath ,
237
238
base_url : Optional [str ] = None ,
238
239
cls : Optional [AnyResponseUnmarshallerType ] = None ,
239
240
** unmarshaller_kwargs : Any ,
@@ -242,8 +243,8 @@ def unmarshal_response(
242
243
raise TypeError ("'request' argument is not type of (Webhook)Request" )
243
244
if not isinstance (response , Response ):
244
245
raise TypeError ("'response' argument is not type of Response" )
245
- if not isinstance (spec , Spec ):
246
- raise TypeError ("'spec' argument is not type of Spec " )
246
+ if not isinstance (spec , SchemaPath ):
247
+ raise TypeError ("'spec' argument is not type of SchemaPath " )
247
248
if isinstance (request , WebhookRequest ):
248
249
if cls is None or issubclass (cls , WebhookResponseUnmarshaller ):
249
250
return unmarshal_webhook_response (
@@ -276,15 +277,15 @@ def unmarshal_response(
276
277
277
278
def validate_request (
278
279
request : AnyRequest ,
279
- spec : Spec ,
280
+ spec : SchemaPath ,
280
281
base_url : Optional [str ] = None ,
281
282
cls : Optional [AnyRequestValidatorType ] = None ,
282
283
** validator_kwargs : Any ,
283
284
) -> Optional [RequestUnmarshalResult ]:
284
285
if not isinstance (request , (Request , WebhookRequest )):
285
286
raise TypeError ("'request' argument is not type of (Webhook)Request" )
286
- if not isinstance (spec , Spec ):
287
- raise TypeError ("'spec' argument is not type of Spec " )
287
+ if not isinstance (spec , SchemaPath ):
288
+ raise TypeError ("'spec' argument is not type of SchemaPath " )
288
289
289
290
if isinstance (request , WebhookRequest ):
290
291
if cls is None or issubclass (cls , WebhookRequestValidator ):
@@ -317,7 +318,7 @@ def validate_request(
317
318
def validate_response (
318
319
request : Union [Request , WebhookRequest , Spec ],
319
320
response : Union [Response , Request , WebhookRequest ],
320
- spec : Union [Spec , Response ],
321
+ spec : Union [SchemaPath , Response ],
321
322
base_url : Optional [str ] = None ,
322
323
cls : Optional [AnyResponseValidatorType ] = None ,
323
324
** validator_kwargs : Any ,
@@ -326,8 +327,8 @@ def validate_response(
326
327
raise TypeError ("'request' argument is not type of (Webhook)Request" )
327
328
if not isinstance (response , Response ):
328
329
raise TypeError ("'response' argument is not type of Response" )
329
- if not isinstance (spec , Spec ):
330
- raise TypeError ("'spec' argument is not type of Spec " )
330
+ if not isinstance (spec , SchemaPath ):
331
+ raise TypeError ("'spec' argument is not type of SchemaPath " )
331
332
332
333
if isinstance (request , WebhookRequest ):
333
334
if cls is None or issubclass (cls , WebhookResponseValidator ):
@@ -361,15 +362,15 @@ def validate_response(
361
362
362
363
def validate_apicall_request (
363
364
request : Request ,
364
- spec : Spec ,
365
+ spec : SchemaPath ,
365
366
base_url : Optional [str ] = None ,
366
367
cls : Optional [RequestValidatorType ] = None ,
367
368
** validator_kwargs : Any ,
368
369
) -> None :
369
370
if not isinstance (request , Request ):
370
371
raise TypeError ("'request' argument is not type of Request" )
371
- if not isinstance (spec , Spec ):
372
- raise TypeError ("'spec' argument is not type of Spec " )
372
+ if not isinstance (spec , SchemaPath ):
373
+ raise TypeError ("'spec' argument is not type of SchemaPath " )
373
374
if cls is None :
374
375
classes = get_classes (spec )
375
376
cls = classes .request_validator_cls
@@ -381,15 +382,15 @@ def validate_apicall_request(
381
382
382
383
def validate_webhook_request (
383
384
request : WebhookRequest ,
384
- spec : Spec ,
385
+ spec : SchemaPath ,
385
386
base_url : Optional [str ] = None ,
386
387
cls : Optional [WebhookRequestValidatorType ] = None ,
387
388
** validator_kwargs : Any ,
388
389
) -> None :
389
390
if not isinstance (request , WebhookRequest ):
390
391
raise TypeError ("'request' argument is not type of WebhookRequest" )
391
- if not isinstance (spec , Spec ):
392
- raise TypeError ("'spec' argument is not type of Spec " )
392
+ if not isinstance (spec , SchemaPath ):
393
+ raise TypeError ("'spec' argument is not type of SchemaPath " )
393
394
if cls is None :
394
395
classes = get_classes (spec )
395
396
cls = classes .webhook_request_validator_cls
@@ -406,7 +407,7 @@ def validate_webhook_request(
406
407
def validate_apicall_response (
407
408
request : Request ,
408
409
response : Response ,
409
- spec : Spec ,
410
+ spec : SchemaPath ,
410
411
base_url : Optional [str ] = None ,
411
412
cls : Optional [ResponseValidatorType ] = None ,
412
413
** validator_kwargs : Any ,
@@ -415,8 +416,8 @@ def validate_apicall_response(
415
416
raise TypeError ("'request' argument is not type of Request" )
416
417
if not isinstance (response , Response ):
417
418
raise TypeError ("'response' argument is not type of Response" )
418
- if not isinstance (spec , Spec ):
419
- raise TypeError ("'spec' argument is not type of Spec " )
419
+ if not isinstance (spec , SchemaPath ):
420
+ raise TypeError ("'spec' argument is not type of SchemaPath " )
420
421
if cls is None :
421
422
classes = get_classes (spec )
422
423
cls = classes .response_validator_cls
@@ -429,7 +430,7 @@ def validate_apicall_response(
429
430
def validate_webhook_response (
430
431
request : WebhookRequest ,
431
432
response : Response ,
432
- spec : Spec ,
433
+ spec : SchemaPath ,
433
434
base_url : Optional [str ] = None ,
434
435
cls : Optional [WebhookResponseValidatorType ] = None ,
435
436
** validator_kwargs : Any ,
@@ -438,8 +439,8 @@ def validate_webhook_response(
438
439
raise TypeError ("'request' argument is not type of WebhookRequest" )
439
440
if not isinstance (response , Response ):
440
441
raise TypeError ("'response' argument is not type of Response" )
441
- if not isinstance (spec , Spec ):
442
- raise TypeError ("'spec' argument is not type of Spec " )
442
+ if not isinstance (spec , SchemaPath ):
443
+ raise TypeError ("'spec' argument is not type of SchemaPath " )
443
444
if cls is None :
444
445
classes = get_classes (spec )
445
446
cls = classes .webhook_response_validator_cls
0 commit comments