Skip to content
This repository was archived by the owner on Dec 25, 2024. It is now read-only.

Commit b04e9f3

Browse files
authored
Adds 3.1.0 json schema propertyNames (#216)
* Adds two propertyNames component schema examples * Adds validator and supressable keyword for propertyNames * Adds python test samples * Regenerates samples and docs
1 parent 0804007 commit b04e9f3

File tree

35 files changed

+368
-9
lines changed

35 files changed

+368
-9
lines changed

docs/generators/java.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
343343
|OneOf|✗|OAS3
344344
|Pattern|✓|OAS2,OAS3
345345
|Properties|✓|OAS2,OAS3
346+
|PropertyNames|✗|OAS3
346347
|Required|✓|OAS2,OAS3
347348
|Type|✓|OAS2,OAS3
348349
|UniqueItems|✓|OAS2,OAS3

docs/generators/jaxrs-jersey.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
326326
|OneOf|✗|OAS3
327327
|Pattern|✓|OAS2,OAS3
328328
|Properties|✓|OAS2,OAS3
329+
|PropertyNames|✗|OAS3
329330
|Required|✓|OAS2,OAS3
330331
|Type|✓|OAS2,OAS3
331332
|UniqueItems|✓|OAS2,OAS3

docs/generators/jmeter.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
185185
|OneOf|✗|OAS3
186186
|Pattern|✓|OAS2,OAS3
187187
|Properties|✓|OAS2,OAS3
188+
|PropertyNames|✗|OAS3
188189
|Required|✓|OAS2,OAS3
189190
|Type|✓|OAS2,OAS3
190191
|UniqueItems|✓|OAS2,OAS3

docs/generators/kotlin.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
295295
|OneOf|✗|OAS3
296296
|Pattern|✓|OAS2,OAS3
297297
|Properties|✓|OAS2,OAS3
298+
|PropertyNames|✗|OAS3
298299
|Required|✓|OAS2,OAS3
299300
|Type|✓|OAS2,OAS3
300301
|UniqueItems|✓|OAS2,OAS3

docs/generators/python.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
254254
|OneOf|✓|OAS3
255255
|Pattern|✓|OAS2,OAS3
256256
|Properties|✓|OAS2,OAS3
257+
|PropertyNames|✓|OAS3
257258
|Required|✓|OAS2,OAS3
258259
|Type|✓|OAS2,OAS3
259260
|UniqueItems|✓|OAS2,OAS3

samples/client/3_0_3_unit_test/python/src/unit_test_api/configurations/schema_configuration.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
'one_of': 'oneOf',
4343
'pattern': 'pattern',
4444
'properties': 'properties',
45+
'property_names': 'propertyNames',
4546
'required': 'required',
4647
'types': 'type',
4748
'unique_items': 'uniqueItems'

samples/client/3_0_3_unit_test/python/src/unit_test_api/schemas/validation.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1103,6 +1103,27 @@ def validate_dependent_schemas(
11031103
return path_to_schemas
11041104

11051105

1106+
def validate_property_names(
1107+
arg: typing.Any,
1108+
property_names_schema: typing.Type[SchemaValidator],
1109+
cls: typing.Type,
1110+
validation_metadata: ValidationMetadata,
1111+
) -> None:
1112+
if not isinstance(arg, immutabledict):
1113+
return None
1114+
module_namespace = vars(sys.modules[cls.__module__])
1115+
property_names_schema = _get_class(property_names_schema, module_namespace)
1116+
for key in arg.keys():
1117+
path_to_item = validation_metadata.path_to_item + (key,)
1118+
key_validation_metadata = ValidationMetadata(
1119+
path_to_item=path_to_item,
1120+
configuration=validation_metadata.configuration,
1121+
validated_path_to_schemas=validation_metadata.validated_path_to_schemas
1122+
)
1123+
property_names_schema._validate(key, validation_metadata=key_validation_metadata)
1124+
return None
1125+
1126+
11061127
validator_type = typing.Callable[[typing.Any, typing.Any, type, ValidationMetadata], typing.Optional[PathToSchemasType]]
11071128
json_schema_keyword_to_validator: typing.Mapping[str, validator_type] = {
11081129
'types': validate_types,
@@ -1135,5 +1156,6 @@ def validate_dependent_schemas(
11351156
'max_contains': validate_max_contains,
11361157
'const_value_to_name': validate_const,
11371158
'dependent_required': validate_dependent_required,
1138-
'dependent_schemas': validate_dependent_schemas
1159+
'dependent_schemas': validate_dependent_schemas,
1160+
'property_names': validate_property_names
11391161
}

samples/client/3_1_0_json_schema/python/.openapi-generator/FILES

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@ docs/components/schema/any_type_dependent_required.md
99
docs/components/schema/any_type_dependent_schemas.md
1010
docs/components/schema/any_type_max_contains_value.md
1111
docs/components/schema/any_type_min_contains_value.md
12+
docs/components/schema/any_type_property_names.md
1213
docs/components/schema/array_contains_value.md
1314
docs/components/schema/array_max_contains_value.md
1415
docs/components/schema/array_min_contains_value.md
1516
docs/components/schema/object_dependent_required.md
1617
docs/components/schema/object_dependent_schemas.md
18+
docs/components/schema/object_property_names.md
1719
docs/components/schema/string_const_string.md
1820
docs/paths/some_path/get.md
1921
docs/paths/some_path/get/responses/response_200/content/application_json/schema.md
@@ -41,11 +43,13 @@ src/json_schema_api/components/schema/any_type_dependent_required.py
4143
src/json_schema_api/components/schema/any_type_dependent_schemas.py
4244
src/json_schema_api/components/schema/any_type_max_contains_value.py
4345
src/json_schema_api/components/schema/any_type_min_contains_value.py
46+
src/json_schema_api/components/schema/any_type_property_names.py
4447
src/json_schema_api/components/schema/array_contains_value.py
4548
src/json_schema_api/components/schema/array_max_contains_value.py
4649
src/json_schema_api/components/schema/array_min_contains_value.py
4750
src/json_schema_api/components/schema/object_dependent_required.py
4851
src/json_schema_api/components/schema/object_dependent_schemas.py
52+
src/json_schema_api/components/schema/object_property_names.py
4953
src/json_schema_api/components/schema/string_const_string.py
5054
src/json_schema_api/components/schemas/__init__.py
5155
src/json_schema_api/configurations/__init__.py

samples/client/3_1_0_json_schema/python/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,11 +179,13 @@ Class | Description
179179
[AnyTypeDependentSchemas](docs/components/schema/any_type_dependent_schemas.md) |
180180
[AnyTypeMaxContainsValue](docs/components/schema/any_type_max_contains_value.md) |
181181
[AnyTypeMinContainsValue](docs/components/schema/any_type_min_contains_value.md) |
182+
[AnyTypePropertyNames](docs/components/schema/any_type_property_names.md) |
182183
[ArrayContainsValue](docs/components/schema/array_contains_value.md) |
183184
[ArrayMaxContainsValue](docs/components/schema/array_max_contains_value.md) |
184185
[ArrayMinContainsValue](docs/components/schema/array_min_contains_value.md) |
185186
[ObjectDependentRequired](docs/components/schema/object_dependent_required.md) |
186187
[ObjectDependentSchemas](docs/components/schema/object_dependent_schemas.md) |
188+
[ObjectPropertyNames](docs/components/schema/object_property_names.md) |
187189
[StringConstString](docs/components/schema/string_const_string.md) |
188190

189191
## Notes for Large OpenAPI documents
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# AnyTypePropertyNames
2+
json_schema_api.components.schema.any_type_property_names
3+
```
4+
type: schemas.Schema
5+
```
6+
7+
## validate method
8+
Input Type | Return Type | Notes
9+
------------ | ------------- | -------------
10+
dict, schemas.immutabledict, str, datetime.date, datetime.datetime, uuid.UUID, int, float, bool, None, list, tuple, bytes, io.FileIO, io.BufferedReader | schemas.immutabledict, str, float, int, bool, None, tuple, bytes, io.FileIO |
11+
12+
[[Back to top]](#top) [[Back to Component Schemas]](../../../README.md#Component-Schemas) [[Back to README]](../../../README.md)

0 commit comments

Comments
 (0)