schemathesis 3.13.0__py3-none-any.whl → 4.4.2__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.
Files changed (245) hide show
  1. schemathesis/__init__.py +53 -25
  2. schemathesis/auths.py +507 -0
  3. schemathesis/checks.py +190 -25
  4. schemathesis/cli/__init__.py +27 -1016
  5. schemathesis/cli/__main__.py +4 -0
  6. schemathesis/cli/commands/__init__.py +133 -0
  7. schemathesis/cli/commands/data.py +10 -0
  8. schemathesis/cli/commands/run/__init__.py +602 -0
  9. schemathesis/cli/commands/run/context.py +228 -0
  10. schemathesis/cli/commands/run/events.py +60 -0
  11. schemathesis/cli/commands/run/executor.py +157 -0
  12. schemathesis/cli/commands/run/filters.py +53 -0
  13. schemathesis/cli/commands/run/handlers/__init__.py +46 -0
  14. schemathesis/cli/commands/run/handlers/base.py +45 -0
  15. schemathesis/cli/commands/run/handlers/cassettes.py +464 -0
  16. schemathesis/cli/commands/run/handlers/junitxml.py +60 -0
  17. schemathesis/cli/commands/run/handlers/output.py +1750 -0
  18. schemathesis/cli/commands/run/loaders.py +118 -0
  19. schemathesis/cli/commands/run/validation.py +256 -0
  20. schemathesis/cli/constants.py +5 -0
  21. schemathesis/cli/core.py +19 -0
  22. schemathesis/cli/ext/fs.py +16 -0
  23. schemathesis/cli/ext/groups.py +203 -0
  24. schemathesis/cli/ext/options.py +81 -0
  25. schemathesis/config/__init__.py +202 -0
  26. schemathesis/config/_auth.py +51 -0
  27. schemathesis/config/_checks.py +268 -0
  28. schemathesis/config/_diff_base.py +101 -0
  29. schemathesis/config/_env.py +21 -0
  30. schemathesis/config/_error.py +163 -0
  31. schemathesis/config/_generation.py +157 -0
  32. schemathesis/config/_health_check.py +24 -0
  33. schemathesis/config/_operations.py +335 -0
  34. schemathesis/config/_output.py +171 -0
  35. schemathesis/config/_parameters.py +19 -0
  36. schemathesis/config/_phases.py +253 -0
  37. schemathesis/config/_projects.py +543 -0
  38. schemathesis/config/_rate_limit.py +17 -0
  39. schemathesis/config/_report.py +120 -0
  40. schemathesis/config/_validator.py +9 -0
  41. schemathesis/config/_warnings.py +89 -0
  42. schemathesis/config/schema.json +975 -0
  43. schemathesis/core/__init__.py +72 -0
  44. schemathesis/core/adapter.py +34 -0
  45. schemathesis/core/compat.py +32 -0
  46. schemathesis/core/control.py +2 -0
  47. schemathesis/core/curl.py +100 -0
  48. schemathesis/core/deserialization.py +210 -0
  49. schemathesis/core/errors.py +588 -0
  50. schemathesis/core/failures.py +316 -0
  51. schemathesis/core/fs.py +19 -0
  52. schemathesis/core/hooks.py +20 -0
  53. schemathesis/core/jsonschema/__init__.py +13 -0
  54. schemathesis/core/jsonschema/bundler.py +183 -0
  55. schemathesis/core/jsonschema/keywords.py +40 -0
  56. schemathesis/core/jsonschema/references.py +222 -0
  57. schemathesis/core/jsonschema/types.py +41 -0
  58. schemathesis/core/lazy_import.py +15 -0
  59. schemathesis/core/loaders.py +107 -0
  60. schemathesis/core/marks.py +66 -0
  61. schemathesis/core/media_types.py +79 -0
  62. schemathesis/core/output/__init__.py +46 -0
  63. schemathesis/core/output/sanitization.py +54 -0
  64. schemathesis/core/parameters.py +45 -0
  65. schemathesis/core/rate_limit.py +60 -0
  66. schemathesis/core/registries.py +34 -0
  67. schemathesis/core/result.py +27 -0
  68. schemathesis/core/schema_analysis.py +17 -0
  69. schemathesis/core/shell.py +203 -0
  70. schemathesis/core/transforms.py +144 -0
  71. schemathesis/core/transport.py +223 -0
  72. schemathesis/core/validation.py +73 -0
  73. schemathesis/core/version.py +7 -0
  74. schemathesis/engine/__init__.py +28 -0
  75. schemathesis/engine/context.py +152 -0
  76. schemathesis/engine/control.py +44 -0
  77. schemathesis/engine/core.py +201 -0
  78. schemathesis/engine/errors.py +446 -0
  79. schemathesis/engine/events.py +284 -0
  80. schemathesis/engine/observations.py +42 -0
  81. schemathesis/engine/phases/__init__.py +108 -0
  82. schemathesis/engine/phases/analysis.py +28 -0
  83. schemathesis/engine/phases/probes.py +172 -0
  84. schemathesis/engine/phases/stateful/__init__.py +68 -0
  85. schemathesis/engine/phases/stateful/_executor.py +364 -0
  86. schemathesis/engine/phases/stateful/context.py +85 -0
  87. schemathesis/engine/phases/unit/__init__.py +220 -0
  88. schemathesis/engine/phases/unit/_executor.py +459 -0
  89. schemathesis/engine/phases/unit/_pool.py +82 -0
  90. schemathesis/engine/recorder.py +254 -0
  91. schemathesis/errors.py +47 -0
  92. schemathesis/filters.py +395 -0
  93. schemathesis/generation/__init__.py +25 -0
  94. schemathesis/generation/case.py +478 -0
  95. schemathesis/generation/coverage.py +1528 -0
  96. schemathesis/generation/hypothesis/__init__.py +121 -0
  97. schemathesis/generation/hypothesis/builder.py +992 -0
  98. schemathesis/generation/hypothesis/examples.py +56 -0
  99. schemathesis/generation/hypothesis/given.py +66 -0
  100. schemathesis/generation/hypothesis/reporting.py +285 -0
  101. schemathesis/generation/meta.py +227 -0
  102. schemathesis/generation/metrics.py +93 -0
  103. schemathesis/generation/modes.py +20 -0
  104. schemathesis/generation/overrides.py +127 -0
  105. schemathesis/generation/stateful/__init__.py +37 -0
  106. schemathesis/generation/stateful/state_machine.py +294 -0
  107. schemathesis/graphql/__init__.py +15 -0
  108. schemathesis/graphql/checks.py +109 -0
  109. schemathesis/graphql/loaders.py +285 -0
  110. schemathesis/hooks.py +270 -91
  111. schemathesis/openapi/__init__.py +13 -0
  112. schemathesis/openapi/checks.py +467 -0
  113. schemathesis/openapi/generation/__init__.py +0 -0
  114. schemathesis/openapi/generation/filters.py +72 -0
  115. schemathesis/openapi/loaders.py +315 -0
  116. schemathesis/pytest/__init__.py +5 -0
  117. schemathesis/pytest/control_flow.py +7 -0
  118. schemathesis/pytest/lazy.py +341 -0
  119. schemathesis/pytest/loaders.py +36 -0
  120. schemathesis/pytest/plugin.py +357 -0
  121. schemathesis/python/__init__.py +0 -0
  122. schemathesis/python/asgi.py +12 -0
  123. schemathesis/python/wsgi.py +12 -0
  124. schemathesis/schemas.py +683 -247
  125. schemathesis/specs/graphql/__init__.py +0 -1
  126. schemathesis/specs/graphql/nodes.py +27 -0
  127. schemathesis/specs/graphql/scalars.py +86 -0
  128. schemathesis/specs/graphql/schemas.py +395 -123
  129. schemathesis/specs/graphql/validation.py +33 -0
  130. schemathesis/specs/openapi/__init__.py +9 -1
  131. schemathesis/specs/openapi/_hypothesis.py +578 -317
  132. schemathesis/specs/openapi/adapter/__init__.py +10 -0
  133. schemathesis/specs/openapi/adapter/parameters.py +729 -0
  134. schemathesis/specs/openapi/adapter/protocol.py +59 -0
  135. schemathesis/specs/openapi/adapter/references.py +19 -0
  136. schemathesis/specs/openapi/adapter/responses.py +368 -0
  137. schemathesis/specs/openapi/adapter/security.py +144 -0
  138. schemathesis/specs/openapi/adapter/v2.py +30 -0
  139. schemathesis/specs/openapi/adapter/v3_0.py +30 -0
  140. schemathesis/specs/openapi/adapter/v3_1.py +30 -0
  141. schemathesis/specs/openapi/analysis.py +96 -0
  142. schemathesis/specs/openapi/checks.py +753 -74
  143. schemathesis/specs/openapi/converter.py +176 -37
  144. schemathesis/specs/openapi/definitions.py +599 -4
  145. schemathesis/specs/openapi/examples.py +581 -165
  146. schemathesis/specs/openapi/expressions/__init__.py +52 -5
  147. schemathesis/specs/openapi/expressions/extractors.py +25 -0
  148. schemathesis/specs/openapi/expressions/lexer.py +34 -31
  149. schemathesis/specs/openapi/expressions/nodes.py +97 -46
  150. schemathesis/specs/openapi/expressions/parser.py +35 -13
  151. schemathesis/specs/openapi/formats.py +122 -0
  152. schemathesis/specs/openapi/media_types.py +75 -0
  153. schemathesis/specs/openapi/negative/__init__.py +117 -68
  154. schemathesis/specs/openapi/negative/mutations.py +294 -104
  155. schemathesis/specs/openapi/negative/utils.py +3 -6
  156. schemathesis/specs/openapi/patterns.py +458 -0
  157. schemathesis/specs/openapi/references.py +60 -81
  158. schemathesis/specs/openapi/schemas.py +648 -650
  159. schemathesis/specs/openapi/serialization.py +53 -30
  160. schemathesis/specs/openapi/stateful/__init__.py +404 -69
  161. schemathesis/specs/openapi/stateful/control.py +87 -0
  162. schemathesis/specs/openapi/stateful/dependencies/__init__.py +232 -0
  163. schemathesis/specs/openapi/stateful/dependencies/inputs.py +428 -0
  164. schemathesis/specs/openapi/stateful/dependencies/models.py +341 -0
  165. schemathesis/specs/openapi/stateful/dependencies/naming.py +491 -0
  166. schemathesis/specs/openapi/stateful/dependencies/outputs.py +34 -0
  167. schemathesis/specs/openapi/stateful/dependencies/resources.py +339 -0
  168. schemathesis/specs/openapi/stateful/dependencies/schemas.py +447 -0
  169. schemathesis/specs/openapi/stateful/inference.py +254 -0
  170. schemathesis/specs/openapi/stateful/links.py +219 -78
  171. schemathesis/specs/openapi/types/__init__.py +3 -0
  172. schemathesis/specs/openapi/types/common.py +23 -0
  173. schemathesis/specs/openapi/types/v2.py +129 -0
  174. schemathesis/specs/openapi/types/v3.py +134 -0
  175. schemathesis/specs/openapi/utils.py +7 -6
  176. schemathesis/specs/openapi/warnings.py +75 -0
  177. schemathesis/transport/__init__.py +224 -0
  178. schemathesis/transport/asgi.py +26 -0
  179. schemathesis/transport/prepare.py +126 -0
  180. schemathesis/transport/requests.py +278 -0
  181. schemathesis/transport/serialization.py +329 -0
  182. schemathesis/transport/wsgi.py +175 -0
  183. schemathesis-4.4.2.dist-info/METADATA +213 -0
  184. schemathesis-4.4.2.dist-info/RECORD +192 -0
  185. {schemathesis-3.13.0.dist-info → schemathesis-4.4.2.dist-info}/WHEEL +1 -1
  186. schemathesis-4.4.2.dist-info/entry_points.txt +6 -0
  187. {schemathesis-3.13.0.dist-info → schemathesis-4.4.2.dist-info/licenses}/LICENSE +1 -1
  188. schemathesis/_compat.py +0 -41
  189. schemathesis/_hypothesis.py +0 -115
  190. schemathesis/cli/callbacks.py +0 -188
  191. schemathesis/cli/cassettes.py +0 -253
  192. schemathesis/cli/context.py +0 -36
  193. schemathesis/cli/debug.py +0 -21
  194. schemathesis/cli/handlers.py +0 -11
  195. schemathesis/cli/junitxml.py +0 -41
  196. schemathesis/cli/options.py +0 -51
  197. schemathesis/cli/output/__init__.py +0 -1
  198. schemathesis/cli/output/default.py +0 -508
  199. schemathesis/cli/output/short.py +0 -40
  200. schemathesis/constants.py +0 -79
  201. schemathesis/exceptions.py +0 -207
  202. schemathesis/extra/_aiohttp.py +0 -27
  203. schemathesis/extra/_flask.py +0 -10
  204. schemathesis/extra/_server.py +0 -16
  205. schemathesis/extra/pytest_plugin.py +0 -216
  206. schemathesis/failures.py +0 -131
  207. schemathesis/fixups/__init__.py +0 -29
  208. schemathesis/fixups/fast_api.py +0 -30
  209. schemathesis/lazy.py +0 -227
  210. schemathesis/models.py +0 -1041
  211. schemathesis/parameters.py +0 -88
  212. schemathesis/runner/__init__.py +0 -460
  213. schemathesis/runner/events.py +0 -240
  214. schemathesis/runner/impl/__init__.py +0 -3
  215. schemathesis/runner/impl/core.py +0 -755
  216. schemathesis/runner/impl/solo.py +0 -85
  217. schemathesis/runner/impl/threadpool.py +0 -367
  218. schemathesis/runner/serialization.py +0 -189
  219. schemathesis/serializers.py +0 -233
  220. schemathesis/service/__init__.py +0 -3
  221. schemathesis/service/client.py +0 -46
  222. schemathesis/service/constants.py +0 -12
  223. schemathesis/service/events.py +0 -39
  224. schemathesis/service/handler.py +0 -39
  225. schemathesis/service/models.py +0 -7
  226. schemathesis/service/serialization.py +0 -153
  227. schemathesis/service/worker.py +0 -40
  228. schemathesis/specs/graphql/loaders.py +0 -215
  229. schemathesis/specs/openapi/constants.py +0 -7
  230. schemathesis/specs/openapi/expressions/context.py +0 -12
  231. schemathesis/specs/openapi/expressions/pointers.py +0 -29
  232. schemathesis/specs/openapi/filters.py +0 -44
  233. schemathesis/specs/openapi/links.py +0 -302
  234. schemathesis/specs/openapi/loaders.py +0 -453
  235. schemathesis/specs/openapi/parameters.py +0 -413
  236. schemathesis/specs/openapi/security.py +0 -129
  237. schemathesis/specs/openapi/validation.py +0 -24
  238. schemathesis/stateful.py +0 -349
  239. schemathesis/targets.py +0 -32
  240. schemathesis/types.py +0 -38
  241. schemathesis/utils.py +0 -436
  242. schemathesis-3.13.0.dist-info/METADATA +0 -202
  243. schemathesis-3.13.0.dist-info/RECORD +0 -91
  244. schemathesis-3.13.0.dist-info/entry_points.txt +0 -6
  245. /schemathesis/{extra → cli/ext}/__init__.py +0 -0
@@ -1,6 +1,13 @@
1
- # pylint: disable=too-many-lines
2
1
  # These schemas are copied from https://github.com/OAI/OpenAPI-Specification/tree/master/schemas
3
- import jsonschema
2
+ from __future__ import annotations
3
+
4
+ from typing import TYPE_CHECKING, Any
5
+
6
+ from schemathesis.core.lazy_import import lazy_import
7
+
8
+ if TYPE_CHECKING:
9
+ from jsonschema import Validator
10
+
4
11
 
5
12
  SWAGGER_20 = {
6
13
  "title": "A JSON Schema for Swagger 2.0 API.",
@@ -665,7 +672,6 @@ SWAGGER_20 = {
665
672
  },
666
673
  },
667
674
  }
668
- SWAGGER_20_VALIDATOR = jsonschema.validators.validator_for(SWAGGER_20)(SWAGGER_20)
669
675
  OPENAPI_30 = {
670
676
  "id": "https://spec.openapis.org/oas/3.0/schema/2019-04-02",
671
677
  "$schema": "http://json-schema.org/draft-04/schema#",
@@ -1324,4 +1330,593 @@ OPENAPI_30 = {
1324
1330
  },
1325
1331
  },
1326
1332
  }
1327
- OPENAPI_30_VALIDATOR = jsonschema.validators.validator_for(OPENAPI_30)(OPENAPI_30)
1333
+ # Generated from the updated schema.yaml from 0035208, which includes unpublished bugfixes
1334
+ # https://github.com/OAI/OpenAPI-Specification/blob/0035208611701b4f7f2c959eb99a8725cca41e6e/schemas/v3.1/schema.yaml
1335
+ OPENAPI_31 = {
1336
+ "$id": "https://spec.openapis.org/oas/3.1/schema/2022-10-07",
1337
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1338
+ "description": "The description of OpenAPI v3.1.x documents without schema validation, as defined by https://spec.openapis.org/oas/v3.1.0",
1339
+ "type": "object",
1340
+ "properties": {
1341
+ "openapi": {"type": "string", "pattern": "^3\\.1\\.\\d+(-.+)?$"},
1342
+ "info": {"$ref": "#/$defs/info"},
1343
+ "jsonSchemaDialect": {
1344
+ "type": "string",
1345
+ "format": "uri",
1346
+ "default": "https://spec.openapis.org/oas/3.1/dialect/base",
1347
+ },
1348
+ "servers": {"type": "array", "items": {"$ref": "#/$defs/server"}, "default": [{"url": "/"}]},
1349
+ "paths": {"$ref": "#/$defs/paths"},
1350
+ "webhooks": {"type": "object", "additionalProperties": {"$ref": "#/$defs/path-item"}},
1351
+ "components": {"$ref": "#/$defs/components"},
1352
+ "security": {"type": "array", "items": {"$ref": "#/$defs/security-requirement"}},
1353
+ "tags": {"type": "array", "items": {"$ref": "#/$defs/tag"}},
1354
+ "externalDocs": {"$ref": "#/$defs/external-documentation"},
1355
+ },
1356
+ "required": ["openapi", "info"],
1357
+ "anyOf": [{"required": ["paths"]}, {"required": ["components"]}, {"required": ["webhooks"]}],
1358
+ "$ref": "#/$defs/specification-extensions",
1359
+ "unevaluatedProperties": False,
1360
+ "$defs": {
1361
+ "info": {
1362
+ "$comment": "https://spec.openapis.org/oas/v3.1.0#info-object",
1363
+ "type": "object",
1364
+ "properties": {
1365
+ "title": {"type": "string"},
1366
+ "summary": {"type": "string"},
1367
+ "description": {"type": "string"},
1368
+ "termsOfService": {"type": "string", "format": "uri"},
1369
+ "contact": {"$ref": "#/$defs/contact"},
1370
+ "license": {"$ref": "#/$defs/license"},
1371
+ "version": {"type": "string"},
1372
+ },
1373
+ "required": ["title", "version"],
1374
+ "$ref": "#/$defs/specification-extensions",
1375
+ "unevaluatedProperties": False,
1376
+ },
1377
+ "contact": {
1378
+ "$comment": "https://spec.openapis.org/oas/v3.1.0#contact-object",
1379
+ "type": "object",
1380
+ "properties": {
1381
+ "name": {"type": "string"},
1382
+ "url": {"type": "string", "format": "uri"},
1383
+ "email": {"type": "string", "format": "email"},
1384
+ },
1385
+ "$ref": "#/$defs/specification-extensions",
1386
+ "unevaluatedProperties": False,
1387
+ },
1388
+ "license": {
1389
+ "$comment": "https://spec.openapis.org/oas/v3.1.0#license-object",
1390
+ "type": "object",
1391
+ "properties": {
1392
+ "name": {"type": "string"},
1393
+ "identifier": {"type": "string"},
1394
+ "url": {"type": "string", "format": "uri"},
1395
+ },
1396
+ "required": ["name"],
1397
+ "dependentSchemas": {"identifier": {"not": {"required": ["url"]}}},
1398
+ "$ref": "#/$defs/specification-extensions",
1399
+ "unevaluatedProperties": False,
1400
+ },
1401
+ "server": {
1402
+ "$comment": "https://spec.openapis.org/oas/v3.1.0#server-object",
1403
+ "type": "object",
1404
+ "properties": {
1405
+ "url": {"type": "string"},
1406
+ "description": {"type": "string"},
1407
+ "variables": {"type": "object", "additionalProperties": {"$ref": "#/$defs/server-variable"}},
1408
+ },
1409
+ "required": ["url"],
1410
+ "$ref": "#/$defs/specification-extensions",
1411
+ "unevaluatedProperties": False,
1412
+ },
1413
+ "server-variable": {
1414
+ "$comment": "https://spec.openapis.org/oas/v3.1.0#server-variable-object",
1415
+ "type": "object",
1416
+ "properties": {
1417
+ "enum": {"type": "array", "items": {"type": "string"}, "minItems": 1},
1418
+ "default": {"type": "string"},
1419
+ "description": {"type": "string"},
1420
+ },
1421
+ "required": ["default"],
1422
+ "$ref": "#/$defs/specification-extensions",
1423
+ "unevaluatedProperties": False,
1424
+ },
1425
+ "components": {
1426
+ "$comment": "https://spec.openapis.org/oas/v3.1.0#components-object",
1427
+ "type": "object",
1428
+ "properties": {
1429
+ "schemas": {"type": "object", "additionalProperties": {"$dynamicRef": "#meta"}},
1430
+ "responses": {"type": "object", "additionalProperties": {"$ref": "#/$defs/response-or-reference"}},
1431
+ "parameters": {"type": "object", "additionalProperties": {"$ref": "#/$defs/parameter-or-reference"}},
1432
+ "examples": {"type": "object", "additionalProperties": {"$ref": "#/$defs/example-or-reference"}},
1433
+ "requestBodies": {
1434
+ "type": "object",
1435
+ "additionalProperties": {"$ref": "#/$defs/request-body-or-reference"},
1436
+ },
1437
+ "headers": {"type": "object", "additionalProperties": {"$ref": "#/$defs/header-or-reference"}},
1438
+ "securitySchemes": {
1439
+ "type": "object",
1440
+ "additionalProperties": {"$ref": "#/$defs/security-scheme-or-reference"},
1441
+ },
1442
+ "links": {"type": "object", "additionalProperties": {"$ref": "#/$defs/link-or-reference"}},
1443
+ "callbacks": {"type": "object", "additionalProperties": {"$ref": "#/$defs/callbacks-or-reference"}},
1444
+ "pathItems": {"type": "object", "additionalProperties": {"$ref": "#/$defs/path-item"}},
1445
+ },
1446
+ "patternProperties": {
1447
+ "^(schemas|responses|parameters|examples|requestBodies|headers|securitySchemes|links|callbacks|pathItems)$": {
1448
+ "$comment": "Enumerating all of the property names in the regex above is necessary for unevaluatedProperties to work as expected",
1449
+ "propertyNames": {"pattern": "^[a-zA-Z0-9._-]+$"},
1450
+ }
1451
+ },
1452
+ "$ref": "#/$defs/specification-extensions",
1453
+ "unevaluatedProperties": False,
1454
+ },
1455
+ "paths": {
1456
+ "$comment": "https://spec.openapis.org/oas/v3.1.0#paths-object",
1457
+ "type": "object",
1458
+ "patternProperties": {"^/": {"$ref": "#/$defs/path-item"}},
1459
+ "$ref": "#/$defs/specification-extensions",
1460
+ "unevaluatedProperties": False,
1461
+ },
1462
+ "path-item": {
1463
+ "$comment": "https://spec.openapis.org/oas/v3.1.0#path-item-object",
1464
+ "type": "object",
1465
+ "properties": {
1466
+ "$ref": {"type": "string", "format": "uri-reference"},
1467
+ "summary": {"type": "string"},
1468
+ "description": {"type": "string"},
1469
+ "servers": {"type": "array", "items": {"$ref": "#/$defs/server"}},
1470
+ "parameters": {"type": "array", "items": {"$ref": "#/$defs/parameter-or-reference"}},
1471
+ "get": {"$ref": "#/$defs/operation"},
1472
+ "put": {"$ref": "#/$defs/operation"},
1473
+ "post": {"$ref": "#/$defs/operation"},
1474
+ "delete": {"$ref": "#/$defs/operation"},
1475
+ "options": {"$ref": "#/$defs/operation"},
1476
+ "head": {"$ref": "#/$defs/operation"},
1477
+ "patch": {"$ref": "#/$defs/operation"},
1478
+ "trace": {"$ref": "#/$defs/operation"},
1479
+ },
1480
+ "$ref": "#/$defs/specification-extensions",
1481
+ "unevaluatedProperties": False,
1482
+ },
1483
+ "operation": {
1484
+ "$comment": "https://spec.openapis.org/oas/v3.1.0#operation-object",
1485
+ "type": "object",
1486
+ "properties": {
1487
+ "tags": {"type": "array", "items": {"type": "string"}},
1488
+ "summary": {"type": "string"},
1489
+ "description": {"type": "string"},
1490
+ "externalDocs": {"$ref": "#/$defs/external-documentation"},
1491
+ "operationId": {"type": "string"},
1492
+ "parameters": {"type": "array", "items": {"$ref": "#/$defs/parameter-or-reference"}},
1493
+ "requestBody": {"$ref": "#/$defs/request-body-or-reference"},
1494
+ "responses": {"$ref": "#/$defs/responses"},
1495
+ "callbacks": {"type": "object", "additionalProperties": {"$ref": "#/$defs/callbacks-or-reference"}},
1496
+ "deprecated": {"default": False, "type": "boolean"},
1497
+ "security": {"type": "array", "items": {"$ref": "#/$defs/security-requirement"}},
1498
+ "servers": {"type": "array", "items": {"$ref": "#/$defs/server"}},
1499
+ },
1500
+ "$ref": "#/$defs/specification-extensions",
1501
+ "unevaluatedProperties": False,
1502
+ },
1503
+ "external-documentation": {
1504
+ "$comment": "https://spec.openapis.org/oas/v3.1.0#external-documentation-object",
1505
+ "type": "object",
1506
+ "properties": {"description": {"type": "string"}, "url": {"type": "string", "format": "uri"}},
1507
+ "required": ["url"],
1508
+ "$ref": "#/$defs/specification-extensions",
1509
+ "unevaluatedProperties": False,
1510
+ },
1511
+ "parameter": {
1512
+ "$comment": "https://spec.openapis.org/oas/v3.1.0#parameter-object",
1513
+ "type": "object",
1514
+ "properties": {
1515
+ "name": {"type": "string"},
1516
+ "in": {"enum": ["query", "header", "path", "cookie"]},
1517
+ "description": {"type": "string"},
1518
+ "required": {"default": False, "type": "boolean"},
1519
+ "deprecated": {"default": False, "type": "boolean"},
1520
+ "schema": {"$dynamicRef": "#meta"},
1521
+ "content": {"$ref": "#/$defs/content", "minProperties": 1, "maxProperties": 1},
1522
+ },
1523
+ "required": ["name", "in"],
1524
+ "oneOf": [{"required": ["schema"]}, {"required": ["content"]}],
1525
+ "if": {"properties": {"in": {"const": "query"}}, "required": ["in"]},
1526
+ "then": {"properties": {"allowEmptyValue": {"default": False, "type": "boolean"}}},
1527
+ "dependentSchemas": {
1528
+ "schema": {
1529
+ "properties": {"style": {"type": "string"}, "explode": {"type": "boolean"}},
1530
+ "allOf": [
1531
+ {"$ref": "#/$defs/examples"},
1532
+ {"$ref": "#/$defs/parameter/dependentSchemas/schema/$defs/styles-for-path"},
1533
+ {"$ref": "#/$defs/parameter/dependentSchemas/schema/$defs/styles-for-header"},
1534
+ {"$ref": "#/$defs/parameter/dependentSchemas/schema/$defs/styles-for-query"},
1535
+ {"$ref": "#/$defs/parameter/dependentSchemas/schema/$defs/styles-for-cookie"},
1536
+ {"$ref": "#/$defs/styles-for-form"},
1537
+ ],
1538
+ "$defs": {
1539
+ "styles-for-path": {
1540
+ "if": {"properties": {"in": {"const": "path"}}, "required": ["in"]},
1541
+ "then": {
1542
+ "properties": {
1543
+ "style": {"default": "simple", "enum": ["matrix", "label", "simple"]},
1544
+ "required": {"const": True},
1545
+ },
1546
+ "required": ["required"],
1547
+ },
1548
+ },
1549
+ "styles-for-header": {
1550
+ "if": {"properties": {"in": {"const": "header"}}, "required": ["in"]},
1551
+ "then": {"properties": {"style": {"default": "simple", "const": "simple"}}},
1552
+ },
1553
+ "styles-for-query": {
1554
+ "if": {"properties": {"in": {"const": "query"}}, "required": ["in"]},
1555
+ "then": {
1556
+ "properties": {
1557
+ "style": {
1558
+ "default": "form",
1559
+ "enum": ["form", "spaceDelimited", "pipeDelimited", "deepObject"],
1560
+ },
1561
+ "allowReserved": {"default": False, "type": "boolean"},
1562
+ }
1563
+ },
1564
+ },
1565
+ "styles-for-cookie": {
1566
+ "if": {"properties": {"in": {"const": "cookie"}}, "required": ["in"]},
1567
+ "then": {"properties": {"style": {"default": "form", "const": "form"}}},
1568
+ },
1569
+ },
1570
+ }
1571
+ },
1572
+ "$ref": "#/$defs/specification-extensions",
1573
+ "unevaluatedProperties": False,
1574
+ },
1575
+ "parameter-or-reference": {
1576
+ "if": {"type": "object", "required": ["$ref"]},
1577
+ "then": {"$ref": "#/$defs/reference"},
1578
+ "else": {"$ref": "#/$defs/parameter"},
1579
+ },
1580
+ "request-body": {
1581
+ "$comment": "https://spec.openapis.org/oas/v3.1.0#request-body-object",
1582
+ "type": "object",
1583
+ "properties": {
1584
+ "description": {"type": "string"},
1585
+ "content": {"$ref": "#/$defs/content"},
1586
+ "required": {"default": False, "type": "boolean"},
1587
+ },
1588
+ "required": ["content"],
1589
+ "$ref": "#/$defs/specification-extensions",
1590
+ "unevaluatedProperties": False,
1591
+ },
1592
+ "request-body-or-reference": {
1593
+ "if": {"type": "object", "required": ["$ref"]},
1594
+ "then": {"$ref": "#/$defs/reference"},
1595
+ "else": {"$ref": "#/$defs/request-body"},
1596
+ },
1597
+ "content": {
1598
+ "$comment": "https://spec.openapis.org/oas/v3.1.0#fixed-fields-10",
1599
+ "type": "object",
1600
+ "additionalProperties": {"$ref": "#/$defs/media-type"},
1601
+ "propertyNames": {"format": "media-range"},
1602
+ },
1603
+ "media-type": {
1604
+ "$comment": "https://spec.openapis.org/oas/v3.1.0#media-type-object",
1605
+ "type": "object",
1606
+ "properties": {
1607
+ "schema": {"$dynamicRef": "#meta"},
1608
+ "encoding": {"type": "object", "additionalProperties": {"$ref": "#/$defs/encoding"}},
1609
+ },
1610
+ "allOf": [{"$ref": "#/$defs/specification-extensions"}, {"$ref": "#/$defs/examples"}],
1611
+ "unevaluatedProperties": False,
1612
+ },
1613
+ "encoding": {
1614
+ "$comment": "https://spec.openapis.org/oas/v3.1.0#encoding-object",
1615
+ "type": "object",
1616
+ "properties": {
1617
+ "contentType": {"type": "string", "format": "media-range"},
1618
+ "headers": {"type": "object", "additionalProperties": {"$ref": "#/$defs/header-or-reference"}},
1619
+ "style": {"default": "form", "enum": ["form", "spaceDelimited", "pipeDelimited", "deepObject"]},
1620
+ "explode": {"type": "boolean"},
1621
+ "allowReserved": {"default": False, "type": "boolean"},
1622
+ },
1623
+ "allOf": [{"$ref": "#/$defs/specification-extensions"}, {"$ref": "#/$defs/styles-for-form"}],
1624
+ "unevaluatedProperties": False,
1625
+ },
1626
+ "responses": {
1627
+ "$comment": "https://spec.openapis.org/oas/v3.1.0#responses-object",
1628
+ "type": "object",
1629
+ "properties": {"default": {"$ref": "#/$defs/response-or-reference"}},
1630
+ "patternProperties": {"^[1-5](?:[0-9]{2}|XX)$": {"$ref": "#/$defs/response-or-reference"}},
1631
+ "minProperties": 1,
1632
+ "$ref": "#/$defs/specification-extensions",
1633
+ "unevaluatedProperties": False,
1634
+ "if": {
1635
+ "$comment": "either default, or at least one response code property must exist",
1636
+ "patternProperties": {"^[1-5](?:[0-9]{2}|XX)$": False},
1637
+ },
1638
+ "then": {"required": ["default"]},
1639
+ },
1640
+ "response": {
1641
+ "$comment": "https://spec.openapis.org/oas/v3.1.0#response-object",
1642
+ "type": "object",
1643
+ "properties": {
1644
+ "description": {"type": "string"},
1645
+ "headers": {"type": "object", "additionalProperties": {"$ref": "#/$defs/header-or-reference"}},
1646
+ "content": {"$ref": "#/$defs/content"},
1647
+ "links": {"type": "object", "additionalProperties": {"$ref": "#/$defs/link-or-reference"}},
1648
+ },
1649
+ "required": ["description"],
1650
+ "$ref": "#/$defs/specification-extensions",
1651
+ "unevaluatedProperties": False,
1652
+ },
1653
+ "response-or-reference": {
1654
+ "if": {"type": "object", "required": ["$ref"]},
1655
+ "then": {"$ref": "#/$defs/reference"},
1656
+ "else": {"$ref": "#/$defs/response"},
1657
+ },
1658
+ "callbacks": {
1659
+ "$comment": "https://spec.openapis.org/oas/v3.1.0#callback-object",
1660
+ "type": "object",
1661
+ "$ref": "#/$defs/specification-extensions",
1662
+ "additionalProperties": {"$ref": "#/$defs/path-item"},
1663
+ },
1664
+ "callbacks-or-reference": {
1665
+ "if": {"type": "object", "required": ["$ref"]},
1666
+ "then": {"$ref": "#/$defs/reference"},
1667
+ "else": {"$ref": "#/$defs/callbacks"},
1668
+ },
1669
+ "example": {
1670
+ "$comment": "https://spec.openapis.org/oas/v3.1.0#example-object",
1671
+ "type": "object",
1672
+ "properties": {
1673
+ "summary": {"type": "string"},
1674
+ "description": {"type": "string"},
1675
+ "value": True,
1676
+ "externalValue": {"type": "string", "format": "uri"},
1677
+ },
1678
+ "not": {"required": ["value", "externalValue"]},
1679
+ "$ref": "#/$defs/specification-extensions",
1680
+ "unevaluatedProperties": False,
1681
+ },
1682
+ "example-or-reference": {
1683
+ "if": {"type": "object", "required": ["$ref"]},
1684
+ "then": {"$ref": "#/$defs/reference"},
1685
+ "else": {"$ref": "#/$defs/example"},
1686
+ },
1687
+ "link": {
1688
+ "$comment": "https://spec.openapis.org/oas/v3.1.0#link-object",
1689
+ "type": "object",
1690
+ "properties": {
1691
+ "operationRef": {"type": "string", "format": "uri-reference"},
1692
+ "operationId": {"type": "string"},
1693
+ "parameters": {"$ref": "#/$defs/map-of-strings"},
1694
+ "requestBody": True,
1695
+ "description": {"type": "string"},
1696
+ "body": {"$ref": "#/$defs/server"},
1697
+ },
1698
+ "oneOf": [{"required": ["operationRef"]}, {"required": ["operationId"]}],
1699
+ "$ref": "#/$defs/specification-extensions",
1700
+ "unevaluatedProperties": False,
1701
+ },
1702
+ "link-or-reference": {
1703
+ "if": {"type": "object", "required": ["$ref"]},
1704
+ "then": {"$ref": "#/$defs/reference"},
1705
+ "else": {"$ref": "#/$defs/link"},
1706
+ },
1707
+ "header": {
1708
+ "$comment": "https://spec.openapis.org/oas/v3.1.0#header-object",
1709
+ "type": "object",
1710
+ "properties": {
1711
+ "description": {"type": "string"},
1712
+ "required": {"default": False, "type": "boolean"},
1713
+ "deprecated": {"default": False, "type": "boolean"},
1714
+ "schema": {"$dynamicRef": "#meta"},
1715
+ "content": {"$ref": "#/$defs/content", "minProperties": 1, "maxProperties": 1},
1716
+ },
1717
+ "oneOf": [{"required": ["schema"]}, {"required": ["content"]}],
1718
+ "dependentSchemas": {
1719
+ "schema": {
1720
+ "properties": {
1721
+ "style": {"default": "simple", "const": "simple"},
1722
+ "explode": {"default": False, "type": "boolean"},
1723
+ },
1724
+ "$ref": "#/$defs/examples",
1725
+ }
1726
+ },
1727
+ "$ref": "#/$defs/specification-extensions",
1728
+ "unevaluatedProperties": False,
1729
+ },
1730
+ "header-or-reference": {
1731
+ "if": {"type": "object", "required": ["$ref"]},
1732
+ "then": {"$ref": "#/$defs/reference"},
1733
+ "else": {"$ref": "#/$defs/header"},
1734
+ },
1735
+ "tag": {
1736
+ "$comment": "https://spec.openapis.org/oas/v3.1.0#tag-object",
1737
+ "type": "object",
1738
+ "properties": {
1739
+ "name": {"type": "string"},
1740
+ "description": {"type": "string"},
1741
+ "externalDocs": {"$ref": "#/$defs/external-documentation"},
1742
+ },
1743
+ "required": ["name"],
1744
+ "$ref": "#/$defs/specification-extensions",
1745
+ "unevaluatedProperties": False,
1746
+ },
1747
+ "reference": {
1748
+ "$comment": "https://spec.openapis.org/oas/v3.1.0#reference-object",
1749
+ "type": "object",
1750
+ "properties": {
1751
+ "$ref": {"type": "string", "format": "uri-reference"},
1752
+ "summary": {"type": "string"},
1753
+ "description": {"type": "string"},
1754
+ },
1755
+ },
1756
+ "schema": {
1757
+ "$comment": "https://spec.openapis.org/oas/v3.1.0#schema-object",
1758
+ "$dynamicAnchor": "meta",
1759
+ "type": ["object", "boolean"],
1760
+ },
1761
+ "security-scheme": {
1762
+ "$comment": "https://spec.openapis.org/oas/v3.1.0#security-scheme-object",
1763
+ "type": "object",
1764
+ "properties": {
1765
+ "type": {"enum": ["apiKey", "http", "mutualTLS", "oauth2", "openIdConnect"]},
1766
+ "description": {"type": "string"},
1767
+ },
1768
+ "required": ["type"],
1769
+ "allOf": [
1770
+ {"$ref": "#/$defs/specification-extensions"},
1771
+ {"$ref": "#/$defs/security-scheme/$defs/type-apikey"},
1772
+ {"$ref": "#/$defs/security-scheme/$defs/type-http"},
1773
+ {"$ref": "#/$defs/security-scheme/$defs/type-http-bearer"},
1774
+ {"$ref": "#/$defs/security-scheme/$defs/type-oauth2"},
1775
+ {"$ref": "#/$defs/security-scheme/$defs/type-oidc"},
1776
+ ],
1777
+ "unevaluatedProperties": False,
1778
+ "$defs": {
1779
+ "type-apikey": {
1780
+ "if": {"properties": {"type": {"const": "apiKey"}}, "required": ["type"]},
1781
+ "then": {
1782
+ "properties": {"name": {"type": "string"}, "in": {"enum": ["query", "header", "cookie"]}},
1783
+ "required": ["name", "in"],
1784
+ },
1785
+ },
1786
+ "type-http": {
1787
+ "if": {"properties": {"type": {"const": "http"}}, "required": ["type"]},
1788
+ "then": {"properties": {"scheme": {"type": "string"}}, "required": ["scheme"]},
1789
+ },
1790
+ "type-http-bearer": {
1791
+ "if": {
1792
+ "properties": {
1793
+ "type": {"const": "http"},
1794
+ "scheme": {"type": "string", "pattern": "^[Bb][Ee][Aa][Rr][Ee][Rr]$"},
1795
+ },
1796
+ "required": ["type", "scheme"],
1797
+ },
1798
+ "then": {"properties": {"bearerFormat": {"type": "string"}}},
1799
+ },
1800
+ "type-oauth2": {
1801
+ "if": {"properties": {"type": {"const": "oauth2"}}, "required": ["type"]},
1802
+ "then": {"properties": {"flows": {"$ref": "#/$defs/oauth-flows"}}, "required": ["flows"]},
1803
+ },
1804
+ "type-oidc": {
1805
+ "if": {"properties": {"type": {"const": "openIdConnect"}}, "required": ["type"]},
1806
+ "then": {
1807
+ "properties": {"openIdConnectUrl": {"type": "string", "format": "uri"}},
1808
+ "required": ["openIdConnectUrl"],
1809
+ },
1810
+ },
1811
+ },
1812
+ },
1813
+ "security-scheme-or-reference": {
1814
+ "if": {"type": "object", "required": ["$ref"]},
1815
+ "then": {"$ref": "#/$defs/reference"},
1816
+ "else": {"$ref": "#/$defs/security-scheme"},
1817
+ },
1818
+ "oauth-flows": {
1819
+ "type": "object",
1820
+ "properties": {
1821
+ "implicit": {"$ref": "#/$defs/oauth-flows/$defs/implicit"},
1822
+ "password": {"$ref": "#/$defs/oauth-flows/$defs/password"},
1823
+ "clientCredentials": {"$ref": "#/$defs/oauth-flows/$defs/client-credentials"},
1824
+ "authorizationCode": {"$ref": "#/$defs/oauth-flows/$defs/authorization-code"},
1825
+ },
1826
+ "$ref": "#/$defs/specification-extensions",
1827
+ "unevaluatedProperties": False,
1828
+ "$defs": {
1829
+ "implicit": {
1830
+ "type": "object",
1831
+ "properties": {
1832
+ "authorizationUrl": {"type": "string", "format": "uri"},
1833
+ "refreshUrl": {"type": "string", "format": "uri"},
1834
+ "scopes": {"$ref": "#/$defs/map-of-strings"},
1835
+ },
1836
+ "required": ["authorizationUrl", "scopes"],
1837
+ "$ref": "#/$defs/specification-extensions",
1838
+ "unevaluatedProperties": False,
1839
+ },
1840
+ "password": {
1841
+ "type": "object",
1842
+ "properties": {
1843
+ "tokenUrl": {"type": "string", "format": "uri"},
1844
+ "refreshUrl": {"type": "string", "format": "uri"},
1845
+ "scopes": {"$ref": "#/$defs/map-of-strings"},
1846
+ },
1847
+ "required": ["tokenUrl", "scopes"],
1848
+ "$ref": "#/$defs/specification-extensions",
1849
+ "unevaluatedProperties": False,
1850
+ },
1851
+ "client-credentials": {
1852
+ "type": "object",
1853
+ "properties": {
1854
+ "tokenUrl": {"type": "string", "format": "uri"},
1855
+ "refreshUrl": {"type": "string", "format": "uri"},
1856
+ "scopes": {"$ref": "#/$defs/map-of-strings"},
1857
+ },
1858
+ "required": ["tokenUrl", "scopes"],
1859
+ "$ref": "#/$defs/specification-extensions",
1860
+ "unevaluatedProperties": False,
1861
+ },
1862
+ "authorization-code": {
1863
+ "type": "object",
1864
+ "properties": {
1865
+ "authorizationUrl": {"type": "string", "format": "uri"},
1866
+ "tokenUrl": {"type": "string", "format": "uri"},
1867
+ "refreshUrl": {"type": "string", "format": "uri"},
1868
+ "scopes": {"$ref": "#/$defs/map-of-strings"},
1869
+ },
1870
+ "required": ["authorizationUrl", "tokenUrl", "scopes"],
1871
+ "$ref": "#/$defs/specification-extensions",
1872
+ "unevaluatedProperties": False,
1873
+ },
1874
+ },
1875
+ },
1876
+ "security-requirement": {
1877
+ "$comment": "https://spec.openapis.org/oas/v3.1.0#security-requirement-object",
1878
+ "type": "object",
1879
+ "additionalProperties": {"type": "array", "items": {"type": "string"}},
1880
+ },
1881
+ "specification-extensions": {
1882
+ "$comment": "https://spec.openapis.org/oas/v3.1.0#specification-extensions",
1883
+ "patternProperties": {"^x-": True},
1884
+ },
1885
+ "examples": {
1886
+ "properties": {
1887
+ "example": True,
1888
+ "examples": {"type": "object", "additionalProperties": {"$ref": "#/$defs/example-or-reference"}},
1889
+ }
1890
+ },
1891
+ "map-of-strings": {"type": "object", "additionalProperties": {"type": "string"}},
1892
+ "styles-for-form": {
1893
+ "if": {"properties": {"style": {"const": "form"}}, "required": ["style"]},
1894
+ "then": {"properties": {"explode": {"default": True}}},
1895
+ "else": {"properties": {"explode": {"default": False}}},
1896
+ },
1897
+ },
1898
+ }
1899
+
1900
+ _VALIDATORS = [
1901
+ "SWAGGER_20_VALIDATOR",
1902
+ "OPENAPI_30_VALIDATOR",
1903
+ "OPENAPI_31_VALIDATOR",
1904
+ ]
1905
+
1906
+ __all__ = ["SWAGGER_20", "OPENAPI_30", "OPENAPI_31", *_VALIDATORS]
1907
+
1908
+ _imports = {
1909
+ "SWAGGER_20_VALIDATOR": lambda: make_validator(SWAGGER_20),
1910
+ "OPENAPI_30_VALIDATOR": lambda: make_validator(OPENAPI_30),
1911
+ "OPENAPI_31_VALIDATOR": lambda: make_validator(OPENAPI_31),
1912
+ }
1913
+
1914
+
1915
+ def make_validator(schema: dict[str, Any]) -> Validator:
1916
+ import jsonschema
1917
+
1918
+ return jsonschema.validators.validator_for(schema)(schema)
1919
+
1920
+
1921
+ def __getattr__(name: str) -> Any:
1922
+ return lazy_import(__name__, name, _imports, globals())