|
2 | 2 | from typing import Any
|
3 | 3 | from typing import Type
|
4 | 4 |
|
5 |
| -from jsonschema import _legacy_validators |
6 |
| -from jsonschema import _validators |
| 5 | +from jsonschema import _keywords |
| 6 | +from jsonschema import _legacy_keywords |
7 | 7 | from jsonschema.validators import Draft202012Validator
|
8 | 8 | from jsonschema.validators import create
|
9 | 9 | from jsonschema.validators import extend
|
10 | 10 | from jsonschema_specifications import REGISTRY as SPECIFICATIONS
|
11 | 11 |
|
12 | 12 | from openapi_schema_validator import _format as oas_format
|
| 13 | +from openapi_schema_validator import _keywords as oas_keywords |
13 | 14 | from openapi_schema_validator import _types as oas_types
|
14 |
| -from openapi_schema_validator import _validators as oas_validators |
15 | 15 | from openapi_schema_validator._types import oas31_type_checker
|
16 | 16 |
|
17 | 17 | OAS30Validator = create(
|
18 | 18 | meta_schema=SPECIFICATIONS.contents(
|
19 | 19 | "http://json-schema.org/draft-04/schema#",
|
20 | 20 | ),
|
21 | 21 | validators={
|
22 |
| - "multipleOf": _validators.multipleOf, |
| 22 | + "multipleOf": _keywords.multipleOf, |
23 | 23 | # exclusiveMaximum supported inside maximum_draft3_draft4
|
24 |
| - "maximum": _legacy_validators.maximum_draft3_draft4, |
| 24 | + "maximum": _legacy_keywords.maximum_draft3_draft4, |
25 | 25 | # exclusiveMinimum supported inside minimum_draft3_draft4
|
26 |
| - "minimum": _legacy_validators.minimum_draft3_draft4, |
27 |
| - "maxLength": _validators.maxLength, |
28 |
| - "minLength": _validators.minLength, |
29 |
| - "pattern": _validators.pattern, |
30 |
| - "maxItems": _validators.maxItems, |
31 |
| - "minItems": _validators.minItems, |
32 |
| - "uniqueItems": _validators.uniqueItems, |
33 |
| - "maxProperties": _validators.maxProperties, |
34 |
| - "minProperties": _validators.minProperties, |
35 |
| - "enum": _validators.enum, |
| 26 | + "minimum": _legacy_keywords.minimum_draft3_draft4, |
| 27 | + "maxLength": _keywords.maxLength, |
| 28 | + "minLength": _keywords.minLength, |
| 29 | + "pattern": _keywords.pattern, |
| 30 | + "maxItems": _keywords.maxItems, |
| 31 | + "minItems": _keywords.minItems, |
| 32 | + "uniqueItems": _keywords.uniqueItems, |
| 33 | + "maxProperties": _keywords.maxProperties, |
| 34 | + "minProperties": _keywords.minProperties, |
| 35 | + "enum": _keywords.enum, |
36 | 36 | # adjusted to OAS
|
37 |
| - "type": oas_validators.type, |
38 |
| - "allOf": oas_validators.allOf, |
39 |
| - "oneOf": oas_validators.oneOf, |
40 |
| - "anyOf": oas_validators.anyOf, |
41 |
| - "not": _validators.not_, |
42 |
| - "items": oas_validators.items, |
43 |
| - "properties": _validators.properties, |
44 |
| - "required": oas_validators.required, |
45 |
| - "additionalProperties": oas_validators.additionalProperties, |
| 37 | + "type": oas_keywords.type, |
| 38 | + "allOf": oas_keywords.allOf, |
| 39 | + "oneOf": oas_keywords.oneOf, |
| 40 | + "anyOf": oas_keywords.anyOf, |
| 41 | + "not": _keywords.not_, |
| 42 | + "items": oas_keywords.items, |
| 43 | + "properties": _keywords.properties, |
| 44 | + "required": oas_keywords.required, |
| 45 | + "additionalProperties": oas_keywords.additionalProperties, |
46 | 46 | # TODO: adjust description
|
47 |
| - "format": oas_validators.format, |
| 47 | + "format": oas_keywords.format, |
48 | 48 | # TODO: adjust default
|
49 |
| - "$ref": _validators.ref, |
| 49 | + "$ref": _keywords.ref, |
50 | 50 | # fixed OAS fields
|
51 |
| - "discriminator": oas_validators.not_implemented, |
52 |
| - "readOnly": oas_validators.readOnly, |
53 |
| - "writeOnly": oas_validators.writeOnly, |
54 |
| - "xml": oas_validators.not_implemented, |
55 |
| - "externalDocs": oas_validators.not_implemented, |
56 |
| - "example": oas_validators.not_implemented, |
57 |
| - "deprecated": oas_validators.not_implemented, |
| 51 | + "discriminator": oas_keywords.not_implemented, |
| 52 | + "readOnly": oas_keywords.readOnly, |
| 53 | + "writeOnly": oas_keywords.writeOnly, |
| 54 | + "xml": oas_keywords.not_implemented, |
| 55 | + "externalDocs": oas_keywords.not_implemented, |
| 56 | + "example": oas_keywords.not_implemented, |
| 57 | + "deprecated": oas_keywords.not_implemented, |
58 | 58 | },
|
59 | 59 | type_checker=oas_types.oas30_type_checker,
|
60 | 60 | format_checker=oas_format.oas30_format_checker,
|
|
67 | 67 | OAS30ReadValidator = extend(
|
68 | 68 | OAS30Validator,
|
69 | 69 | validators={
|
70 |
| - "required": oas_validators.read_required, |
71 |
| - "readOnly": oas_validators.not_implemented, |
72 |
| - "writeOnly": oas_validators.writeOnly, |
| 70 | + "required": oas_keywords.read_required, |
| 71 | + "readOnly": oas_keywords.not_implemented, |
| 72 | + "writeOnly": oas_keywords.writeOnly, |
73 | 73 | },
|
74 | 74 | )
|
75 | 75 | OAS30WriteValidator = extend(
|
76 | 76 | OAS30Validator,
|
77 | 77 | validators={
|
78 |
| - "required": oas_validators.write_required, |
79 |
| - "readOnly": oas_validators.readOnly, |
80 |
| - "writeOnly": oas_validators.not_implemented, |
| 78 | + "required": oas_keywords.write_required, |
| 79 | + "readOnly": oas_keywords.readOnly, |
| 80 | + "writeOnly": oas_keywords.not_implemented, |
81 | 81 | },
|
82 | 82 | )
|
83 | 83 |
|
84 | 84 | OAS31Validator = extend(
|
85 | 85 | Draft202012Validator,
|
86 | 86 | {
|
87 | 87 | # adjusted to OAS
|
88 |
| - "allOf": oas_validators.allOf, |
89 |
| - "oneOf": oas_validators.oneOf, |
90 |
| - "anyOf": oas_validators.anyOf, |
91 |
| - "description": oas_validators.not_implemented, |
| 88 | + "allOf": oas_keywords.allOf, |
| 89 | + "oneOf": oas_keywords.oneOf, |
| 90 | + "anyOf": oas_keywords.anyOf, |
| 91 | + "description": oas_keywords.not_implemented, |
92 | 92 | # fixed OAS fields
|
93 |
| - "discriminator": oas_validators.not_implemented, |
94 |
| - "xml": oas_validators.not_implemented, |
95 |
| - "externalDocs": oas_validators.not_implemented, |
96 |
| - "example": oas_validators.not_implemented, |
| 93 | + "discriminator": oas_keywords.not_implemented, |
| 94 | + "xml": oas_keywords.not_implemented, |
| 95 | + "externalDocs": oas_keywords.not_implemented, |
| 96 | + "example": oas_keywords.not_implemented, |
97 | 97 | },
|
98 | 98 | type_checker=oas31_type_checker,
|
99 | 99 | format_checker=oas_format.oas31_format_checker,
|
|
0 commit comments