[python-experimental] turns on allOf unit test cases (#12826)

* Spec regenerated with only allOf on

Sample regnerated

Fixes a bug where AnyType composed schemas omitted validations, Fixes a bug where properties in AnyType schemas were omitted, Stops storing multipleOf value in a list

Adds required variable info to AnyType classes

Samples regenerated

Turns all unit tests back on

* Samples regenerated

* Docs and models regenerated
This commit is contained in:
Justin Black
2022-07-13 19:27:55 -07:00
committed by GitHub
parent c44fe8a04a
commit 01afbaecd8
45 changed files with 2162 additions and 82 deletions

View File

@@ -5445,10 +5445,12 @@ public class DefaultCodegen implements CodegenConfig {
final CodegenProperty cp = fromProperty(key, prop, mandatory.contains(key));
vars.add(cp);
m.setHasVars(true);
if (cp.required) {
m.setHasRequired(true);
m.getRequiredVars().add(cp);
}
if (cm == null) {
continue;
}

View File

@@ -498,13 +498,15 @@ public class PythonExperimentalClientCodegen extends AbstractPythonCodegen {
@Override
protected void addVarsRequiredVarsAdditionalProps(Schema schema, IJsonSchemaValidationProperties property){
setAddProps(schema, property);
if (schema instanceof ComposedSchema && supportsAdditionalPropertiesWithComposedSchema) {
// if schema has properties outside of allOf/oneOf/anyOf also add them
ComposedSchema cs = (ComposedSchema) schema;
if (ModelUtils.isAnyType(schema) && supportsAdditionalPropertiesWithComposedSchema) {
// if anyType schema has properties then add them
if (schema.getProperties() != null && !schema.getProperties().isEmpty()) {
if (cs.getOneOf() != null && !cs.getOneOf().isEmpty()) {
LOGGER.warn("'oneOf' is intended to include only the additional optional OAS extension discriminator object. " +
"For more details, see https://json-schema.org/draft/2019-09/json-schema-core.html#rfc.section.9.2.1.3 and the OAS section on 'Composition and Inheritance'.");
if (schema instanceof ComposedSchema) {
ComposedSchema cs = (ComposedSchema) schema;
if (cs.getOneOf() != null && !cs.getOneOf().isEmpty()) {
LOGGER.warn("'oneOf' is intended to include only the additional optional OAS extension discriminator object. " +
"For more details, see https://json-schema.org/draft/2019-09/json-schema-core.html#rfc.section.9.2.1.3 and the OAS section on 'Composition and Inheritance'.");
}
}
HashSet<String> requiredVars = new HashSet<>();
if (schema.getRequired() != null) {
@@ -2031,27 +2033,19 @@ public class PythonExperimentalClientCodegen extends AbstractPythonCodegen {
if (schema.getAdditionalProperties() == null) {
if (!disallowAdditionalPropertiesIfNotPresent) {
isAdditionalPropertiesTrue = true;
// pass in the hashCode as the name to ensure that the returned property is not from the cache
// if we need to set indent on every one, then they need to be different
addPropProp = fromProperty(String.valueOf(property.hashCode()), new Schema(), false);
addPropProp.name = "";
addPropProp.baseName = "";
addPropProp = fromProperty("", new Schema());
addPropProp.nameInSnakeCase = null;
additionalPropertiesIsAnyType = true;
}
} else if (schema.getAdditionalProperties() instanceof Boolean) {
if (Boolean.TRUE.equals(schema.getAdditionalProperties())) {
isAdditionalPropertiesTrue = true;
addPropProp = fromProperty(String.valueOf(property.hashCode()), new Schema(), false);
addPropProp.name = "";
addPropProp.baseName = "";
addPropProp = fromProperty("", new Schema());
addPropProp.nameInSnakeCase = null;
additionalPropertiesIsAnyType = true;
}
} else {
addPropProp = fromProperty(String.valueOf(property.hashCode()), (Schema) schema.getAdditionalProperties(), false);
addPropProp.name = "";
addPropProp.baseName = "";
addPropProp = fromProperty("", (Schema) schema.getAdditionalProperties());
addPropProp.nameInSnakeCase = null;
if (isAnyTypeSchema((Schema) schema.getAdditionalProperties())) {
additionalPropertiesIsAnyType = true;

View File

@@ -12,43 +12,23 @@ def _composed_schemas(cls):
{{#with composedSchemas}}
{{#each allOf}}
{{#unless complexType}}
{{#unless isAnyType}}
{{> model_templates/schema }}
{{/unless}}
{{/unless}}
{{#if isAnyType}}
{{#if this.classname}}{{classname}}{{else}}{{#if nameInSnakeCase}}{{name}}{{else}}{{baseName}}{{/if}}{{/if}} = AnyTypeSchema
{{/if}}
{{/each}}
{{#each oneOf}}
{{#unless complexType}}
{{#unless isAnyType}}
{{> model_templates/schema }}
{{/unless}}
{{/unless}}
{{#if isAnyType}}
{{#if this.classname}}{{classname}}{{else}}{{#if nameInSnakeCase}}{{name}}{{else}}{{baseName}}{{/if}}{{/if}} = AnyTypeSchema
{{/if}}
{{/each}}
{{#each anyOf}}
{{#unless complexType}}
{{#unless isAnyType}}
{{> model_templates/schema }}
{{/unless}}
{{/unless}}
{{#if isAnyType}}
{{#if this.classname}}{{classname}}{{else}}{{#if nameInSnakeCase}}{{name}}{{else}}{{baseName}}{{/if}}{{/if}} = AnyTypeSchema
{{/if}}
{{/each}}
{{#with not}}
{{#unless complexType}}
{{#unless isAnyType}}
{{> model_templates/schema }}
{{/unless}}
{{/unless}}
{{#if isAnyType}}
{{#if this.classname}}{{classname}}{{else}}{{#if nameInSnakeCase}}{{name}}{{else}}{{baseName}}{{/if}}{{/if}} = AnyTypeSchema
{{/if}}
{{/with}}
{{/with}}
return {

View File

@@ -45,6 +45,6 @@ _SchemaValidator(
}],
{{/if}}
{{#if multipleOf}}
multiple_of=[{{multipleOf}}],
multiple_of={{multipleOf}},
{{/if}}
),

View File

@@ -288,18 +288,17 @@ class ValidatorBase:
if cls.__is_json_validation_enabled('multipleOf',
validation_metadata.configuration) and 'multiple_of' in validations:
multiple_of_values = validations['multiple_of']
for multiple_of_value in multiple_of_values:
if (isinstance(input_values, decimal.Decimal) and
not (float(input_values) / multiple_of_value).is_integer()
):
# Note 'multipleOf' will be as good as the floating point arithmetic.
cls.__raise_validation_error_message(
value=input_values,
constraint_msg="value must be a multiple of",
constraint_value=multiple_of_value,
path_to_item=validation_metadata.path_to_item
)
multiple_of_value = validations['multiple_of']
if (isinstance(input_values, decimal.Decimal) and
not (float(input_values) / multiple_of_value).is_integer()
):
# Note 'multipleOf' will be as good as the floating point arithmetic.
cls.__raise_validation_error_message(
value=input_values,
constraint_msg="value must be a multiple of",
constraint_value=multiple_of_value,
path_to_item=validation_metadata.path_to_item
)
checking_max_or_min_values = {'exclusive_maximum', 'inclusive_maximum', 'exclusive_minimum',
'inclusive_minimum'}.isdisjoint(validations) is False

View File

@@ -26,6 +26,65 @@ components:
foo: {}
additionalProperties:
type: boolean
Allof:
allOf:
- properties:
bar:
type: integer
required:
- bar
- properties:
foo:
type: string
required:
- foo
AllofWithBaseSchema:
properties:
bar:
type: integer
required:
- bar
allOf:
- properties:
foo:
type: string
required:
- foo
- properties:
baz:
type: 'null'
required:
- baz
AllofSimpleTypes:
allOf:
- maximum: 30
- minimum: 20
AllofWithOneEmptySchema:
allOf:
- {}
AllofWithTwoEmptySchemas:
allOf:
- {}
- {}
AllofWithTheFirstEmptySchema:
allOf:
- {}
- type: number
AllofWithTheLastEmptySchema:
allOf:
- type: number
- {}
NestedAllofToCheckValidationSemantics:
allOf:
- allOf:
- type: 'null'
AllofCombinedWithAnyofOneof:
allOf:
- multipleOf: 2
anyOf:
- multipleOf: 3
oneOf:
- multipleOf: 5
InvalidStringValueForDefault:
properties:
bar:
@@ -276,6 +335,139 @@ components:
foo: 1
bar: true
valid: false
Allof:
Allof:
description: allOf
data:
foo: baz
bar: 2
valid: true
MismatchSecond:
description: mismatch second
data:
foo: baz
valid: false
MismatchFirst:
description: mismatch first
data:
bar: 2
valid: false
WrongType:
description: wrong type
data:
foo: baz
bar: quux
valid: false
AllofWithBaseSchema:
Valid:
description: valid
data:
foo: quux
bar: 2
baz: null
valid: true
MismatchBaseSchema:
description: mismatch base schema
data:
foo: quux
baz: null
valid: false
MismatchFirstAllof:
description: mismatch first allOf
data:
bar: 2
baz: null
valid: false
MismatchSecondAllof:
description: mismatch second allOf
data:
foo: quux
bar: 2
valid: false
MismatchBoth:
description: mismatch both
data:
bar: 2
valid: false
AllofSimpleTypes:
Valid:
description: valid
data: 25
valid: true
MismatchOne:
description: mismatch one
data: 35
valid: false
AllofWithOneEmptySchema:
AnyDataIsValid:
description: any data is valid
data: 1
valid: true
AllofWithTwoEmptySchemas:
AnyDataIsValid:
description: any data is valid
data: 1
valid: true
AllofWithTheFirstEmptySchema:
NumberIsValid:
description: number is valid
data: 1
valid: true
StringIsInvalid:
description: string is invalid
data: foo
valid: false
AllofWithTheLastEmptySchema:
NumberIsValid:
description: number is valid
data: 1
valid: true
StringIsInvalid:
description: string is invalid
data: foo
valid: false
NestedAllofToCheckValidationSemantics:
NullIsValid:
description: null is valid
data: null
valid: true
AnythingNonNullIsInvalid:
description: anything non-null is invalid
data: 123
valid: false
AllofCombinedWithAnyofOneof:
AllofFalseAnyofFalseOneofFalse:
description: 'allOf: false, anyOf: false, oneOf: false'
data: 1
valid: false
AllofFalseAnyofFalseOneofTrue:
description: 'allOf: false, anyOf: false, oneOf: true'
data: 5
valid: false
AllofFalseAnyofTrueOneofFalse:
description: 'allOf: false, anyOf: true, oneOf: false'
data: 3
valid: false
AllofFalseAnyofTrueOneofTrue:
description: 'allOf: false, anyOf: true, oneOf: true'
data: 15
valid: false
AllofTrueAnyofFalseOneofFalse:
description: 'allOf: true, anyOf: false, oneOf: false'
data: 2
valid: false
AllofTrueAnyofFalseOneofTrue:
description: 'allOf: true, anyOf: false, oneOf: true'
data: 10
valid: false
AllofTrueAnyofTrueOneofFalse:
description: 'allOf: true, anyOf: true, oneOf: false'
data: 6
valid: false
AllofTrueAnyofTrueOneofTrue:
description: 'allOf: true, anyOf: true, oneOf: true'
data: 30
valid: true
InvalidStringValueForDefault:
ValidWhenPropertyIsSpecified:
description: valid when property is specified

View File

@@ -108,6 +108,11 @@ json_schema_test_draft = 'draft6'
openapi_additions = 'openapi_additions'
FILEPATH_TO_EXCLUDED_CASE_AND_REASON = {
(json_schema_test_draft, 'allOf.json'): {
'allOf with boolean schemas, all true': ExclusionReason.v303_does_not_support_boolean_schemas_in_location,
'allOf with boolean schemas, some false': ExclusionReason.v303_does_not_support_boolean_schemas_in_location,
'allOf with boolean schemas, all false': ExclusionReason.v303_does_not_support_boolean_schemas_in_location,
},
(json_schema_test_draft, 'default.json'): {
'invalid type for default': ExclusionReason.v303_requires_that_the_default_value_is_an_allowed_type,
},
@@ -213,7 +218,7 @@ FILEPATH_TO_EXCLUDE_REASON = {
JSON_SCHEMA_TEST_FILE_TO_FOLDERS = {
'additionalItems.json': (json_schema_test_draft,),
'additionalProperties.json': (json_schema_test_draft,),
# 'allOf.json': (json_schema_test_draft,), # activate later after fixing composition processing
'allOf.json': (json_schema_test_draft,), # activate later after fixing composition processing
# 'anyOf.json': (json_schema_test_draft,), # activate later after fixing composition processing
'boolean_schema.json': (json_schema_test_draft,),
'const.json': (json_schema_test_draft,),

View File

@@ -6,6 +6,14 @@ docs/AdditionalpropertiesAllowsASchemaWhichShouldValidate.md
docs/AdditionalpropertiesAreAllowedByDefault.md
docs/AdditionalpropertiesCanExistByItself.md
docs/AdditionalpropertiesShouldNotLookInApplicators.md
docs/Allof.md
docs/AllofCombinedWithAnyofOneof.md
docs/AllofSimpleTypes.md
docs/AllofWithBaseSchema.md
docs/AllofWithOneEmptySchema.md
docs/AllofWithTheFirstEmptySchema.md
docs/AllofWithTheLastEmptySchema.md
docs/AllofWithTwoEmptySchemas.md
docs/ArrayTypeMatchesArrays.md
docs/BooleanTypeMatchesBooleans.md
docs/ByInt.md
@@ -39,6 +47,7 @@ docs/MinitemsValidation.md
docs/MinlengthValidation.md
docs/MinpropertiesValidation.md
docs/ModelNot.md
docs/NestedAllofToCheckValidationSemantics.md
docs/NestedItems.md
docs/NotMoreComplexSchema.md
docs/NulCharactersInStrings.md
@@ -76,6 +85,14 @@ test/test_additionalproperties_allows_a_schema_which_should_validate.py
test/test_additionalproperties_are_allowed_by_default.py
test/test_additionalproperties_can_exist_by_itself.py
test/test_additionalproperties_should_not_look_in_applicators.py
test/test_allof.py
test/test_allof_combined_with_anyof_oneof.py
test/test_allof_simple_types.py
test/test_allof_with_base_schema.py
test/test_allof_with_one_empty_schema.py
test/test_allof_with_the_first_empty_schema.py
test/test_allof_with_the_last_empty_schema.py
test/test_allof_with_two_empty_schemas.py
test/test_array_type_matches_arrays.py
test/test_boolean_type_matches_booleans.py
test/test_by_int.py
@@ -109,6 +126,7 @@ test/test_minitems_validation.py
test/test_minlength_validation.py
test/test_minproperties_validation.py
test/test_model_not.py
test/test_nested_allof_to_check_validation_semantics.py
test/test_nested_items.py
test/test_not_more_complex_schema.py
test/test_nul_characters_in_strings.py
@@ -148,6 +166,14 @@ unit_test_api/model/additionalproperties_allows_a_schema_which_should_validate.p
unit_test_api/model/additionalproperties_are_allowed_by_default.py
unit_test_api/model/additionalproperties_can_exist_by_itself.py
unit_test_api/model/additionalproperties_should_not_look_in_applicators.py
unit_test_api/model/allof.py
unit_test_api/model/allof_combined_with_anyof_oneof.py
unit_test_api/model/allof_simple_types.py
unit_test_api/model/allof_with_base_schema.py
unit_test_api/model/allof_with_one_empty_schema.py
unit_test_api/model/allof_with_the_first_empty_schema.py
unit_test_api/model/allof_with_the_last_empty_schema.py
unit_test_api/model/allof_with_two_empty_schemas.py
unit_test_api/model/array_type_matches_arrays.py
unit_test_api/model/boolean_type_matches_booleans.py
unit_test_api/model/by_int.py
@@ -181,6 +207,7 @@ unit_test_api/model/minitems_validation.py
unit_test_api/model/minlength_validation.py
unit_test_api/model/minproperties_validation.py
unit_test_api/model/model_not.py
unit_test_api/model/nested_allof_to_check_validation_semantics.py
unit_test_api/model/nested_items.py
unit_test_api/model/not_more_complex_schema.py
unit_test_api/model/nul_characters_in_strings.py

View File

@@ -66,6 +66,14 @@ Class | Method | HTTP request | Description
- [AdditionalpropertiesAreAllowedByDefault](docs/AdditionalpropertiesAreAllowedByDefault.md)
- [AdditionalpropertiesCanExistByItself](docs/AdditionalpropertiesCanExistByItself.md)
- [AdditionalpropertiesShouldNotLookInApplicators](docs/AdditionalpropertiesShouldNotLookInApplicators.md)
- [Allof](docs/Allof.md)
- [AllofCombinedWithAnyofOneof](docs/AllofCombinedWithAnyofOneof.md)
- [AllofSimpleTypes](docs/AllofSimpleTypes.md)
- [AllofWithBaseSchema](docs/AllofWithBaseSchema.md)
- [AllofWithOneEmptySchema](docs/AllofWithOneEmptySchema.md)
- [AllofWithTheFirstEmptySchema](docs/AllofWithTheFirstEmptySchema.md)
- [AllofWithTheLastEmptySchema](docs/AllofWithTheLastEmptySchema.md)
- [AllofWithTwoEmptySchemas](docs/AllofWithTwoEmptySchemas.md)
- [ArrayTypeMatchesArrays](docs/ArrayTypeMatchesArrays.md)
- [BooleanTypeMatchesBooleans](docs/BooleanTypeMatchesBooleans.md)
- [ByInt](docs/ByInt.md)
@@ -99,6 +107,7 @@ Class | Method | HTTP request | Description
- [MinlengthValidation](docs/MinlengthValidation.md)
- [MinpropertiesValidation](docs/MinpropertiesValidation.md)
- [ModelNot](docs/ModelNot.md)
- [NestedAllofToCheckValidationSemantics](docs/NestedAllofToCheckValidationSemantics.md)
- [NestedItems](docs/NestedItems.md)
- [NotMoreComplexSchema](docs/NotMoreComplexSchema.md)
- [NulCharactersInStrings](docs/NulCharactersInStrings.md)

View File

@@ -0,0 +1,9 @@
# Allof
#### Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional]
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@@ -0,0 +1,9 @@
# AllofCombinedWithAnyofOneof
#### Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional]
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@@ -0,0 +1,9 @@
# AllofSimpleTypes
#### Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional]
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@@ -0,0 +1,10 @@
# AllofWithBaseSchema
#### Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**bar** | **int** | |
**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional]
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@@ -0,0 +1,9 @@
# AllofWithOneEmptySchema
#### Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional]
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@@ -0,0 +1,9 @@
# AllofWithTheFirstEmptySchema
#### Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional]
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@@ -0,0 +1,9 @@
# AllofWithTheLastEmptySchema
#### Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional]
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@@ -0,0 +1,9 @@
# AllofWithTwoEmptySchemas
#### Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional]
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@@ -0,0 +1,9 @@
# NestedAllofToCheckValidationSemantics
#### Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional]
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@@ -0,0 +1,72 @@
# coding: utf-8
"""
openapi 3.0.3 sample spec
sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501
The version of the OpenAPI document: 0.0.1
Generated by: https://openapi-generator.tech
"""
import unittest
import unit_test_api
from unit_test_api.model.allof import Allof
from unit_test_api import configuration
class TestAllof(unittest.TestCase):
"""Allof unit test stubs"""
_configuration = configuration.Configuration()
def test_allof_passes(self):
# allOf
Allof._from_openapi_data(
{
"foo":
"baz",
"bar":
2,
},
_configuration=self._configuration
)
def test_mismatch_first_fails(self):
# mismatch first
with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)):
Allof._from_openapi_data(
{
"bar":
2,
},
_configuration=self._configuration
)
def test_mismatch_second_fails(self):
# mismatch second
with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)):
Allof._from_openapi_data(
{
"foo":
"baz",
},
_configuration=self._configuration
)
def test_wrong_type_fails(self):
# wrong type
with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)):
Allof._from_openapi_data(
{
"foo":
"baz",
"bar":
"quux",
},
_configuration=self._configuration
)
if __name__ == '__main__':
unittest.main()

View File

@@ -0,0 +1,88 @@
# coding: utf-8
"""
openapi 3.0.3 sample spec
sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501
The version of the OpenAPI document: 0.0.1
Generated by: https://openapi-generator.tech
"""
import unittest
import unit_test_api
from unit_test_api.model.allof_combined_with_anyof_oneof import AllofCombinedWithAnyofOneof
from unit_test_api import configuration
class TestAllofCombinedWithAnyofOneof(unittest.TestCase):
"""AllofCombinedWithAnyofOneof unit test stubs"""
_configuration = configuration.Configuration()
def test_allof_true_anyof_false_oneof_false_fails(self):
# allOf: true, anyOf: false, oneOf: false
with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)):
AllofCombinedWithAnyofOneof._from_openapi_data(
2,
_configuration=self._configuration
)
def test_allof_false_anyof_false_oneof_true_fails(self):
# allOf: false, anyOf: false, oneOf: true
with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)):
AllofCombinedWithAnyofOneof._from_openapi_data(
5,
_configuration=self._configuration
)
def test_allof_false_anyof_true_oneof_true_fails(self):
# allOf: false, anyOf: true, oneOf: true
with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)):
AllofCombinedWithAnyofOneof._from_openapi_data(
15,
_configuration=self._configuration
)
def test_allof_true_anyof_true_oneof_false_fails(self):
# allOf: true, anyOf: true, oneOf: false
with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)):
AllofCombinedWithAnyofOneof._from_openapi_data(
6,
_configuration=self._configuration
)
def test_allof_true_anyof_true_oneof_true_passes(self):
# allOf: true, anyOf: true, oneOf: true
AllofCombinedWithAnyofOneof._from_openapi_data(
30,
_configuration=self._configuration
)
def test_allof_true_anyof_false_oneof_true_fails(self):
# allOf: true, anyOf: false, oneOf: true
with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)):
AllofCombinedWithAnyofOneof._from_openapi_data(
10,
_configuration=self._configuration
)
def test_allof_false_anyof_true_oneof_false_fails(self):
# allOf: false, anyOf: true, oneOf: false
with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)):
AllofCombinedWithAnyofOneof._from_openapi_data(
3,
_configuration=self._configuration
)
def test_allof_false_anyof_false_oneof_false_fails(self):
# allOf: false, anyOf: false, oneOf: false
with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)):
AllofCombinedWithAnyofOneof._from_openapi_data(
1,
_configuration=self._configuration
)
if __name__ == '__main__':
unittest.main()

View File

@@ -0,0 +1,40 @@
# coding: utf-8
"""
openapi 3.0.3 sample spec
sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501
The version of the OpenAPI document: 0.0.1
Generated by: https://openapi-generator.tech
"""
import unittest
import unit_test_api
from unit_test_api.model.allof_simple_types import AllofSimpleTypes
from unit_test_api import configuration
class TestAllofSimpleTypes(unittest.TestCase):
"""AllofSimpleTypes unit test stubs"""
_configuration = configuration.Configuration()
def test_valid_passes(self):
# valid
AllofSimpleTypes._from_openapi_data(
25,
_configuration=self._configuration
)
def test_mismatch_one_fails(self):
# mismatch one
with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)):
AllofSimpleTypes._from_openapi_data(
35,
_configuration=self._configuration
)
if __name__ == '__main__':
unittest.main()

View File

@@ -0,0 +1,89 @@
# coding: utf-8
"""
openapi 3.0.3 sample spec
sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501
The version of the OpenAPI document: 0.0.1
Generated by: https://openapi-generator.tech
"""
import unittest
import unit_test_api
from unit_test_api.model.allof_with_base_schema import AllofWithBaseSchema
from unit_test_api import configuration
class TestAllofWithBaseSchema(unittest.TestCase):
"""AllofWithBaseSchema unit test stubs"""
_configuration = configuration.Configuration()
def test_valid_passes(self):
# valid
AllofWithBaseSchema._from_openapi_data(
{
"foo":
"quux",
"bar":
2,
"baz":
None,
},
_configuration=self._configuration
)
def test_mismatch_first_allof_fails(self):
# mismatch first allOf
with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)):
AllofWithBaseSchema._from_openapi_data(
{
"bar":
2,
"baz":
None,
},
_configuration=self._configuration
)
def test_mismatch_base_schema_fails(self):
# mismatch base schema
with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)):
AllofWithBaseSchema._from_openapi_data(
{
"foo":
"quux",
"baz":
None,
},
_configuration=self._configuration
)
def test_mismatch_both_fails(self):
# mismatch both
with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)):
AllofWithBaseSchema._from_openapi_data(
{
"bar":
2,
},
_configuration=self._configuration
)
def test_mismatch_second_allof_fails(self):
# mismatch second allOf
with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)):
AllofWithBaseSchema._from_openapi_data(
{
"foo":
"quux",
"bar":
2,
},
_configuration=self._configuration
)
if __name__ == '__main__':
unittest.main()

View File

@@ -0,0 +1,32 @@
# coding: utf-8
"""
openapi 3.0.3 sample spec
sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501
The version of the OpenAPI document: 0.0.1
Generated by: https://openapi-generator.tech
"""
import unittest
import unit_test_api
from unit_test_api.model.allof_with_one_empty_schema import AllofWithOneEmptySchema
from unit_test_api import configuration
class TestAllofWithOneEmptySchema(unittest.TestCase):
"""AllofWithOneEmptySchema unit test stubs"""
_configuration = configuration.Configuration()
def test_any_data_is_valid_passes(self):
# any data is valid
AllofWithOneEmptySchema._from_openapi_data(
1,
_configuration=self._configuration
)
if __name__ == '__main__':
unittest.main()

View File

@@ -0,0 +1,40 @@
# coding: utf-8
"""
openapi 3.0.3 sample spec
sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501
The version of the OpenAPI document: 0.0.1
Generated by: https://openapi-generator.tech
"""
import unittest
import unit_test_api
from unit_test_api.model.allof_with_the_first_empty_schema import AllofWithTheFirstEmptySchema
from unit_test_api import configuration
class TestAllofWithTheFirstEmptySchema(unittest.TestCase):
"""AllofWithTheFirstEmptySchema unit test stubs"""
_configuration = configuration.Configuration()
def test_string_is_invalid_fails(self):
# string is invalid
with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)):
AllofWithTheFirstEmptySchema._from_openapi_data(
"foo",
_configuration=self._configuration
)
def test_number_is_valid_passes(self):
# number is valid
AllofWithTheFirstEmptySchema._from_openapi_data(
1,
_configuration=self._configuration
)
if __name__ == '__main__':
unittest.main()

View File

@@ -0,0 +1,40 @@
# coding: utf-8
"""
openapi 3.0.3 sample spec
sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501
The version of the OpenAPI document: 0.0.1
Generated by: https://openapi-generator.tech
"""
import unittest
import unit_test_api
from unit_test_api.model.allof_with_the_last_empty_schema import AllofWithTheLastEmptySchema
from unit_test_api import configuration
class TestAllofWithTheLastEmptySchema(unittest.TestCase):
"""AllofWithTheLastEmptySchema unit test stubs"""
_configuration = configuration.Configuration()
def test_string_is_invalid_fails(self):
# string is invalid
with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)):
AllofWithTheLastEmptySchema._from_openapi_data(
"foo",
_configuration=self._configuration
)
def test_number_is_valid_passes(self):
# number is valid
AllofWithTheLastEmptySchema._from_openapi_data(
1,
_configuration=self._configuration
)
if __name__ == '__main__':
unittest.main()

View File

@@ -0,0 +1,32 @@
# coding: utf-8
"""
openapi 3.0.3 sample spec
sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501
The version of the OpenAPI document: 0.0.1
Generated by: https://openapi-generator.tech
"""
import unittest
import unit_test_api
from unit_test_api.model.allof_with_two_empty_schemas import AllofWithTwoEmptySchemas
from unit_test_api import configuration
class TestAllofWithTwoEmptySchemas(unittest.TestCase):
"""AllofWithTwoEmptySchemas unit test stubs"""
_configuration = configuration.Configuration()
def test_any_data_is_valid_passes(self):
# any data is valid
AllofWithTwoEmptySchemas._from_openapi_data(
1,
_configuration=self._configuration
)
if __name__ == '__main__':
unittest.main()

View File

@@ -0,0 +1,40 @@
# coding: utf-8
"""
openapi 3.0.3 sample spec
sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501
The version of the OpenAPI document: 0.0.1
Generated by: https://openapi-generator.tech
"""
import unittest
import unit_test_api
from unit_test_api.model.nested_allof_to_check_validation_semantics import NestedAllofToCheckValidationSemantics
from unit_test_api import configuration
class TestNestedAllofToCheckValidationSemantics(unittest.TestCase):
"""NestedAllofToCheckValidationSemantics unit test stubs"""
_configuration = configuration.Configuration()
def test_anything_non_null_is_invalid_fails(self):
# anything non-null is invalid
with self.assertRaises((unit_test_api.ApiValueError, unit_test_api.ApiTypeError)):
NestedAllofToCheckValidationSemantics._from_openapi_data(
123,
_configuration=self._configuration
)
def test_null_is_valid_passes(self):
# null is valid
NestedAllofToCheckValidationSemantics._from_openapi_data(
None,
_configuration=self._configuration
)
if __name__ == '__main__':
unittest.main()

View File

@@ -89,7 +89,27 @@ class AdditionalpropertiesShouldNotLookInApplicators(
# code would be run when this module is imported, and these composed
# classes don't exist yet because their module has not finished
# loading
allOf_0 = AnyTypeSchema
class allOf_0(
AnyTypeSchema
):
foo = AnyTypeSchema
def __new__(
cls,
*args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes],
foo: typing.Union[foo, Unset] = unset,
_configuration: typing.Optional[Configuration] = None,
**kwargs: typing.Type[Schema],
) -> 'allOf_0':
return super().__new__(
cls,
*args,
foo=foo,
_configuration=_configuration,
**kwargs,
)
return {
'allOf': [
allOf_0,

View File

@@ -0,0 +1,163 @@
# coding: utf-8
"""
openapi 3.0.3 sample spec
sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501
The version of the OpenAPI document: 0.0.1
Generated by: https://openapi-generator.tech
"""
import re # noqa: F401
import sys # noqa: F401
import typing # noqa: F401
import functools # noqa: F401
from frozendict import frozendict # noqa: F401
import decimal # noqa: F401
from datetime import date, datetime # noqa: F401
from frozendict import frozendict # noqa: F401
from unit_test_api.schemas import ( # noqa: F401
AnyTypeSchema,
ComposedSchema,
DictSchema,
ListSchema,
StrSchema,
IntSchema,
Int32Schema,
Int64Schema,
Float32Schema,
Float64Schema,
NumberSchema,
UUIDSchema,
DateSchema,
DateTimeSchema,
DecimalSchema,
BoolSchema,
BinarySchema,
NoneSchema,
none_type,
Configuration,
Unset,
unset,
ComposedBase,
ListBase,
DictBase,
NoneBase,
StrBase,
IntBase,
Int32Base,
Int64Base,
Float32Base,
Float64Base,
NumberBase,
UUIDBase,
DateBase,
DateTimeBase,
BoolBase,
BinaryBase,
Schema,
NoneClass,
BoolClass,
_SchemaValidator,
_SchemaTypeChecker,
_SchemaEnumMaker
)
class Allof(
ComposedSchema
):
"""NOTE: This class is auto generated by OpenAPI Generator.
Ref: https://openapi-generator.tech
Do not edit the class manually.
"""
@classmethod
@property
@functools.cache
def _composed_schemas(cls):
# we need this here to make our import statements work
# we must store _composed_schemas in here so the code is only run
# when we invoke this method. If we kept this at the class
# level we would get an error because the class level
# code would be run when this module is imported, and these composed
# classes don't exist yet because their module has not finished
# loading
class allOf_0(
AnyTypeSchema
):
_required_property_names = set((
'bar',
))
bar = IntSchema
def __new__(
cls,
*args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes],
bar: bar,
_configuration: typing.Optional[Configuration] = None,
**kwargs: typing.Type[Schema],
) -> 'allOf_0':
return super().__new__(
cls,
*args,
bar=bar,
_configuration=_configuration,
**kwargs,
)
class allOf_1(
AnyTypeSchema
):
_required_property_names = set((
'foo',
))
foo = StrSchema
def __new__(
cls,
*args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes],
foo: foo,
_configuration: typing.Optional[Configuration] = None,
**kwargs: typing.Type[Schema],
) -> 'allOf_1':
return super().__new__(
cls,
*args,
foo=foo,
_configuration=_configuration,
**kwargs,
)
return {
'allOf': [
allOf_0,
allOf_1,
],
'oneOf': [
],
'anyOf': [
],
'not':
None
}
def __new__(
cls,
*args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes],
_configuration: typing.Optional[Configuration] = None,
**kwargs: typing.Type[Schema],
) -> 'Allof':
return super().__new__(
cls,
*args,
_configuration=_configuration,
**kwargs,
)

View File

@@ -0,0 +1,179 @@
# coding: utf-8
"""
openapi 3.0.3 sample spec
sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501
The version of the OpenAPI document: 0.0.1
Generated by: https://openapi-generator.tech
"""
import re # noqa: F401
import sys # noqa: F401
import typing # noqa: F401
import functools # noqa: F401
from frozendict import frozendict # noqa: F401
import decimal # noqa: F401
from datetime import date, datetime # noqa: F401
from frozendict import frozendict # noqa: F401
from unit_test_api.schemas import ( # noqa: F401
AnyTypeSchema,
ComposedSchema,
DictSchema,
ListSchema,
StrSchema,
IntSchema,
Int32Schema,
Int64Schema,
Float32Schema,
Float64Schema,
NumberSchema,
UUIDSchema,
DateSchema,
DateTimeSchema,
DecimalSchema,
BoolSchema,
BinarySchema,
NoneSchema,
none_type,
Configuration,
Unset,
unset,
ComposedBase,
ListBase,
DictBase,
NoneBase,
StrBase,
IntBase,
Int32Base,
Int64Base,
Float32Base,
Float64Base,
NumberBase,
UUIDBase,
DateBase,
DateTimeBase,
BoolBase,
BinaryBase,
Schema,
NoneClass,
BoolClass,
_SchemaValidator,
_SchemaTypeChecker,
_SchemaEnumMaker
)
class AllofCombinedWithAnyofOneof(
ComposedSchema
):
"""NOTE: This class is auto generated by OpenAPI Generator.
Ref: https://openapi-generator.tech
Do not edit the class manually.
"""
@classmethod
@property
@functools.cache
def _composed_schemas(cls):
# we need this here to make our import statements work
# we must store _composed_schemas in here so the code is only run
# when we invoke this method. If we kept this at the class
# level we would get an error because the class level
# code would be run when this module is imported, and these composed
# classes don't exist yet because their module has not finished
# loading
class allOf_0(
_SchemaValidator(
multiple_of=2,
),
AnyTypeSchema
):
def __new__(
cls,
*args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes],
_configuration: typing.Optional[Configuration] = None,
**kwargs: typing.Type[Schema],
) -> 'allOf_0':
return super().__new__(
cls,
*args,
_configuration=_configuration,
**kwargs,
)
class oneOf_0(
_SchemaValidator(
multiple_of=5,
),
AnyTypeSchema
):
def __new__(
cls,
*args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes],
_configuration: typing.Optional[Configuration] = None,
**kwargs: typing.Type[Schema],
) -> 'oneOf_0':
return super().__new__(
cls,
*args,
_configuration=_configuration,
**kwargs,
)
class anyOf_0(
_SchemaValidator(
multiple_of=3,
),
AnyTypeSchema
):
def __new__(
cls,
*args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes],
_configuration: typing.Optional[Configuration] = None,
**kwargs: typing.Type[Schema],
) -> 'anyOf_0':
return super().__new__(
cls,
*args,
_configuration=_configuration,
**kwargs,
)
return {
'allOf': [
allOf_0,
],
'oneOf': [
oneOf_0,
],
'anyOf': [
anyOf_0,
],
'not':
None
}
def __new__(
cls,
*args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes],
_configuration: typing.Optional[Configuration] = None,
**kwargs: typing.Type[Schema],
) -> 'AllofCombinedWithAnyofOneof':
return super().__new__(
cls,
*args,
_configuration=_configuration,
**kwargs,
)

View File

@@ -0,0 +1,157 @@
# coding: utf-8
"""
openapi 3.0.3 sample spec
sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501
The version of the OpenAPI document: 0.0.1
Generated by: https://openapi-generator.tech
"""
import re # noqa: F401
import sys # noqa: F401
import typing # noqa: F401
import functools # noqa: F401
from frozendict import frozendict # noqa: F401
import decimal # noqa: F401
from datetime import date, datetime # noqa: F401
from frozendict import frozendict # noqa: F401
from unit_test_api.schemas import ( # noqa: F401
AnyTypeSchema,
ComposedSchema,
DictSchema,
ListSchema,
StrSchema,
IntSchema,
Int32Schema,
Int64Schema,
Float32Schema,
Float64Schema,
NumberSchema,
UUIDSchema,
DateSchema,
DateTimeSchema,
DecimalSchema,
BoolSchema,
BinarySchema,
NoneSchema,
none_type,
Configuration,
Unset,
unset,
ComposedBase,
ListBase,
DictBase,
NoneBase,
StrBase,
IntBase,
Int32Base,
Int64Base,
Float32Base,
Float64Base,
NumberBase,
UUIDBase,
DateBase,
DateTimeBase,
BoolBase,
BinaryBase,
Schema,
NoneClass,
BoolClass,
_SchemaValidator,
_SchemaTypeChecker,
_SchemaEnumMaker
)
class AllofSimpleTypes(
ComposedSchema
):
"""NOTE: This class is auto generated by OpenAPI Generator.
Ref: https://openapi-generator.tech
Do not edit the class manually.
"""
@classmethod
@property
@functools.cache
def _composed_schemas(cls):
# we need this here to make our import statements work
# we must store _composed_schemas in here so the code is only run
# when we invoke this method. If we kept this at the class
# level we would get an error because the class level
# code would be run when this module is imported, and these composed
# classes don't exist yet because their module has not finished
# loading
class allOf_0(
_SchemaValidator(
inclusive_maximum=30,
),
AnyTypeSchema
):
def __new__(
cls,
*args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes],
_configuration: typing.Optional[Configuration] = None,
**kwargs: typing.Type[Schema],
) -> 'allOf_0':
return super().__new__(
cls,
*args,
_configuration=_configuration,
**kwargs,
)
class allOf_1(
_SchemaValidator(
inclusive_minimum=20,
),
AnyTypeSchema
):
def __new__(
cls,
*args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes],
_configuration: typing.Optional[Configuration] = None,
**kwargs: typing.Type[Schema],
) -> 'allOf_1':
return super().__new__(
cls,
*args,
_configuration=_configuration,
**kwargs,
)
return {
'allOf': [
allOf_0,
allOf_1,
],
'oneOf': [
],
'anyOf': [
],
'not':
None
}
def __new__(
cls,
*args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes],
_configuration: typing.Optional[Configuration] = None,
**kwargs: typing.Type[Schema],
) -> 'AllofSimpleTypes':
return super().__new__(
cls,
*args,
_configuration=_configuration,
**kwargs,
)

View File

@@ -0,0 +1,169 @@
# coding: utf-8
"""
openapi 3.0.3 sample spec
sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501
The version of the OpenAPI document: 0.0.1
Generated by: https://openapi-generator.tech
"""
import re # noqa: F401
import sys # noqa: F401
import typing # noqa: F401
import functools # noqa: F401
from frozendict import frozendict # noqa: F401
import decimal # noqa: F401
from datetime import date, datetime # noqa: F401
from frozendict import frozendict # noqa: F401
from unit_test_api.schemas import ( # noqa: F401
AnyTypeSchema,
ComposedSchema,
DictSchema,
ListSchema,
StrSchema,
IntSchema,
Int32Schema,
Int64Schema,
Float32Schema,
Float64Schema,
NumberSchema,
UUIDSchema,
DateSchema,
DateTimeSchema,
DecimalSchema,
BoolSchema,
BinarySchema,
NoneSchema,
none_type,
Configuration,
Unset,
unset,
ComposedBase,
ListBase,
DictBase,
NoneBase,
StrBase,
IntBase,
Int32Base,
Int64Base,
Float32Base,
Float64Base,
NumberBase,
UUIDBase,
DateBase,
DateTimeBase,
BoolBase,
BinaryBase,
Schema,
NoneClass,
BoolClass,
_SchemaValidator,
_SchemaTypeChecker,
_SchemaEnumMaker
)
class AllofWithBaseSchema(
ComposedSchema
):
"""NOTE: This class is auto generated by OpenAPI Generator.
Ref: https://openapi-generator.tech
Do not edit the class manually.
"""
_required_property_names = set((
'bar',
))
bar = IntSchema
@classmethod
@property
@functools.cache
def _composed_schemas(cls):
# we need this here to make our import statements work
# we must store _composed_schemas in here so the code is only run
# when we invoke this method. If we kept this at the class
# level we would get an error because the class level
# code would be run when this module is imported, and these composed
# classes don't exist yet because their module has not finished
# loading
class allOf_0(
AnyTypeSchema
):
_required_property_names = set((
'foo',
))
foo = StrSchema
def __new__(
cls,
*args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes],
foo: foo,
_configuration: typing.Optional[Configuration] = None,
**kwargs: typing.Type[Schema],
) -> 'allOf_0':
return super().__new__(
cls,
*args,
foo=foo,
_configuration=_configuration,
**kwargs,
)
class allOf_1(
AnyTypeSchema
):
_required_property_names = set((
'baz',
))
baz = NoneSchema
def __new__(
cls,
*args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes],
baz: baz,
_configuration: typing.Optional[Configuration] = None,
**kwargs: typing.Type[Schema],
) -> 'allOf_1':
return super().__new__(
cls,
*args,
baz=baz,
_configuration=_configuration,
**kwargs,
)
return {
'allOf': [
allOf_0,
allOf_1,
],
'oneOf': [
],
'anyOf': [
],
'not':
None
}
def __new__(
cls,
*args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes],
bar: bar,
_configuration: typing.Optional[Configuration] = None,
**kwargs: typing.Type[Schema],
) -> 'AllofWithBaseSchema':
return super().__new__(
cls,
*args,
bar=bar,
_configuration=_configuration,
**kwargs,
)

View File

@@ -0,0 +1,115 @@
# coding: utf-8
"""
openapi 3.0.3 sample spec
sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501
The version of the OpenAPI document: 0.0.1
Generated by: https://openapi-generator.tech
"""
import re # noqa: F401
import sys # noqa: F401
import typing # noqa: F401
import functools # noqa: F401
from frozendict import frozendict # noqa: F401
import decimal # noqa: F401
from datetime import date, datetime # noqa: F401
from frozendict import frozendict # noqa: F401
from unit_test_api.schemas import ( # noqa: F401
AnyTypeSchema,
ComposedSchema,
DictSchema,
ListSchema,
StrSchema,
IntSchema,
Int32Schema,
Int64Schema,
Float32Schema,
Float64Schema,
NumberSchema,
UUIDSchema,
DateSchema,
DateTimeSchema,
DecimalSchema,
BoolSchema,
BinarySchema,
NoneSchema,
none_type,
Configuration,
Unset,
unset,
ComposedBase,
ListBase,
DictBase,
NoneBase,
StrBase,
IntBase,
Int32Base,
Int64Base,
Float32Base,
Float64Base,
NumberBase,
UUIDBase,
DateBase,
DateTimeBase,
BoolBase,
BinaryBase,
Schema,
NoneClass,
BoolClass,
_SchemaValidator,
_SchemaTypeChecker,
_SchemaEnumMaker
)
class AllofWithOneEmptySchema(
ComposedSchema
):
"""NOTE: This class is auto generated by OpenAPI Generator.
Ref: https://openapi-generator.tech
Do not edit the class manually.
"""
@classmethod
@property
@functools.cache
def _composed_schemas(cls):
# we need this here to make our import statements work
# we must store _composed_schemas in here so the code is only run
# when we invoke this method. If we kept this at the class
# level we would get an error because the class level
# code would be run when this module is imported, and these composed
# classes don't exist yet because their module has not finished
# loading
allOf_0 = AnyTypeSchema
return {
'allOf': [
allOf_0,
],
'oneOf': [
],
'anyOf': [
],
'not':
None
}
def __new__(
cls,
*args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes],
_configuration: typing.Optional[Configuration] = None,
**kwargs: typing.Type[Schema],
) -> 'AllofWithOneEmptySchema':
return super().__new__(
cls,
*args,
_configuration=_configuration,
**kwargs,
)

View File

@@ -0,0 +1,117 @@
# coding: utf-8
"""
openapi 3.0.3 sample spec
sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501
The version of the OpenAPI document: 0.0.1
Generated by: https://openapi-generator.tech
"""
import re # noqa: F401
import sys # noqa: F401
import typing # noqa: F401
import functools # noqa: F401
from frozendict import frozendict # noqa: F401
import decimal # noqa: F401
from datetime import date, datetime # noqa: F401
from frozendict import frozendict # noqa: F401
from unit_test_api.schemas import ( # noqa: F401
AnyTypeSchema,
ComposedSchema,
DictSchema,
ListSchema,
StrSchema,
IntSchema,
Int32Schema,
Int64Schema,
Float32Schema,
Float64Schema,
NumberSchema,
UUIDSchema,
DateSchema,
DateTimeSchema,
DecimalSchema,
BoolSchema,
BinarySchema,
NoneSchema,
none_type,
Configuration,
Unset,
unset,
ComposedBase,
ListBase,
DictBase,
NoneBase,
StrBase,
IntBase,
Int32Base,
Int64Base,
Float32Base,
Float64Base,
NumberBase,
UUIDBase,
DateBase,
DateTimeBase,
BoolBase,
BinaryBase,
Schema,
NoneClass,
BoolClass,
_SchemaValidator,
_SchemaTypeChecker,
_SchemaEnumMaker
)
class AllofWithTheFirstEmptySchema(
ComposedSchema
):
"""NOTE: This class is auto generated by OpenAPI Generator.
Ref: https://openapi-generator.tech
Do not edit the class manually.
"""
@classmethod
@property
@functools.cache
def _composed_schemas(cls):
# we need this here to make our import statements work
# we must store _composed_schemas in here so the code is only run
# when we invoke this method. If we kept this at the class
# level we would get an error because the class level
# code would be run when this module is imported, and these composed
# classes don't exist yet because their module has not finished
# loading
allOf_0 = AnyTypeSchema
allOf_1 = NumberSchema
return {
'allOf': [
allOf_0,
allOf_1,
],
'oneOf': [
],
'anyOf': [
],
'not':
None
}
def __new__(
cls,
*args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes],
_configuration: typing.Optional[Configuration] = None,
**kwargs: typing.Type[Schema],
) -> 'AllofWithTheFirstEmptySchema':
return super().__new__(
cls,
*args,
_configuration=_configuration,
**kwargs,
)

View File

@@ -0,0 +1,117 @@
# coding: utf-8
"""
openapi 3.0.3 sample spec
sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501
The version of the OpenAPI document: 0.0.1
Generated by: https://openapi-generator.tech
"""
import re # noqa: F401
import sys # noqa: F401
import typing # noqa: F401
import functools # noqa: F401
from frozendict import frozendict # noqa: F401
import decimal # noqa: F401
from datetime import date, datetime # noqa: F401
from frozendict import frozendict # noqa: F401
from unit_test_api.schemas import ( # noqa: F401
AnyTypeSchema,
ComposedSchema,
DictSchema,
ListSchema,
StrSchema,
IntSchema,
Int32Schema,
Int64Schema,
Float32Schema,
Float64Schema,
NumberSchema,
UUIDSchema,
DateSchema,
DateTimeSchema,
DecimalSchema,
BoolSchema,
BinarySchema,
NoneSchema,
none_type,
Configuration,
Unset,
unset,
ComposedBase,
ListBase,
DictBase,
NoneBase,
StrBase,
IntBase,
Int32Base,
Int64Base,
Float32Base,
Float64Base,
NumberBase,
UUIDBase,
DateBase,
DateTimeBase,
BoolBase,
BinaryBase,
Schema,
NoneClass,
BoolClass,
_SchemaValidator,
_SchemaTypeChecker,
_SchemaEnumMaker
)
class AllofWithTheLastEmptySchema(
ComposedSchema
):
"""NOTE: This class is auto generated by OpenAPI Generator.
Ref: https://openapi-generator.tech
Do not edit the class manually.
"""
@classmethod
@property
@functools.cache
def _composed_schemas(cls):
# we need this here to make our import statements work
# we must store _composed_schemas in here so the code is only run
# when we invoke this method. If we kept this at the class
# level we would get an error because the class level
# code would be run when this module is imported, and these composed
# classes don't exist yet because their module has not finished
# loading
allOf_0 = NumberSchema
allOf_1 = AnyTypeSchema
return {
'allOf': [
allOf_0,
allOf_1,
],
'oneOf': [
],
'anyOf': [
],
'not':
None
}
def __new__(
cls,
*args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes],
_configuration: typing.Optional[Configuration] = None,
**kwargs: typing.Type[Schema],
) -> 'AllofWithTheLastEmptySchema':
return super().__new__(
cls,
*args,
_configuration=_configuration,
**kwargs,
)

View File

@@ -0,0 +1,117 @@
# coding: utf-8
"""
openapi 3.0.3 sample spec
sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501
The version of the OpenAPI document: 0.0.1
Generated by: https://openapi-generator.tech
"""
import re # noqa: F401
import sys # noqa: F401
import typing # noqa: F401
import functools # noqa: F401
from frozendict import frozendict # noqa: F401
import decimal # noqa: F401
from datetime import date, datetime # noqa: F401
from frozendict import frozendict # noqa: F401
from unit_test_api.schemas import ( # noqa: F401
AnyTypeSchema,
ComposedSchema,
DictSchema,
ListSchema,
StrSchema,
IntSchema,
Int32Schema,
Int64Schema,
Float32Schema,
Float64Schema,
NumberSchema,
UUIDSchema,
DateSchema,
DateTimeSchema,
DecimalSchema,
BoolSchema,
BinarySchema,
NoneSchema,
none_type,
Configuration,
Unset,
unset,
ComposedBase,
ListBase,
DictBase,
NoneBase,
StrBase,
IntBase,
Int32Base,
Int64Base,
Float32Base,
Float64Base,
NumberBase,
UUIDBase,
DateBase,
DateTimeBase,
BoolBase,
BinaryBase,
Schema,
NoneClass,
BoolClass,
_SchemaValidator,
_SchemaTypeChecker,
_SchemaEnumMaker
)
class AllofWithTwoEmptySchemas(
ComposedSchema
):
"""NOTE: This class is auto generated by OpenAPI Generator.
Ref: https://openapi-generator.tech
Do not edit the class manually.
"""
@classmethod
@property
@functools.cache
def _composed_schemas(cls):
# we need this here to make our import statements work
# we must store _composed_schemas in here so the code is only run
# when we invoke this method. If we kept this at the class
# level we would get an error because the class level
# code would be run when this module is imported, and these composed
# classes don't exist yet because their module has not finished
# loading
allOf_0 = AnyTypeSchema
allOf_1 = AnyTypeSchema
return {
'allOf': [
allOf_0,
allOf_1,
],
'oneOf': [
],
'anyOf': [
],
'not':
None
}
def __new__(
cls,
*args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes],
_configuration: typing.Optional[Configuration] = None,
**kwargs: typing.Type[Schema],
) -> 'AllofWithTwoEmptySchemas':
return super().__new__(
cls,
*args,
_configuration=_configuration,
**kwargs,
)

View File

@@ -70,7 +70,7 @@ from unit_test_api.schemas import ( # noqa: F401
class ByInt(
_SchemaValidator(
multiple_of=[2],
multiple_of=2,
),
AnyTypeSchema
):

View File

@@ -70,7 +70,7 @@ from unit_test_api.schemas import ( # noqa: F401
class ByNumber(
_SchemaValidator(
multiple_of=[1.5],
multiple_of=1.5,
),
AnyTypeSchema
):

View File

@@ -70,7 +70,7 @@ from unit_test_api.schemas import ( # noqa: F401
class BySmallNumber(
_SchemaValidator(
multiple_of=[0.00010],
multiple_of=0.00010,
),
AnyTypeSchema
):

View File

@@ -70,7 +70,7 @@ from unit_test_api.schemas import ( # noqa: F401
class InvalidInstanceShouldNotRaiseErrorWhenFloatDivisionInf(
_SchemaValidator(
multiple_of=[0.123456789],
multiple_of=0.123456789,
),
IntSchema
):

View File

@@ -0,0 +1,156 @@
# coding: utf-8
"""
openapi 3.0.3 sample spec
sample spec for testing openapi functionality, built from json schema tests for draft6 # noqa: E501
The version of the OpenAPI document: 0.0.1
Generated by: https://openapi-generator.tech
"""
import re # noqa: F401
import sys # noqa: F401
import typing # noqa: F401
import functools # noqa: F401
from frozendict import frozendict # noqa: F401
import decimal # noqa: F401
from datetime import date, datetime # noqa: F401
from frozendict import frozendict # noqa: F401
from unit_test_api.schemas import ( # noqa: F401
AnyTypeSchema,
ComposedSchema,
DictSchema,
ListSchema,
StrSchema,
IntSchema,
Int32Schema,
Int64Schema,
Float32Schema,
Float64Schema,
NumberSchema,
UUIDSchema,
DateSchema,
DateTimeSchema,
DecimalSchema,
BoolSchema,
BinarySchema,
NoneSchema,
none_type,
Configuration,
Unset,
unset,
ComposedBase,
ListBase,
DictBase,
NoneBase,
StrBase,
IntBase,
Int32Base,
Int64Base,
Float32Base,
Float64Base,
NumberBase,
UUIDBase,
DateBase,
DateTimeBase,
BoolBase,
BinaryBase,
Schema,
NoneClass,
BoolClass,
_SchemaValidator,
_SchemaTypeChecker,
_SchemaEnumMaker
)
class NestedAllofToCheckValidationSemantics(
ComposedSchema
):
"""NOTE: This class is auto generated by OpenAPI Generator.
Ref: https://openapi-generator.tech
Do not edit the class manually.
"""
@classmethod
@property
@functools.cache
def _composed_schemas(cls):
# we need this here to make our import statements work
# we must store _composed_schemas in here so the code is only run
# when we invoke this method. If we kept this at the class
# level we would get an error because the class level
# code would be run when this module is imported, and these composed
# classes don't exist yet because their module has not finished
# loading
class allOf_0(
ComposedSchema
):
@classmethod
@property
@functools.cache
def _composed_schemas(cls):
# we need this here to make our import statements work
# we must store _composed_schemas in here so the code is only run
# when we invoke this method. If we kept this at the class
# level we would get an error because the class level
# code would be run when this module is imported, and these composed
# classes don't exist yet because their module has not finished
# loading
allOf_0 = NoneSchema
return {
'allOf': [
allOf_0,
],
'oneOf': [
],
'anyOf': [
],
'not':
None
}
def __new__(
cls,
*args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes],
_configuration: typing.Optional[Configuration] = None,
**kwargs: typing.Type[Schema],
) -> 'allOf_0':
return super().__new__(
cls,
*args,
_configuration=_configuration,
**kwargs,
)
return {
'allOf': [
allOf_0,
],
'oneOf': [
],
'anyOf': [
],
'not':
None
}
def __new__(
cls,
*args: typing.Union[dict, frozendict, str, date, datetime, int, float, decimal.Decimal, None, list, tuple, bytes],
_configuration: typing.Optional[Configuration] = None,
**kwargs: typing.Type[Schema],
) -> 'NestedAllofToCheckValidationSemantics':
return super().__new__(
cls,
*args,
_configuration=_configuration,
**kwargs,
)

View File

@@ -15,6 +15,14 @@ from unit_test_api.model.additionalproperties_allows_a_schema_which_should_valid
from unit_test_api.model.additionalproperties_are_allowed_by_default import AdditionalpropertiesAreAllowedByDefault
from unit_test_api.model.additionalproperties_can_exist_by_itself import AdditionalpropertiesCanExistByItself
from unit_test_api.model.additionalproperties_should_not_look_in_applicators import AdditionalpropertiesShouldNotLookInApplicators
from unit_test_api.model.allof import Allof
from unit_test_api.model.allof_combined_with_anyof_oneof import AllofCombinedWithAnyofOneof
from unit_test_api.model.allof_simple_types import AllofSimpleTypes
from unit_test_api.model.allof_with_base_schema import AllofWithBaseSchema
from unit_test_api.model.allof_with_one_empty_schema import AllofWithOneEmptySchema
from unit_test_api.model.allof_with_the_first_empty_schema import AllofWithTheFirstEmptySchema
from unit_test_api.model.allof_with_the_last_empty_schema import AllofWithTheLastEmptySchema
from unit_test_api.model.allof_with_two_empty_schemas import AllofWithTwoEmptySchemas
from unit_test_api.model.array_type_matches_arrays import ArrayTypeMatchesArrays
from unit_test_api.model.boolean_type_matches_booleans import BooleanTypeMatchesBooleans
from unit_test_api.model.by_int import ByInt
@@ -48,6 +56,7 @@ from unit_test_api.model.minitems_validation import MinitemsValidation
from unit_test_api.model.minlength_validation import MinlengthValidation
from unit_test_api.model.minproperties_validation import MinpropertiesValidation
from unit_test_api.model.model_not import ModelNot
from unit_test_api.model.nested_allof_to_check_validation_semantics import NestedAllofToCheckValidationSemantics
from unit_test_api.model.nested_items import NestedItems
from unit_test_api.model.not_more_complex_schema import NotMoreComplexSchema
from unit_test_api.model.nul_characters_in_strings import NulCharactersInStrings

View File

@@ -295,18 +295,17 @@ class ValidatorBase:
if cls.__is_json_validation_enabled('multipleOf',
validation_metadata.configuration) and 'multiple_of' in validations:
multiple_of_values = validations['multiple_of']
for multiple_of_value in multiple_of_values:
if (isinstance(input_values, decimal.Decimal) and
not (float(input_values) / multiple_of_value).is_integer()
):
# Note 'multipleOf' will be as good as the floating point arithmetic.
cls.__raise_validation_error_message(
value=input_values,
constraint_msg="value must be a multiple of",
constraint_value=multiple_of_value,
path_to_item=validation_metadata.path_to_item
)
multiple_of_value = validations['multiple_of']
if (isinstance(input_values, decimal.Decimal) and
not (float(input_values) / multiple_of_value).is_integer()
):
# Note 'multipleOf' will be as good as the floating point arithmetic.
cls.__raise_validation_error_message(
value=input_values,
constraint_msg="value must be a multiple of",
constraint_value=multiple_of_value,
path_to_item=validation_metadata.path_to_item
)
checking_max_or_min_values = {'exclusive_maximum', 'inclusive_maximum', 'exclusive_minimum',
'inclusive_minimum'}.isdisjoint(validations) is False

View File

@@ -88,7 +88,7 @@ class FormatTest(
_SchemaValidator(
inclusive_maximum=100,
inclusive_minimum=10,
multiple_of=[2],
multiple_of=2,
),
IntSchema
):
@@ -111,7 +111,7 @@ class FormatTest(
_SchemaValidator(
inclusive_maximum=543.2,
inclusive_minimum=32.1,
multiple_of=[32.5],
multiple_of=32.5,
),
NumberSchema
):

View File

@@ -295,18 +295,17 @@ class ValidatorBase:
if cls.__is_json_validation_enabled('multipleOf',
validation_metadata.configuration) and 'multiple_of' in validations:
multiple_of_values = validations['multiple_of']
for multiple_of_value in multiple_of_values:
if (isinstance(input_values, decimal.Decimal) and
not (float(input_values) / multiple_of_value).is_integer()
):
# Note 'multipleOf' will be as good as the floating point arithmetic.
cls.__raise_validation_error_message(
value=input_values,
constraint_msg="value must be a multiple of",
constraint_value=multiple_of_value,
path_to_item=validation_metadata.path_to_item
)
multiple_of_value = validations['multiple_of']
if (isinstance(input_values, decimal.Decimal) and
not (float(input_values) / multiple_of_value).is_integer()
):
# Note 'multipleOf' will be as good as the floating point arithmetic.
cls.__raise_validation_error_message(
value=input_values,
constraint_msg="value must be a multiple of",
constraint_value=multiple_of_value,
path_to_item=validation_metadata.path_to_item
)
checking_max_or_min_values = {'exclusive_maximum', 'inclusive_maximum', 'exclusive_minimum',
'inclusive_minimum'}.isdisjoint(validations) is False