assertions-mate 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,569 @@
1
+ # Copyright 2025 Terradue
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ from __future__ import annotations
16
+
17
+ from enum import Enum
18
+ from typing import List, Literal, Optional
19
+
20
+ from pydantic import BaseModel, Field, RootModel, conint, constr
21
+
22
+ class AssertionModel(BaseModel):
23
+
24
+ # Default dumps to JSON-friendly types (URLs -> str, datetimes -> ISO, etc.)
25
+ def model_dump(self, *args, **kwargs):
26
+ kwargs.setdefault('exclude_none', True)
27
+ kwargs.setdefault('mode', 'json')
28
+ return super().model_dump(*args, **kwargs)
29
+
30
+ def model_dump_json(self, *args, **kwargs):
31
+ # stays consistent with model_dump default
32
+ kwargs.setdefault('exclude_none', True)
33
+ kwargs.setdefault('indent', None)
34
+ return super().model_dump_json(*args, **kwargs)
35
+
36
+ class ErrorDetail(AssertionModel):
37
+ detail: constr(max_length=4096) = Field(
38
+ ...,
39
+ description='A granular description on the specific error related to a body property, query parameter, path parameters, and/or header.',
40
+ )
41
+ pointer: Optional[constr(max_length=1024)] = Field(
42
+ default=None,
43
+ description='A JSON Pointer to a specific request body property that is the source of error.',
44
+ )
45
+ parameter: Optional[constr(max_length=1024)] = Field(
46
+ default=None,
47
+ description='The name of the query or path parameter that is the source of error.',
48
+ )
49
+ header: Optional[constr(max_length=1024)] = Field(
50
+ default=None, description='The name of the header that is the source of error.'
51
+ )
52
+ code: Optional[constr(max_length=50)] = Field(
53
+ default=None,
54
+ description='A string containing additional provider specific codes to identify the error context.',
55
+ )
56
+
57
+
58
+ class Type(Enum):
59
+ about_blank = 'about:blank'
60
+ https___problems_registry_smartbear_com_already_exists = (
61
+ 'https://problems-registry.smartbear.com/already-exists'
62
+ )
63
+ https___problems_registry_smartbear_com_bad_request = (
64
+ 'https://problems-registry.smartbear.com/bad-request'
65
+ )
66
+ https___problems_registry_smartbear_com_business_rule_violation = (
67
+ 'https://problems-registry.smartbear.com/business-rule-violation'
68
+ )
69
+ https___problems_registry_smartbear_com_forbidden = (
70
+ 'https://problems-registry.smartbear.com/forbidden'
71
+ )
72
+ https___problems_registry_smartbear_com_invalid_body_property_format = (
73
+ 'https://problems-registry.smartbear.com/invalid-body-property-format'
74
+ )
75
+ https___problems_registry_smartbear_com_invalid_body_property_value = (
76
+ 'https://problems-registry.smartbear.com/invalid-body-property-value'
77
+ )
78
+ https___problems_registry_smartbear_com_invalid_parameters = (
79
+ 'https://problems-registry.smartbear.com/invalid-parameters'
80
+ )
81
+ https___problems_registry_smartbear_com_invalid_request_header_format = (
82
+ 'https://problems-registry.smartbear.com/invalid-request-header-format'
83
+ )
84
+ https___problems_registry_smartbear_com_invalid_request_parameter_format = (
85
+ 'https://problems-registry.smartbear.com/invalid-request-parameter-format'
86
+ )
87
+ https___problems_registry_smartbear_com_invalid_request_parameter_value = (
88
+ 'https://problems-registry.smartbear.com/invalid-request-parameter-value'
89
+ )
90
+ https___problems_registry_smartbear_com_license_cancelled = (
91
+ 'https://problems-registry.smartbear.com/license-cancelled'
92
+ )
93
+ https___problems_registry_smartbear_com_license_expired = (
94
+ 'https://problems-registry.smartbear.com/license-expired'
95
+ )
96
+ https___problems_registry_smartbear_com_missing_body_property = (
97
+ 'https://problems-registry.smartbear.com/missing-body-property'
98
+ )
99
+ https___problems_registry_smartbear_com_missing_request_header = (
100
+ 'https://problems-registry.smartbear.com/missing-request-header'
101
+ )
102
+ https___problems_registry_smartbear_com_not_found = (
103
+ 'https://problems-registry.smartbear.com/not-found'
104
+ )
105
+ https___problems_registry_smartbear_com_server_error = (
106
+ 'https://problems-registry.smartbear.com/server-error'
107
+ )
108
+ https___problems_registry_smartbear_com_service_unavailable = (
109
+ 'https://problems-registry.smartbear.com/service-unavailable'
110
+ )
111
+ https___problems_registry_smartbear_com_unauthorized = (
112
+ 'https://problems-registry.smartbear.com/unauthorized'
113
+ )
114
+ https___problems_registry_smartbear_com_validation_error = (
115
+ 'https://problems-registry.smartbear.com/validation-error'
116
+ )
117
+
118
+
119
+ class ProblemDetails(AssertionModel):
120
+ type: Optional[Type] = Field(
121
+ default=None, description='A URI reference that identifies the problem type.'
122
+ )
123
+ status: Optional[conint(ge=100, le=599)] = Field(
124
+ default=None,
125
+ description='The HTTP status code generated by the origin server for this occurrence of the problem.',
126
+ )
127
+ title: Optional[constr(max_length=1024)] = Field(
128
+ default=None,
129
+ description='A short, human-readable summary of the problem type. It should not change from occurrence to occurrence of the problem, except for purposes of localization.',
130
+ )
131
+ detail: constr(max_length=4096) = Field(
132
+ ...,
133
+ description='A human-readable explanation specific to this occurrence of the problem.',
134
+ )
135
+ instance: Optional[constr(max_length=1024)] = Field(
136
+ default=None,
137
+ description='A URI reference that identifies the specific occurrence of the problem. It may or may not yield further information if dereferenced.',
138
+ )
139
+ code: Optional[constr(max_length=50)] = Field(
140
+ default=None,
141
+ description='An API specific error code aiding the provider team understand the error based on their own potential taxonomy or registry.',
142
+ )
143
+ errors: Optional[List[ErrorDetail]] = Field(
144
+ default=None,
145
+ description='An array of error details to accompany a problem details response.',
146
+ max_length=1000,
147
+ )
148
+
149
+
150
+ class AlreadyExists(ProblemDetails):
151
+ type: Literal['https://problems-registry.smartbear.com/already-exists'] = Field(
152
+ default='https://problems-registry.smartbear.com/already-exists',
153
+ description='A URI reference that identifies the problem type.',
154
+ )
155
+ status: Literal[409] = Field(
156
+ default=409,
157
+ description='The HTTP status code generated by the origin server for this occurrence of the problem.',
158
+ )
159
+ title: Literal['Already exists'] = Field(
160
+ default='Already exists',
161
+ description='A short, human-readable summary of the problem type. It should not change from occurrence to occurrence of the problem, except for purposes of localization.',
162
+ )
163
+ detail: Literal['The resource being created already exists.'] = Field(
164
+ default='The resource being created already exists.',
165
+ description='A human-readable explanation specific to this occurrence of the problem.',
166
+ )
167
+
168
+
169
+ class BadRequest(ProblemDetails):
170
+ type: Literal['https://problems-registry.smartbear.com/bad-request'] = Field(
171
+ default='https://problems-registry.smartbear.com/bad-request',
172
+ description='A URI reference that identifies the problem type.',
173
+ )
174
+ status: Literal[400] = Field(
175
+ default=400,
176
+ description='The HTTP status code generated by the origin server for this occurrence of the problem.',
177
+ )
178
+ title: Literal['Bad Request'] = Field(
179
+ default='Bad Request',
180
+ description='A short, human-readable summary of the problem type. It should not change from occurrence to occurrence of the problem, except for purposes of localization.',
181
+ )
182
+ detail: Literal['The request is invalid or malformed.'] = Field(
183
+ default='The request is invalid or malformed.',
184
+ description='A human-readable explanation specific to this occurrence of the problem.',
185
+ )
186
+
187
+
188
+ class BusinessRuleViolation(ProblemDetails):
189
+ type: Literal[
190
+ 'https://problems-registry.smartbear.com/business-rule-violation'
191
+ ] = Field(
192
+ default='https://problems-registry.smartbear.com/business-rule-violation',
193
+ description='A URI reference that identifies the problem type.',
194
+ )
195
+ status: Literal[422] = Field(
196
+ default=422,
197
+ description='The HTTP status code generated by the origin server for this occurrence of the problem.',
198
+ )
199
+ title: Literal['Business Rule Violation'] = Field(
200
+ default='Business Rule Violation',
201
+ description='A short, human-readable summary of the problem type. It should not change from occurrence to occurrence of the problem, except for purposes of localization.',
202
+ )
203
+ detail: Literal[
204
+ 'The request body is invalid and not meeting business rules.'
205
+ ] = Field(
206
+ default='The request body is invalid and not meeting business rules.',
207
+ description='A human-readable explanation specific to this occurrence of the problem.',
208
+ )
209
+
210
+
211
+ class Forbidden(ProblemDetails):
212
+ type: Literal['https://problems-registry.smartbear.com/forbidden'] = Field(
213
+ default='https://problems-registry.smartbear.com/forbidden',
214
+ description='A URI reference that identifies the problem type.',
215
+ )
216
+ status: Literal[403] = Field(
217
+ default=403,
218
+ description='The HTTP status code generated by the origin server for this occurrence of the problem.',
219
+ )
220
+ title: Literal['Forbidden'] = Field(
221
+ default='Forbidden',
222
+ description='A short, human-readable summary of the problem type. It should not change from occurrence to occurrence of the problem, except for purposes of localization.',
223
+ )
224
+ detail: Literal[
225
+ 'The resource could not be returned as the requestor is not authorized.'
226
+ ] = Field(
227
+ default='The resource could not be returned as the requestor is not authorized.',
228
+ description='A human-readable explanation specific to this occurrence of the problem.',
229
+ )
230
+
231
+
232
+ class InvalidBodyPropertyFormat(ProblemDetails):
233
+ type: Literal[
234
+ 'https://problems-registry.smartbear.com/invalid-body-property-format'
235
+ ] = Field(
236
+ default='https://problems-registry.smartbear.com/invalid-body-property-format',
237
+ description='A URI reference that identifies the problem type.',
238
+ )
239
+ status: Literal[400] = Field(
240
+ default=400,
241
+ description='The HTTP status code generated by the origin server for this occurrence of the problem.',
242
+ )
243
+ title: Literal['Invalid Body Property Format'] = Field(
244
+ default='Invalid Body Property Format',
245
+ description='A short, human-readable summary of the problem type. It should not change from occurrence to occurrence of the problem, except for purposes of localization.',
246
+ )
247
+ detail: Literal['The request body contains a malformed property.'] = Field(
248
+ default='The request body contains a malformed property.',
249
+ description='A human-readable explanation specific to this occurrence of the problem.',
250
+ )
251
+
252
+
253
+ class InvalidBodyPropertyValue(ProblemDetails):
254
+ type: Literal[
255
+ 'https://problems-registry.smartbear.com/invalid-body-property-value'
256
+ ] = Field(
257
+ default='https://problems-registry.smartbear.com/invalid-body-property-value',
258
+ description='A URI reference that identifies the problem type.',
259
+ )
260
+ status: Literal[400] = Field(
261
+ default=400,
262
+ description='The HTTP status code generated by the origin server for this occurrence of the problem.',
263
+ )
264
+ title: Literal['Invalid Body Property Value'] = Field(
265
+ default='Invalid Body Property Value',
266
+ description='A short, human-readable summary of the problem type. It should not change from occurrence to occurrence of the problem, except for purposes of localization.',
267
+ )
268
+ detail: Literal[
269
+ 'The request body contains an invalid body property value.'
270
+ ] = Field(
271
+ default='The request body contains an invalid body property value.',
272
+ description='A human-readable explanation specific to this occurrence of the problem.',
273
+ )
274
+
275
+
276
+ class InvalidParameters(ProblemDetails):
277
+ type: Literal['https://problems-registry.smartbear.com/invalid-parameters'] = Field(
278
+ default='https://problems-registry.smartbear.com/invalid-parameters',
279
+ description='A URI reference that identifies the problem type.',
280
+ )
281
+ status: Literal[400] = Field(
282
+ default=400,
283
+ description='The HTTP status code generated by the origin server for this occurrence of the problem.',
284
+ )
285
+ title: Literal['Invalid parameters'] = Field(
286
+ default='Invalid parameters',
287
+ description='A short, human-readable summary of the problem type. It should not change from occurrence to occurrence of the problem, except for purposes of localization.',
288
+ )
289
+ detail: Literal[
290
+ 'The request contained invalid, or malformed parameters (path or header or query).'
291
+ ] = Field(
292
+ default='The request contained invalid, or malformed parameters (path or header or query).',
293
+ description='A human-readable explanation specific to this occurrence of the problem.',
294
+ )
295
+
296
+
297
+ class InvalidRequestHeaderFormat(ProblemDetails):
298
+ type: Literal[
299
+ 'https://problems-registry.smartbear.com/invalid-request-header-format'
300
+ ] = Field(
301
+ default='https://problems-registry.smartbear.com/invalid-request-header-format',
302
+ description='A URI reference that identifies the problem type.',
303
+ )
304
+ status: Literal[400] = Field(
305
+ default=400,
306
+ description='The HTTP status code generated by the origin server for this occurrence of the problem.',
307
+ )
308
+ title: Literal['Invalid Request Header Format'] = Field(
309
+ default='Invalid Request Header Format',
310
+ description='A short, human-readable summary of the problem type. It should not change from occurrence to occurrence of the problem, except for purposes of localization.',
311
+ )
312
+ detail: Literal[
313
+ 'The request contains a malformed request header parameter.'
314
+ ] = Field(
315
+ default='The request contains a malformed request header parameter.',
316
+ description='A human-readable explanation specific to this occurrence of the problem.',
317
+ )
318
+
319
+
320
+ class InvalidRequestParameterFormat(ProblemDetails):
321
+ type: Literal[
322
+ 'https://problems-registry.smartbear.com/invalid-request-parameter-format'
323
+ ] = Field(
324
+ default='https://problems-registry.smartbear.com/invalid-request-parameter-format',
325
+ description='A URI reference that identifies the problem type.',
326
+ )
327
+ status: Literal[400] = Field(
328
+ default=400,
329
+ description='The HTTP status code generated by the origin server for this occurrence of the problem.',
330
+ )
331
+ title: Literal['Invalid Request Parameter Format'] = Field(
332
+ default='Invalid Request Parameter Format',
333
+ description='A short, human-readable summary of the problem type. It should not change from occurrence to occurrence of the problem, except for purposes of localization.',
334
+ )
335
+ detail: Literal[
336
+ 'The request contains a malformed request query parameter.'
337
+ ] = Field(
338
+ default='The request contains a malformed request query parameter.',
339
+ description='A human-readable explanation specific to this occurrence of the problem.',
340
+ )
341
+
342
+
343
+ class InvalidRequestParameterValue(ProblemDetails):
344
+ type: Literal[
345
+ 'https://problems-registry.smartbear.com/invalid-request-parameter-value'
346
+ ] = Field(
347
+ default='https://problems-registry.smartbear.com/invalid-request-parameter-value',
348
+ description='A URI reference that identifies the problem type.',
349
+ )
350
+ status: Literal[400] = Field(
351
+ default=400,
352
+ description='The HTTP status code generated by the origin server for this occurrence of the problem.',
353
+ )
354
+ title: Literal['Invalid Request Parameter Value'] = Field(
355
+ default='Invalid Request Parameter Value',
356
+ description='A short, human-readable summary of the problem type. It should not change from occurrence to occurrence of the problem, except for purposes of localization.',
357
+ )
358
+ detail: Literal[
359
+ 'The request body contains an invalid request parameter value.'
360
+ ] = Field(
361
+ default='The request body contains an invalid request parameter value.',
362
+ description='A human-readable explanation specific to this occurrence of the problem.',
363
+ )
364
+
365
+
366
+ class LicenseCancelled(ProblemDetails):
367
+ type: Literal['https://problems-registry.smartbear.com/license-cancelled'] = Field(
368
+ default='https://problems-registry.smartbear.com/license-cancelled',
369
+ description='A URI reference that identifies the problem type.',
370
+ )
371
+ status: Literal[503] = Field(
372
+ default=503,
373
+ description='The HTTP status code generated by the origin server for this occurrence of the problem.',
374
+ )
375
+ title: Literal['License Cancelled'] = Field(
376
+ default='License Cancelled',
377
+ description='A short, human-readable summary of the problem type. It should not change from occurrence to occurrence of the problem, except for purposes of localization.',
378
+ )
379
+ detail: Literal[
380
+ 'The service is unavailable as the license associated with your client or organization has been cancelled. Please contact your account manager or representative.'
381
+ ] = Field(
382
+ default='The service is unavailable as the license associated with your client or organization has been cancelled. Please contact your account manager or representative.',
383
+ description='A human-readable explanation specific to this occurrence of the problem.',
384
+ )
385
+
386
+
387
+ class LicenseExpired(ProblemDetails):
388
+ type: Literal['https://problems-registry.smartbear.com/license-expired'] = Field(
389
+ default='https://problems-registry.smartbear.com/license-expired',
390
+ description='A URI reference that identifies the problem type.',
391
+ )
392
+ status: Literal[503] = Field(
393
+ default=503,
394
+ description='The HTTP status code generated by the origin server for this occurrence of the problem.',
395
+ )
396
+ title: Literal['License Expired'] = Field(
397
+ default='License Expired',
398
+ description='A short, human-readable summary of the problem type. It should not change from occurrence to occurrence of the problem, except for purposes of localization.',
399
+ )
400
+ detail: Literal[
401
+ 'The service is unavailable as the license associated with your client or organization has expired. Please contact your account manager or representative.'
402
+ ] = Field(
403
+ default='The service is unavailable as the license associated with your client or organization has expired. Please contact your account manager or representative.',
404
+ description='A human-readable explanation specific to this occurrence of the problem.',
405
+ )
406
+
407
+
408
+ class MissingBodyProperty(ProblemDetails):
409
+ type: Literal[
410
+ 'https://problems-registry.smartbear.com/missing-body-property'
411
+ ] = Field(
412
+ default='https://problems-registry.smartbear.com/missing-body-property',
413
+ description='A URI reference that identifies the problem type.',
414
+ )
415
+ status: Literal[400] = Field(
416
+ default=400,
417
+ description='The HTTP status code generated by the origin server for this occurrence of the problem.',
418
+ )
419
+ title: Literal['Missing body property'] = Field(
420
+ default='Missing body property',
421
+ description='A short, human-readable summary of the problem type. It should not change from occurrence to occurrence of the problem, except for purposes of localization.',
422
+ )
423
+ detail: Literal['The request is missing an expected body property.'] = Field(
424
+ default='The request is missing an expected body property.',
425
+ description='A human-readable explanation specific to this occurrence of the problem.',
426
+ )
427
+
428
+
429
+ class MissingRequestHeader(ProblemDetails):
430
+ type: Literal[
431
+ 'https://problems-registry.smartbear.com/missing-request-header'
432
+ ] = Field(
433
+ default='https://problems-registry.smartbear.com/missing-request-header',
434
+ description='A URI reference that identifies the problem type.',
435
+ )
436
+ status: Literal[400] = Field(
437
+ default=400,
438
+ description='The HTTP status code generated by the origin server for this occurrence of the problem.',
439
+ )
440
+ title: Literal['Missing request header'] = Field(
441
+ default='Missing request header',
442
+ description='A short, human-readable summary of the problem type. It should not change from occurrence to occurrence of the problem, except for purposes of localization.',
443
+ )
444
+ detail: Literal['The request is missing an expected HTTP request header.'] = Field(
445
+ default='The request is missing an expected HTTP request header.',
446
+ description='A human-readable explanation specific to this occurrence of the problem.',
447
+ )
448
+
449
+
450
+ class MissingRequestParameter(ProblemDetails):
451
+ type: Literal[
452
+ 'https://problems-registry.smartbear.com/missing-request-parameter'
453
+ ] = Field(
454
+ default='https://problems-registry.smartbear.com/missing-request-parameter',
455
+ description='A URI reference that identifies the problem type.',
456
+ )
457
+ status: Literal[400] = Field(
458
+ default=400,
459
+ description='The HTTP status code generated by the origin server for this occurrence of the problem.',
460
+ )
461
+ title: Literal['Missing request parameter'] = Field(
462
+ default='Missing request parameter',
463
+ description='A short, human-readable summary of the problem type. It should not change from occurrence to occurrence of the problem, except for purposes of localization.',
464
+ )
465
+ detail: Literal[
466
+ 'The request is missing an expected query or path parameter.'
467
+ ] = Field(
468
+ default='The request is missing an expected query or path parameter.',
469
+ description='A human-readable explanation specific to this occurrence of the problem.',
470
+ )
471
+
472
+
473
+ class NotFound(ProblemDetails):
474
+ type: Literal['https://problems-registry.smartbear.com/not-found'] = Field(
475
+ default='https://problems-registry.smartbear.com/not-found',
476
+ description='A URI reference that identifies the problem type.',
477
+ )
478
+ status: Literal[404] = Field(
479
+ default=404,
480
+ description='The HTTP status code generated by the origin server for this occurrence of the problem.',
481
+ )
482
+ title: Literal['Not Found'] = Field(
483
+ default='Not Found',
484
+ description='A short, human-readable summary of the problem type. It should not change from occurrence to occurrence of the problem, except for purposes of localization.',
485
+ )
486
+ detail: Literal['The requested resource was not found.'] = Field(
487
+ default='The requested resource was not found.',
488
+ description='A human-readable explanation specific to this occurrence of the problem.',
489
+ )
490
+
491
+
492
+ class ServerError(ProblemDetails):
493
+ type: Literal['https://problems-registry.smartbear.com/server-error'] = Field(
494
+ default='https://problems-registry.smartbear.com/server-error',
495
+ description='A URI reference that identifies the problem type.',
496
+ )
497
+ status: Literal[500] = Field(
498
+ default=500,
499
+ description='The HTTP status code generated by the origin server for this occurrence of the problem.',
500
+ )
501
+ title: Literal['Server Error'] = Field(
502
+ default='Server Error',
503
+ description='A short, human-readable summary of the problem type. It should not change from occurrence to occurrence of the problem, except for purposes of localization.',
504
+ )
505
+ detail: Literal['The server encountered an unexpected error.'] = Field(
506
+ default='The server encountered an unexpected error.',
507
+ description='A human-readable explanation specific to this occurrence of the problem.',
508
+ )
509
+
510
+
511
+ class ServiceUnavailable(ProblemDetails):
512
+ type: Literal[
513
+ 'https://problems-registry.smartbear.com/service-unavailable'
514
+ ] = Field(
515
+ default='https://problems-registry.smartbear.com/service-unavailable',
516
+ description='A URI reference that identifies the problem type.',
517
+ )
518
+ status: Literal[503] = Field(
519
+ default=503,
520
+ description='The HTTP status code generated by the origin server for this occurrence of the problem.',
521
+ )
522
+ title: Literal['Service Unavailable'] = Field(
523
+ default='Service Unavailable',
524
+ description='A short, human-readable summary of the problem type. It should not change from occurrence to occurrence of the problem, except for purposes of localization.',
525
+ )
526
+ detail: Literal['The service is currently unavailable.'] = Field(
527
+ 'The service is currently unavailable.',
528
+ description='A human-readable explanation specific to this occurrence of the problem.',
529
+ )
530
+
531
+
532
+ class Unauthorized(ProblemDetails):
533
+ type: Literal['https://problems-registry.smartbear.com/unauthorized'] = Field(
534
+ default='https://problems-registry.smartbear.com/unauthorized',
535
+ description='A URI reference that identifies the problem type.',
536
+ )
537
+ status: Literal[401] = Field(
538
+ default=401,
539
+ description='The HTTP status code generated by the origin server for this occurrence of the problem.',
540
+ )
541
+ title: Literal['Unauthorized'] = Field(
542
+ default='Unauthorized',
543
+ description='A short, human-readable summary of the problem type. It should not change from occurrence to occurrence of the problem, except for purposes of localization.',
544
+ )
545
+ detail: Literal[
546
+ 'Access token not set or invalid, and the requested resource could not be returned.'
547
+ ] = Field(
548
+ default='Access token not set or invalid, and the requested resource could not be returned.',
549
+ description='A human-readable explanation specific to this occurrence of the problem.',
550
+ )
551
+
552
+
553
+ class ValidationError(ProblemDetails):
554
+ type: Literal['https://problems-registry.smartbear.com/validation-error'] = Field(
555
+ default='https://problems-registry.smartbear.com/validation-error',
556
+ description='A URI reference that identifies the problem type.',
557
+ )
558
+ status: Literal[422] = Field(
559
+ default=422,
560
+ description='The HTTP status code generated by the origin server for this occurrence of the problem.',
561
+ )
562
+ title: Literal['Validation Error'] = Field(
563
+ default='Validation Error',
564
+ description='A short, human-readable summary of the problem type. It should not change from occurrence to occurrence of the problem, except for purposes of localization.',
565
+ )
566
+ detail: Literal['The request is not valid.'] = Field(
567
+ default='The request is not valid.',
568
+ description='A human-readable explanation specific to this occurrence of the problem.',
569
+ )
@@ -0,0 +1,55 @@
1
+ # Copyright 2025 Terradue
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ from . import BaseValidator
16
+ from .error_models import (
17
+ InvalidBodyPropertyFormat,
18
+ ErrorDetail,
19
+ ProblemDetails
20
+ )
21
+ from jsonschema import Draft202012Validator
22
+ from typing import (
23
+ Any,
24
+ Mapping
25
+ )
26
+
27
+ class JSONSchemaValidator(BaseValidator):
28
+
29
+ def __init__(
30
+ self,
31
+ schema: Mapping[str, Any]
32
+ ):
33
+ self.validator = Draft202012Validator(schema)
34
+
35
+ def validate_inputs(
36
+ self,
37
+ data: Mapping[str, Any]
38
+ ) -> ProblemDetails | None:
39
+ errors_list = []
40
+
41
+ for error in self.validator.iter_errors(data):
42
+ print(error.__dict__)
43
+
44
+ errors_list.append(
45
+ ErrorDetail(
46
+ detail=error.message,
47
+ pointer=f"#/{'/'.join(error.path)}" if error.path and isinstance(error.path, str) else None,
48
+ code='.'.join(error.schema_path)
49
+ )
50
+ )
51
+
52
+ if errors_list:
53
+ return InvalidBodyPropertyFormat(errors=errors_list)
54
+
55
+ return None