Skip to content
This repository was archived by the owner on Dec 25, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/generators/java.md
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|PropertyNames|✗|OAS3
|Required|✓|OAS2,OAS3
|Type|✓|OAS2,OAS3
|UnevaluatedItems|✗|OAS3
|UniqueItems|✓|OAS2,OAS3
|Xml|✗|OAS2,OAS3

Expand Down
1 change: 1 addition & 0 deletions docs/generators/jaxrs-jersey.md
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|PropertyNames|✗|OAS3
|Required|✓|OAS2,OAS3
|Type|✓|OAS2,OAS3
|UnevaluatedItems|✗|OAS3
|UniqueItems|✓|OAS2,OAS3
|Xml|✗|OAS2,OAS3

Expand Down
1 change: 1 addition & 0 deletions docs/generators/jmeter.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|PropertyNames|✗|OAS3
|Required|✓|OAS2,OAS3
|Type|✓|OAS2,OAS3
|UnevaluatedItems|✗|OAS3
|UniqueItems|✓|OAS2,OAS3
|Xml|✗|OAS2,OAS3

Expand Down
1 change: 1 addition & 0 deletions docs/generators/kotlin.md
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|PropertyNames|✗|OAS3
|Required|✓|OAS2,OAS3
|Type|✓|OAS2,OAS3
|UnevaluatedItems|✗|OAS3
|UniqueItems|✓|OAS2,OAS3
|Xml|✗|OAS2,OAS3

Expand Down
1 change: 1 addition & 0 deletions docs/generators/python.md
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|PropertyNames|✓|OAS3
|Required|✓|OAS2,OAS3
|Type|✓|OAS2,OAS3
|UnevaluatedItems|✓|OAS3
|UniqueItems|✓|OAS2,OAS3
|Xml|✗|OAS2,OAS3

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@
'property_names': 'propertyNames',
'required': 'required',
'types': 'type',
'unique_items': 'uniqueItems'
'unique_items': 'uniqueItems',
'unevaluated_items': 'unevaluatedItems'
}

class SchemaConfiguration:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,13 @@ def _validate(
if 'prefix_items' in vars(cls_schema):
prefix_items_length = len(vars(cls_schema)['prefix_items'])
for keyword, val in json_schema_data.items():
used_val: typing.Any
if keyword in {'contains', 'min_contains', 'max_contains'}:
used_val = (val, contains_qty)
elif keyword == 'items':
used_val = (val, prefix_items_length)
elif keyword == 'unevaluated_items':
used_val = (val, path_to_schemas)
else:
used_val = val
validator = json_schema_keyword_to_validator[keyword]
Expand Down Expand Up @@ -1192,6 +1195,32 @@ def validate_prefix_items(
return path_to_schemas


def validate_unevaluated_items(
arg: typing.Any,
unevaluated_items_validated_path_to_schemas: typing.Tuple[typing.Type[SchemaValidator], PathToSchemasType],
cls: typing.Type,
validation_metadata: ValidationMetadata,
) -> typing.Optional[PathToSchemasType]:
if not isinstance(arg, tuple):
return None
path_to_schemas: PathToSchemasType = {}
module_namespace = vars(sys.modules[cls.__module__])
schema = _get_class(unevaluated_items_validated_path_to_schemas[0], module_namespace)
validated_path_to_schemas = unevaluated_items_validated_path_to_schemas[1]
for i, val in enumerate(arg):
path_to_item = validation_metadata.path_to_item + (i,)
if path_to_item in validated_path_to_schemas:
continue
item_validation_metadata = ValidationMetadata(
path_to_item=path_to_item,
configuration=validation_metadata.configuration,
validated_path_to_schemas=validation_metadata.validated_path_to_schemas
)
other_path_to_schemas = schema._validate(val, validation_metadata=item_validation_metadata)
update(path_to_schemas, other_path_to_schemas)
return path_to_schemas


validator_type = typing.Callable[[typing.Any, typing.Any, type, ValidationMetadata], typing.Optional[PathToSchemasType]]
json_schema_keyword_to_validator: typing.Mapping[str, validator_type] = {
'types': validate_types,
Expand Down Expand Up @@ -1227,5 +1256,6 @@ def validate_prefix_items(
'dependent_schemas': validate_dependent_schemas,
'property_names': validate_property_names,
'pattern_properties': validate_pattern_properties,
'prefix_items': validate_prefix_items
'prefix_items': validate_prefix_items,
'unevaluated_items': validate_unevaluated_items
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ docs/components/schema/any_type_min_contains_value.md
docs/components/schema/any_type_pattern_properties.md
docs/components/schema/any_type_prefix_items.md
docs/components/schema/any_type_property_names.md
docs/components/schema/any_type_unevaluated_items_false.md
docs/components/schema/any_type_unevaluated_items_false_with_prefix_items.md
docs/components/schema/any_type_unevaluated_items_string.md
docs/components/schema/any_type_unevaluated_items_true.md
docs/components/schema/array_contains_value.md
docs/components/schema/array_max_contains_value.md
docs/components/schema/array_min_contains_value.md
Expand Down Expand Up @@ -50,6 +54,10 @@ src/json_schema_api/components/schema/any_type_min_contains_value.py
src/json_schema_api/components/schema/any_type_pattern_properties.py
src/json_schema_api/components/schema/any_type_prefix_items.py
src/json_schema_api/components/schema/any_type_property_names.py
src/json_schema_api/components/schema/any_type_unevaluated_items_false.py
src/json_schema_api/components/schema/any_type_unevaluated_items_false_with_prefix_items.py
src/json_schema_api/components/schema/any_type_unevaluated_items_string.py
src/json_schema_api/components/schema/any_type_unevaluated_items_true.py
src/json_schema_api/components/schema/array_contains_value.py
src/json_schema_api/components/schema/array_max_contains_value.py
src/json_schema_api/components/schema/array_min_contains_value.py
Expand Down
4 changes: 4 additions & 0 deletions samples/client/3_1_0_json_schema/python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,10 @@ Class | Description
[AnyTypePatternProperties](docs/components/schema/any_type_pattern_properties.md) |
[AnyTypePrefixItems](docs/components/schema/any_type_prefix_items.md) |
[AnyTypePropertyNames](docs/components/schema/any_type_property_names.md) |
[AnyTypeUnevaluatedItemsFalse](docs/components/schema/any_type_unevaluated_items_false.md) |
[AnyTypeUnevaluatedItemsFalseWithPrefixItems](docs/components/schema/any_type_unevaluated_items_false_with_prefix_items.md) |
[AnyTypeUnevaluatedItemsString](docs/components/schema/any_type_unevaluated_items_string.md) |
[AnyTypeUnevaluatedItemsTrue](docs/components/schema/any_type_unevaluated_items_true.md) |
[ArrayContainsValue](docs/components/schema/array_contains_value.md) |
[ArrayMaxContainsValue](docs/components/schema/array_max_contains_value.md) |
[ArrayMinContainsValue](docs/components/schema/array_min_contains_value.md) |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# AnyTypeUnevaluatedItemsFalse
json_schema_api.components.schema.any_type_unevaluated_items_false
```
type: schemas.Schema
```

## validate method
Input Type | Return Type | Notes
------------ | ------------- | -------------
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 |

[[Back to top]](#top) [[Back to Component Schemas]](../../../README.md#Component-Schemas) [[Back to README]](../../../README.md)
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# AnyTypeUnevaluatedItemsFalseWithPrefixItems
json_schema_api.components.schema.any_type_unevaluated_items_false_with_prefix_items
```
type: schemas.Schema
```

## validate method
Input Type | Return Type | Notes
------------ | ------------- | -------------
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 |

[[Back to top]](#top) [[Back to Component Schemas]](../../../README.md#Component-Schemas) [[Back to README]](../../../README.md)
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# AnyTypeUnevaluatedItemsString
json_schema_api.components.schema.any_type_unevaluated_items_string
```
type: schemas.Schema
```

## validate method
Input Type | Return Type | Notes
------------ | ------------- | -------------
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 |

[[Back to top]](#top) [[Back to Component Schemas]](../../../README.md#Component-Schemas) [[Back to README]](../../../README.md)
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# AnyTypeUnevaluatedItemsTrue
json_schema_api.components.schema.any_type_unevaluated_items_true
```
type: schemas.Schema
```

## validate method
Input Type | Return Type | Notes
------------ | ------------- | -------------
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 |

[[Back to top]](#top) [[Back to Component Schemas]](../../../README.md#Component-Schemas) [[Back to README]](../../../README.md)
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# coding: utf-8

"""
Example
No description provided (generated by Openapi JSON Schema Generator https://github.com/openapi-json-schema-tools/openapi-json-schema-generator) # noqa: E501
The version of the OpenAPI document: 1.0.0
Generated by: https://github.com/openapi-json-schema-tools/openapi-json-schema-generator
"""

from __future__ import annotations
from json_schema_api.shared_imports.schema_imports import * # pyright: ignore [reportWildcardImportFromLibrary]

_Not: typing_extensions.TypeAlias = schemas.AnyTypeSchema


@dataclasses.dataclass(frozen=True)
class UnevaluatedItems(
schemas.AnyTypeSchema[schemas.immutabledict[str, schemas.OUTPUT_BASE_TYPES], typing.Tuple[schemas.OUTPUT_BASE_TYPES, ...]],
):
# any type
not_: typing.Type[_Not] = dataclasses.field(default_factory=lambda: _Not) # type: ignore



@dataclasses.dataclass(frozen=True)
class AnyTypeUnevaluatedItemsFalse(
schemas.AnyTypeSchema[schemas.immutabledict[str, schemas.OUTPUT_BASE_TYPES], typing.Tuple[schemas.OUTPUT_BASE_TYPES, ...]],
):
"""NOTE: This class is auto generated by OpenAPI JSON Schema Generator.
Ref: https://github.com/openapi-json-schema-tools/openapi-json-schema-generator

Do not edit the class manually.
"""
# any type
unevaluated_items: typing.Type[UnevaluatedItems] = dataclasses.field(default_factory=lambda: UnevaluatedItems) # type: ignore

Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# coding: utf-8

"""
Example
No description provided (generated by Openapi JSON Schema Generator https://github.com/openapi-json-schema-tools/openapi-json-schema-generator) # noqa: E501
The version of the OpenAPI document: 1.0.0
Generated by: https://github.com/openapi-json-schema-tools/openapi-json-schema-generator
"""

from __future__ import annotations
from json_schema_api.shared_imports.schema_imports import * # pyright: ignore [reportWildcardImportFromLibrary]

_0: typing_extensions.TypeAlias = schemas.StrSchema
_Not: typing_extensions.TypeAlias = schemas.AnyTypeSchema


@dataclasses.dataclass(frozen=True)
class UnevaluatedItems(
schemas.AnyTypeSchema[schemas.immutabledict[str, schemas.OUTPUT_BASE_TYPES], typing.Tuple[schemas.OUTPUT_BASE_TYPES, ...]],
):
# any type
not_: typing.Type[_Not] = dataclasses.field(default_factory=lambda: _Not) # type: ignore



@dataclasses.dataclass(frozen=True)
class AnyTypeUnevaluatedItemsFalseWithPrefixItems(
schemas.AnyTypeSchema[schemas.immutabledict[str, schemas.OUTPUT_BASE_TYPES], typing.Tuple[schemas.OUTPUT_BASE_TYPES, ...]],
):
"""NOTE: This class is auto generated by OpenAPI JSON Schema Generator.
Ref: https://github.com/openapi-json-schema-tools/openapi-json-schema-generator

Do not edit the class manually.
"""
# any type
prefix_items: typing.Tuple[
typing.Type[_0],
] = (
_0,
)
unevaluated_items: typing.Type[UnevaluatedItems] = dataclasses.field(default_factory=lambda: UnevaluatedItems) # type: ignore

Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# coding: utf-8

"""
Example
No description provided (generated by Openapi JSON Schema Generator https://github.com/openapi-json-schema-tools/openapi-json-schema-generator) # noqa: E501
The version of the OpenAPI document: 1.0.0
Generated by: https://github.com/openapi-json-schema-tools/openapi-json-schema-generator
"""

from __future__ import annotations
from json_schema_api.shared_imports.schema_imports import * # pyright: ignore [reportWildcardImportFromLibrary]

UnevaluatedItems: typing_extensions.TypeAlias = schemas.StrSchema


@dataclasses.dataclass(frozen=True)
class AnyTypeUnevaluatedItemsString(
schemas.AnyTypeSchema[schemas.immutabledict[str, schemas.OUTPUT_BASE_TYPES], typing.Tuple[schemas.OUTPUT_BASE_TYPES, ...]],
):
"""NOTE: This class is auto generated by OpenAPI JSON Schema Generator.
Ref: https://github.com/openapi-json-schema-tools/openapi-json-schema-generator

Do not edit the class manually.
"""
# any type
unevaluated_items: typing.Type[UnevaluatedItems] = dataclasses.field(default_factory=lambda: UnevaluatedItems) # type: ignore

Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# coding: utf-8

"""
Example
No description provided (generated by Openapi JSON Schema Generator https://github.com/openapi-json-schema-tools/openapi-json-schema-generator) # noqa: E501
The version of the OpenAPI document: 1.0.0
Generated by: https://github.com/openapi-json-schema-tools/openapi-json-schema-generator
"""

from __future__ import annotations
from json_schema_api.shared_imports.schema_imports import * # pyright: ignore [reportWildcardImportFromLibrary]

UnevaluatedItems: typing_extensions.TypeAlias = schemas.AnyTypeSchema


@dataclasses.dataclass(frozen=True)
class AnyTypeUnevaluatedItemsTrue(
schemas.AnyTypeSchema[schemas.immutabledict[str, schemas.OUTPUT_BASE_TYPES], typing.Tuple[schemas.OUTPUT_BASE_TYPES, ...]],
):
"""NOTE: This class is auto generated by OpenAPI JSON Schema Generator.
Ref: https://github.com/openapi-json-schema-tools/openapi-json-schema-generator

Do not edit the class manually.
"""
# any type
unevaluated_items: typing.Type[UnevaluatedItems] = dataclasses.field(default_factory=lambda: UnevaluatedItems) # type: ignore

Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
from json_schema_api.components.schema.any_type_pattern_properties import AnyTypePatternProperties
from json_schema_api.components.schema.any_type_prefix_items import AnyTypePrefixItems
from json_schema_api.components.schema.any_type_property_names import AnyTypePropertyNames
from json_schema_api.components.schema.any_type_unevaluated_items_false import AnyTypeUnevaluatedItemsFalse
from json_schema_api.components.schema.any_type_unevaluated_items_false_with_prefix_items import AnyTypeUnevaluatedItemsFalseWithPrefixItems
from json_schema_api.components.schema.any_type_unevaluated_items_string import AnyTypeUnevaluatedItemsString
from json_schema_api.components.schema.any_type_unevaluated_items_true import AnyTypeUnevaluatedItemsTrue
from json_schema_api.components.schema.array_contains_value import ArrayContainsValue
from json_schema_api.components.schema.array_max_contains_value import ArrayMaxContainsValue
from json_schema_api.components.schema.array_min_contains_value import ArrayMinContainsValue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@
'property_names': 'propertyNames',
'required': 'required',
'types': 'type',
'unique_items': 'uniqueItems'
'unique_items': 'uniqueItems',
'unevaluated_items': 'unevaluatedItems'
}

class SchemaConfiguration:
Expand Down
Loading