[python-experimental] code quality improvements (#13221)

* Changes http to https

* Refactors method to be simpler, removes unused json encoder

* Samples regen, test fixed, consolidated redundant return

* Samples regenerated

* Updates composed model property names

* Samples regenerated using composed schema name update

* Samples regen, removed unused arg in __get_oneof_class
This commit is contained in:
Justin Black 2022-08-18 09:41:50 -07:00 committed by GitHub
parent 4916774a21
commit 3239f28e09
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
61 changed files with 617 additions and 440 deletions

View File

@ -7706,16 +7706,16 @@ public class DefaultCodegen implements CodegenConfig {
Schema notSchema = schema.getNot();
CodegenProperty notProperty = null;
if (notSchema != null) {
notProperty = fromProperty("NotSchema", notSchema, false);
notProperty = fromProperty("not_schema", notSchema, false);
}
List<CodegenProperty> allOf = new ArrayList<>();
List<CodegenProperty> oneOf = new ArrayList<>();
List<CodegenProperty> anyOf = new ArrayList<>();
if (schema instanceof ComposedSchema) {
ComposedSchema cs = (ComposedSchema) schema;
allOf = getComposedProperties(cs.getAllOf(), "allOf");
oneOf = getComposedProperties(cs.getOneOf(), "oneOf");
anyOf = getComposedProperties(cs.getAnyOf(), "anyOf");
allOf = getComposedProperties(cs.getAllOf(), "all_of");
oneOf = getComposedProperties(cs.getOneOf(), "one_of");
anyOf = getComposedProperties(cs.getAnyOf(), "any_of");
}
return new CodegenComposedSchemas(
allOf,

View File

@ -145,6 +145,84 @@ class ParameterSerializerBase:
def to_dict(name: str, value: str):
return {name: value}
@classmethod
def __ref6570_str_float_int_expansion(
cls,
variable_name: str,
in_data: typing.Any,
explode: bool,
percent_encode: bool,
prefix_separator_iterator: PrefixSeparatorIterator,
var_name_piece: str,
named_parameter_expansion: bool
) -> str:
item_value = cls.__ref6570_item_value(in_data, percent_encode)
if item_value is None or (item_value == '' and prefix_separator_iterator.separator == ';'):
return next(prefix_separator_iterator) + var_name_piece
value_pair_equals = '=' if named_parameter_expansion else ''
return next(prefix_separator_iterator) + var_name_piece + value_pair_equals + item_value
@classmethod
def __ref6570_list_expansion(
cls,
variable_name: str,
in_data: typing.Any,
explode: bool,
percent_encode: bool,
prefix_separator_iterator: PrefixSeparatorIterator,
var_name_piece: str,
named_parameter_expansion: bool
) -> str:
item_values = [cls.__ref6570_item_value(v, percent_encode) for v in in_data]
item_values = [v for v in item_values if v is not None]
if not item_values:
# ignored by the expansion process https://datatracker.ietf.org/doc/html/rfc6570#section-3.2.1
return ""
value_pair_equals = '=' if named_parameter_expansion else ''
if not explode:
return (
next(prefix_separator_iterator) +
var_name_piece +
value_pair_equals +
prefix_separator_iterator.item_separator.join(item_values)
)
# exploded
return next(prefix_separator_iterator) + next(prefix_separator_iterator).join(
[var_name_piece + value_pair_equals + val for val in item_values]
)
@classmethod
def __ref6570_dict_expansion(
cls,
variable_name: str,
in_data: typing.Any,
explode: bool,
percent_encode: bool,
prefix_separator_iterator: PrefixSeparatorIterator,
var_name_piece: str,
named_parameter_expansion: bool
) -> str:
in_data_transformed = {key: cls.__ref6570_item_value(val, percent_encode) for key, val in in_data.items()}
in_data_transformed = {key: val for key, val in in_data_transformed.items() if val is not None}
if not in_data_transformed:
# ignored by the expansion process https://datatracker.ietf.org/doc/html/rfc6570#section-3.2.1
return ""
value_pair_equals = '=' if named_parameter_expansion else ''
if not explode:
return (
next(prefix_separator_iterator) +
var_name_piece + value_pair_equals +
prefix_separator_iterator.item_separator.join(
prefix_separator_iterator.item_separator.join(
item_pair
) for item_pair in in_data_transformed.items()
)
)
# exploded
return next(prefix_separator_iterator) + next(prefix_separator_iterator).join(
[key + '=' + val for key, val in in_data_transformed.items()]
)
@classmethod
def ref6570_expansion(
cls,
@ -160,54 +238,37 @@ class ParameterSerializerBase:
named_parameter_expansion = prefix_separator_iterator.separator in {'&', ';'}
var_name_piece = variable_name if named_parameter_expansion else ''
if type(in_data) in {str, float, int}:
item_value = cls.__ref6570_item_value(in_data, percent_encode)
if item_value is None:
return next(prefix_separator_iterator) + var_name_piece
elif item_value == '' and prefix_separator_iterator.separator == ';':
return next(prefix_separator_iterator) + var_name_piece
value_pair_equals = '=' if named_parameter_expansion else ''
return next(prefix_separator_iterator) + var_name_piece + value_pair_equals + item_value
return cls.__ref6570_str_float_int_expansion(
variable_name,
in_data,
explode,
percent_encode,
prefix_separator_iterator,
var_name_piece,
named_parameter_expansion
)
elif isinstance(in_data, none_type):
# ignored by the expansion process https://datatracker.ietf.org/doc/html/rfc6570#section-3.2.1
return ""
elif isinstance(in_data, list):
item_values = [cls.__ref6570_item_value(v, percent_encode) for v in in_data]
item_values = [v for v in item_values if v is not None]
if not item_values:
# ignored by the expansion process https://datatracker.ietf.org/doc/html/rfc6570#section-3.2.1
return ""
value_pair_equals = '=' if named_parameter_expansion else ''
if not explode:
return (
next(prefix_separator_iterator) +
var_name_piece +
value_pair_equals +
prefix_separator_iterator.item_separator.join(item_values)
)
# exploded
return next(prefix_separator_iterator) + next(prefix_separator_iterator).join(
[var_name_piece + value_pair_equals + val for val in item_values]
return cls.__ref6570_list_expansion(
variable_name,
in_data,
explode,
percent_encode,
prefix_separator_iterator,
var_name_piece,
named_parameter_expansion
)
elif isinstance(in_data, dict):
in_data_transformed = {key: cls.__ref6570_item_value(val, percent_encode) for key, val in in_data.items()}
in_data_transformed = {key: val for key, val in in_data_transformed.items() if val is not None}
if not in_data_transformed:
# ignored by the expansion process https://datatracker.ietf.org/doc/html/rfc6570#section-3.2.1
return ""
value_pair_equals = '=' if named_parameter_expansion else ''
if not explode:
return (
next(prefix_separator_iterator) +
var_name_piece + value_pair_equals +
prefix_separator_iterator.item_separator.join(
prefix_separator_iterator.item_separator.join(
item_pair
) for item_pair in in_data_transformed.items()
)
)
# exploded
return next(prefix_separator_iterator) + next(prefix_separator_iterator).join(
[key + '=' + val for key, val in in_data_transformed.items()]
return cls.__ref6570_dict_expansion(
variable_name,
in_data,
explode,
percent_encode,
prefix_separator_iterator,
var_name_piece,
named_parameter_expansion
)
# bool, bytes, etc
raise ApiValueError('Unable to generate a ref6570 representation of {}'.format(in_data))
@ -903,7 +964,6 @@ class ApiClient:
"""
_pool = None
__json_encoder = JSONEncoder()
def __init__(
self,
@ -1160,33 +1220,34 @@ class ApiClient:
for auth in auth_settings:
auth_setting = self.configuration.auth_settings().get(auth)
if auth_setting:
if auth_setting['in'] == 'cookie':
headers.add('Cookie', auth_setting['value'])
elif auth_setting['in'] == 'header':
if auth_setting['type'] != 'http-signature':
headers.add(auth_setting['key'], auth_setting['value'])
if not auth_setting:
continue
if auth_setting['in'] == 'cookie':
headers.add('Cookie', auth_setting['value'])
elif auth_setting['in'] == 'header':
if auth_setting['type'] != 'http-signature':
headers.add(auth_setting['key'], auth_setting['value'])
{{#if hasHttpSignatureMethods}}
else:
# The HTTP signature scheme requires multiple HTTP headers
# that are calculated dynamically.
signing_info = self.configuration.signing_info
querys = tuple()
auth_headers = signing_info.get_http_signature_headers(
resource_path, method, headers, body, querys)
for key, value in auth_headers.items():
headers.add(key, value)
{{/if}}
elif auth_setting['in'] == 'query':
""" TODO implement auth in query
need to pass in prefix_separator_iterator
and need to output resource_path with query params added
"""
raise ApiValueError("Auth in query not yet implemented")
else:
raise ApiValueError(
'Authentication token must be in `query` or `header`'
)
# The HTTP signature scheme requires multiple HTTP headers
# that are calculated dynamically.
signing_info = self.configuration.signing_info
querys = tuple()
auth_headers = signing_info.get_http_signature_headers(
resource_path, method, headers, body, querys)
for key, value in auth_headers.items():
headers.add(key, value)
{{/if}}
elif auth_setting['in'] == 'query':
""" TODO implement auth in query
need to pass in prefix_separator_iterator
and need to output resource_path with query params added
"""
raise ApiValueError("Auth in query not yet implemented")
else:
raise ApiValueError(
'Authentication token must be in `query` or `header`'
)
class Api:

View File

@ -1571,7 +1571,6 @@ class ComposedBase(Discriminable):
arg,
discriminated_cls,
validation_metadata: ValidationMetadata,
path_to_schemas: typing.Dict[typing.Tuple, typing.Set[typing.Type[Schema]]]
):
oneof_classes = []
path_to_schemas = defaultdict(set)
@ -1689,8 +1688,7 @@ class ComposedBase(Discriminable):
other_path_to_schemas = cls.__get_oneof_class(
arg,
discriminated_cls=discriminated_cls,
validation_metadata=updated_vm,
path_to_schemas=path_to_schemas
validation_metadata=updated_vm
)
update(path_to_schemas, other_path_to_schemas)
if cls._composed_schemas['anyOf']:

View File

@ -31,8 +31,8 @@ paths:
$ref: '#/components/schemas/Foo'
/pet:
servers:
- url: 'http://petstore.swagger.io/v2'
- url: 'http://path-server-test.petstore.local/v2'
- url: 'https://petstore.swagger.io/v2'
- url: 'https://path-server-test.petstore.local/v2'
post:
tags:
- pet

View File

@ -149,6 +149,84 @@ class ParameterSerializerBase:
def to_dict(name: str, value: str):
return {name: value}
@classmethod
def __ref6570_str_float_int_expansion(
cls,
variable_name: str,
in_data: typing.Any,
explode: bool,
percent_encode: bool,
prefix_separator_iterator: PrefixSeparatorIterator,
var_name_piece: str,
named_parameter_expansion: bool
) -> str:
item_value = cls.__ref6570_item_value(in_data, percent_encode)
if item_value is None or (item_value == '' and prefix_separator_iterator.separator == ';'):
return next(prefix_separator_iterator) + var_name_piece
value_pair_equals = '=' if named_parameter_expansion else ''
return next(prefix_separator_iterator) + var_name_piece + value_pair_equals + item_value
@classmethod
def __ref6570_list_expansion(
cls,
variable_name: str,
in_data: typing.Any,
explode: bool,
percent_encode: bool,
prefix_separator_iterator: PrefixSeparatorIterator,
var_name_piece: str,
named_parameter_expansion: bool
) -> str:
item_values = [cls.__ref6570_item_value(v, percent_encode) for v in in_data]
item_values = [v for v in item_values if v is not None]
if not item_values:
# ignored by the expansion process https://datatracker.ietf.org/doc/html/rfc6570#section-3.2.1
return ""
value_pair_equals = '=' if named_parameter_expansion else ''
if not explode:
return (
next(prefix_separator_iterator) +
var_name_piece +
value_pair_equals +
prefix_separator_iterator.item_separator.join(item_values)
)
# exploded
return next(prefix_separator_iterator) + next(prefix_separator_iterator).join(
[var_name_piece + value_pair_equals + val for val in item_values]
)
@classmethod
def __ref6570_dict_expansion(
cls,
variable_name: str,
in_data: typing.Any,
explode: bool,
percent_encode: bool,
prefix_separator_iterator: PrefixSeparatorIterator,
var_name_piece: str,
named_parameter_expansion: bool
) -> str:
in_data_transformed = {key: cls.__ref6570_item_value(val, percent_encode) for key, val in in_data.items()}
in_data_transformed = {key: val for key, val in in_data_transformed.items() if val is not None}
if not in_data_transformed:
# ignored by the expansion process https://datatracker.ietf.org/doc/html/rfc6570#section-3.2.1
return ""
value_pair_equals = '=' if named_parameter_expansion else ''
if not explode:
return (
next(prefix_separator_iterator) +
var_name_piece + value_pair_equals +
prefix_separator_iterator.item_separator.join(
prefix_separator_iterator.item_separator.join(
item_pair
) for item_pair in in_data_transformed.items()
)
)
# exploded
return next(prefix_separator_iterator) + next(prefix_separator_iterator).join(
[key + '=' + val for key, val in in_data_transformed.items()]
)
@classmethod
def ref6570_expansion(
cls,
@ -164,54 +242,37 @@ class ParameterSerializerBase:
named_parameter_expansion = prefix_separator_iterator.separator in {'&', ';'}
var_name_piece = variable_name if named_parameter_expansion else ''
if type(in_data) in {str, float, int}:
item_value = cls.__ref6570_item_value(in_data, percent_encode)
if item_value is None:
return next(prefix_separator_iterator) + var_name_piece
elif item_value == '' and prefix_separator_iterator.separator == ';':
return next(prefix_separator_iterator) + var_name_piece
value_pair_equals = '=' if named_parameter_expansion else ''
return next(prefix_separator_iterator) + var_name_piece + value_pair_equals + item_value
return cls.__ref6570_str_float_int_expansion(
variable_name,
in_data,
explode,
percent_encode,
prefix_separator_iterator,
var_name_piece,
named_parameter_expansion
)
elif isinstance(in_data, none_type):
# ignored by the expansion process https://datatracker.ietf.org/doc/html/rfc6570#section-3.2.1
return ""
elif isinstance(in_data, list):
item_values = [cls.__ref6570_item_value(v, percent_encode) for v in in_data]
item_values = [v for v in item_values if v is not None]
if not item_values:
# ignored by the expansion process https://datatracker.ietf.org/doc/html/rfc6570#section-3.2.1
return ""
value_pair_equals = '=' if named_parameter_expansion else ''
if not explode:
return (
next(prefix_separator_iterator) +
var_name_piece +
value_pair_equals +
prefix_separator_iterator.item_separator.join(item_values)
)
# exploded
return next(prefix_separator_iterator) + next(prefix_separator_iterator).join(
[var_name_piece + value_pair_equals + val for val in item_values]
return cls.__ref6570_list_expansion(
variable_name,
in_data,
explode,
percent_encode,
prefix_separator_iterator,
var_name_piece,
named_parameter_expansion
)
elif isinstance(in_data, dict):
in_data_transformed = {key: cls.__ref6570_item_value(val, percent_encode) for key, val in in_data.items()}
in_data_transformed = {key: val for key, val in in_data_transformed.items() if val is not None}
if not in_data_transformed:
# ignored by the expansion process https://datatracker.ietf.org/doc/html/rfc6570#section-3.2.1
return ""
value_pair_equals = '=' if named_parameter_expansion else ''
if not explode:
return (
next(prefix_separator_iterator) +
var_name_piece + value_pair_equals +
prefix_separator_iterator.item_separator.join(
prefix_separator_iterator.item_separator.join(
item_pair
) for item_pair in in_data_transformed.items()
)
)
# exploded
return next(prefix_separator_iterator) + next(prefix_separator_iterator).join(
[key + '=' + val for key, val in in_data_transformed.items()]
return cls.__ref6570_dict_expansion(
variable_name,
in_data,
explode,
percent_encode,
prefix_separator_iterator,
var_name_piece,
named_parameter_expansion
)
# bool, bytes, etc
raise ApiValueError('Unable to generate a ref6570 representation of {}'.format(in_data))
@ -907,7 +968,6 @@ class ApiClient:
"""
_pool = None
__json_encoder = JSONEncoder()
def __init__(
self,
@ -1161,22 +1221,23 @@ class ApiClient:
for auth in auth_settings:
auth_setting = self.configuration.auth_settings().get(auth)
if auth_setting:
if auth_setting['in'] == 'cookie':
headers.add('Cookie', auth_setting['value'])
elif auth_setting['in'] == 'header':
if auth_setting['type'] != 'http-signature':
headers.add(auth_setting['key'], auth_setting['value'])
elif auth_setting['in'] == 'query':
""" TODO implement auth in query
need to pass in prefix_separator_iterator
and need to output resource_path with query params added
"""
raise ApiValueError("Auth in query not yet implemented")
else:
raise ApiValueError(
'Authentication token must be in `query` or `header`'
)
if not auth_setting:
continue
if auth_setting['in'] == 'cookie':
headers.add('Cookie', auth_setting['value'])
elif auth_setting['in'] == 'header':
if auth_setting['type'] != 'http-signature':
headers.add(auth_setting['key'], auth_setting['value'])
elif auth_setting['in'] == 'query':
""" TODO implement auth in query
need to pass in prefix_separator_iterator
and need to output resource_path with query params added
"""
raise ApiValueError("Auth in query not yet implemented")
else:
raise ApiValueError(
'Authentication token must be in `query` or `header`'
)
class Api:

View File

@ -91,7 +91,7 @@ class AdditionalpropertiesShouldNotLookInApplicators(
# loading
class allOf_0(
class all_of_0(
AnyTypeSchema
):
foo = AnyTypeSchema
@ -102,7 +102,7 @@ class AdditionalpropertiesShouldNotLookInApplicators(
foo: typing.Union[foo, Unset] = unset,
_configuration: typing.Optional[Configuration] = None,
**kwargs: typing.Type[Schema],
) -> 'allOf_0':
) -> 'all_of_0':
return super().__new__(
cls,
*args,
@ -112,7 +112,7 @@ class AdditionalpropertiesShouldNotLookInApplicators(
)
return {
'allOf': [
allOf_0,
all_of_0,
],
'oneOf': [
],

View File

@ -90,7 +90,7 @@ class Allof(
# loading
class allOf_0(
class all_of_0(
AnyTypeSchema
):
_required_property_names = {
@ -104,7 +104,7 @@ class Allof(
bar: bar,
_configuration: typing.Optional[Configuration] = None,
**kwargs: typing.Type[Schema],
) -> 'allOf_0':
) -> 'all_of_0':
return super().__new__(
cls,
*args,
@ -114,7 +114,7 @@ class Allof(
)
class allOf_1(
class all_of_1(
AnyTypeSchema
):
_required_property_names = {
@ -128,7 +128,7 @@ class Allof(
foo: foo,
_configuration: typing.Optional[Configuration] = None,
**kwargs: typing.Type[Schema],
) -> 'allOf_1':
) -> 'all_of_1':
return super().__new__(
cls,
*args,
@ -138,8 +138,8 @@ class Allof(
)
return {
'allOf': [
allOf_0,
allOf_1,
all_of_0,
all_of_1,
],
'oneOf': [
],

View File

@ -90,7 +90,7 @@ class AllofCombinedWithAnyofOneof(
# loading
class allOf_0(
class all_of_0(
_SchemaValidator(
multiple_of=2,
),
@ -102,7 +102,7 @@ class AllofCombinedWithAnyofOneof(
*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':
) -> 'all_of_0':
return super().__new__(
cls,
*args,
@ -111,7 +111,7 @@ class AllofCombinedWithAnyofOneof(
)
class oneOf_0(
class one_of_0(
_SchemaValidator(
multiple_of=5,
),
@ -123,7 +123,7 @@ class AllofCombinedWithAnyofOneof(
*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':
) -> 'one_of_0':
return super().__new__(
cls,
*args,
@ -132,7 +132,7 @@ class AllofCombinedWithAnyofOneof(
)
class anyOf_0(
class any_of_0(
_SchemaValidator(
multiple_of=3,
),
@ -144,7 +144,7 @@ class AllofCombinedWithAnyofOneof(
*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':
) -> 'any_of_0':
return super().__new__(
cls,
*args,
@ -153,13 +153,13 @@ class AllofCombinedWithAnyofOneof(
)
return {
'allOf': [
allOf_0,
all_of_0,
],
'oneOf': [
oneOf_0,
one_of_0,
],
'anyOf': [
anyOf_0,
any_of_0,
],
'not':
None

View File

@ -90,7 +90,7 @@ class AllofSimpleTypes(
# loading
class allOf_0(
class all_of_0(
_SchemaValidator(
inclusive_maximum=30,
),
@ -102,7 +102,7 @@ class AllofSimpleTypes(
*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':
) -> 'all_of_0':
return super().__new__(
cls,
*args,
@ -111,7 +111,7 @@ class AllofSimpleTypes(
)
class allOf_1(
class all_of_1(
_SchemaValidator(
inclusive_minimum=20,
),
@ -123,7 +123,7 @@ class AllofSimpleTypes(
*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':
) -> 'all_of_1':
return super().__new__(
cls,
*args,
@ -132,8 +132,8 @@ class AllofSimpleTypes(
)
return {
'allOf': [
allOf_0,
allOf_1,
all_of_0,
all_of_1,
],
'oneOf': [
],

View File

@ -94,7 +94,7 @@ class AllofWithBaseSchema(
# loading
class allOf_0(
class all_of_0(
AnyTypeSchema
):
_required_property_names = {
@ -108,7 +108,7 @@ class AllofWithBaseSchema(
foo: foo,
_configuration: typing.Optional[Configuration] = None,
**kwargs: typing.Type[Schema],
) -> 'allOf_0':
) -> 'all_of_0':
return super().__new__(
cls,
*args,
@ -118,7 +118,7 @@ class AllofWithBaseSchema(
)
class allOf_1(
class all_of_1(
AnyTypeSchema
):
_required_property_names = {
@ -132,7 +132,7 @@ class AllofWithBaseSchema(
baz: baz,
_configuration: typing.Optional[Configuration] = None,
**kwargs: typing.Type[Schema],
) -> 'allOf_1':
) -> 'all_of_1':
return super().__new__(
cls,
*args,
@ -142,8 +142,8 @@ class AllofWithBaseSchema(
)
return {
'allOf': [
allOf_0,
allOf_1,
all_of_0,
all_of_1,
],
'oneOf': [
],

View File

@ -88,10 +88,10 @@ class AllofWithOneEmptySchema(
# 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
all_of_0 = AnyTypeSchema
return {
'allOf': [
allOf_0,
all_of_0,
],
'oneOf': [
],

View File

@ -88,12 +88,12 @@ class AllofWithTheFirstEmptySchema(
# 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
all_of_0 = AnyTypeSchema
all_of_1 = NumberSchema
return {
'allOf': [
allOf_0,
allOf_1,
all_of_0,
all_of_1,
],
'oneOf': [
],

View File

@ -88,12 +88,12 @@ class AllofWithTheLastEmptySchema(
# 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
all_of_0 = NumberSchema
all_of_1 = AnyTypeSchema
return {
'allOf': [
allOf_0,
allOf_1,
all_of_0,
all_of_1,
],
'oneOf': [
],

View File

@ -88,12 +88,12 @@ class AllofWithTwoEmptySchemas(
# 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
all_of_0 = AnyTypeSchema
all_of_1 = AnyTypeSchema
return {
'allOf': [
allOf_0,
allOf_1,
all_of_0,
all_of_1,
],
'oneOf': [
],

View File

@ -88,10 +88,10 @@ class Anyof(
# code would be run when this module is imported, and these composed
# classes don't exist yet because their module has not finished
# loading
anyOf_0 = IntSchema
any_of_0 = IntSchema
class anyOf_1(
class any_of_1(
_SchemaValidator(
inclusive_minimum=2,
),
@ -103,7 +103,7 @@ class Anyof(
*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_1':
) -> 'any_of_1':
return super().__new__(
cls,
*args,
@ -116,8 +116,8 @@ class Anyof(
'oneOf': [
],
'anyOf': [
anyOf_0,
anyOf_1,
any_of_0,
any_of_1,
],
'not':
None

View File

@ -90,7 +90,7 @@ class AnyofComplexTypes(
# loading
class anyOf_0(
class any_of_0(
AnyTypeSchema
):
_required_property_names = {
@ -104,7 +104,7 @@ class AnyofComplexTypes(
bar: bar,
_configuration: typing.Optional[Configuration] = None,
**kwargs: typing.Type[Schema],
) -> 'anyOf_0':
) -> 'any_of_0':
return super().__new__(
cls,
*args,
@ -114,7 +114,7 @@ class AnyofComplexTypes(
)
class anyOf_1(
class any_of_1(
AnyTypeSchema
):
_required_property_names = {
@ -128,7 +128,7 @@ class AnyofComplexTypes(
foo: foo,
_configuration: typing.Optional[Configuration] = None,
**kwargs: typing.Type[Schema],
) -> 'anyOf_1':
) -> 'any_of_1':
return super().__new__(
cls,
*args,
@ -142,8 +142,8 @@ class AnyofComplexTypes(
'oneOf': [
],
'anyOf': [
anyOf_0,
anyOf_1,
any_of_0,
any_of_1,
],
'not':
None

View File

@ -91,7 +91,7 @@ class AnyofWithBaseSchema(
# loading
class anyOf_0(
class any_of_0(
_SchemaValidator(
max_length=2,
),
@ -103,7 +103,7 @@ class AnyofWithBaseSchema(
*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':
) -> 'any_of_0':
return super().__new__(
cls,
*args,
@ -112,7 +112,7 @@ class AnyofWithBaseSchema(
)
class anyOf_1(
class any_of_1(
_SchemaValidator(
min_length=4,
),
@ -124,7 +124,7 @@ class AnyofWithBaseSchema(
*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_1':
) -> 'any_of_1':
return super().__new__(
cls,
*args,
@ -137,8 +137,8 @@ class AnyofWithBaseSchema(
'oneOf': [
],
'anyOf': [
anyOf_0,
anyOf_1,
any_of_0,
any_of_1,
],
'not':
None

View File

@ -88,16 +88,16 @@ class AnyofWithOneEmptySchema(
# code would be run when this module is imported, and these composed
# classes don't exist yet because their module has not finished
# loading
anyOf_0 = NumberSchema
anyOf_1 = AnyTypeSchema
any_of_0 = NumberSchema
any_of_1 = AnyTypeSchema
return {
'allOf': [
],
'oneOf': [
],
'anyOf': [
anyOf_0,
anyOf_1,
any_of_0,
any_of_1,
],
'not':
None

View File

@ -93,7 +93,7 @@ class ForbiddenProperty(
# code would be run when this module is imported, and these composed
# classes don't exist yet because their module has not finished
# loading
NotSchema = AnyTypeSchema
not_schema = AnyTypeSchema
return {
'allOf': [
],
@ -102,7 +102,7 @@ class ForbiddenProperty(
'anyOf': [
],
'not':
NotSchema
not_schema
}
def __new__(

View File

@ -88,7 +88,7 @@ class ModelNot(
# code would be run when this module is imported, and these composed
# classes don't exist yet because their module has not finished
# loading
NotSchema = IntSchema
not_schema = IntSchema
return {
'allOf': [
],
@ -97,7 +97,7 @@ class ModelNot(
'anyOf': [
],
'not':
NotSchema
not_schema
}
def __new__(

View File

@ -90,7 +90,7 @@ class NestedAllofToCheckValidationSemantics(
# loading
class allOf_0(
class all_of_0(
ComposedSchema
):
@ -105,10 +105,10 @@ class NestedAllofToCheckValidationSemantics(
# 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
all_of_0 = NoneSchema
return {
'allOf': [
allOf_0,
all_of_0,
],
'oneOf': [
],
@ -123,7 +123,7 @@ class NestedAllofToCheckValidationSemantics(
*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':
) -> 'all_of_0':
return super().__new__(
cls,
*args,
@ -132,7 +132,7 @@ class NestedAllofToCheckValidationSemantics(
)
return {
'allOf': [
allOf_0,
all_of_0,
],
'oneOf': [
],

View File

@ -90,7 +90,7 @@ class NestedAnyofToCheckValidationSemantics(
# loading
class anyOf_0(
class any_of_0(
ComposedSchema
):
@ -105,14 +105,14 @@ class NestedAnyofToCheckValidationSemantics(
# code would be run when this module is imported, and these composed
# classes don't exist yet because their module has not finished
# loading
anyOf_0 = NoneSchema
any_of_0 = NoneSchema
return {
'allOf': [
],
'oneOf': [
],
'anyOf': [
anyOf_0,
any_of_0,
],
'not':
None
@ -123,7 +123,7 @@ class NestedAnyofToCheckValidationSemantics(
*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':
) -> 'any_of_0':
return super().__new__(
cls,
*args,
@ -136,7 +136,7 @@ class NestedAnyofToCheckValidationSemantics(
'oneOf': [
],
'anyOf': [
anyOf_0,
any_of_0,
],
'not':
None

View File

@ -90,7 +90,7 @@ class NestedOneofToCheckValidationSemantics(
# loading
class oneOf_0(
class one_of_0(
ComposedSchema
):
@ -105,12 +105,12 @@ class NestedOneofToCheckValidationSemantics(
# code would be run when this module is imported, and these composed
# classes don't exist yet because their module has not finished
# loading
oneOf_0 = NoneSchema
one_of_0 = NoneSchema
return {
'allOf': [
],
'oneOf': [
oneOf_0,
one_of_0,
],
'anyOf': [
],
@ -123,7 +123,7 @@ class NestedOneofToCheckValidationSemantics(
*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':
) -> 'one_of_0':
return super().__new__(
cls,
*args,
@ -134,7 +134,7 @@ class NestedOneofToCheckValidationSemantics(
'allOf': [
],
'oneOf': [
oneOf_0,
one_of_0,
],
'anyOf': [
],

View File

@ -90,7 +90,7 @@ class NotMoreComplexSchema(
# loading
class NotSchema(
class not_schema(
DictSchema
):
foo = StrSchema
@ -102,7 +102,7 @@ class NotMoreComplexSchema(
foo: typing.Union[foo, Unset] = unset,
_configuration: typing.Optional[Configuration] = None,
**kwargs: typing.Type[Schema],
) -> 'NotSchema':
) -> 'not_schema':
return super().__new__(
cls,
*args,
@ -118,7 +118,7 @@ class NotMoreComplexSchema(
'anyOf': [
],
'not':
NotSchema
not_schema
}
def __new__(

View File

@ -88,10 +88,10 @@ class Oneof(
# code would be run when this module is imported, and these composed
# classes don't exist yet because their module has not finished
# loading
oneOf_0 = IntSchema
one_of_0 = IntSchema
class oneOf_1(
class one_of_1(
_SchemaValidator(
inclusive_minimum=2,
),
@ -103,7 +103,7 @@ class Oneof(
*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_1':
) -> 'one_of_1':
return super().__new__(
cls,
*args,
@ -114,8 +114,8 @@ class Oneof(
'allOf': [
],
'oneOf': [
oneOf_0,
oneOf_1,
one_of_0,
one_of_1,
],
'anyOf': [
],

View File

@ -90,7 +90,7 @@ class OneofComplexTypes(
# loading
class oneOf_0(
class one_of_0(
AnyTypeSchema
):
_required_property_names = {
@ -104,7 +104,7 @@ class OneofComplexTypes(
bar: bar,
_configuration: typing.Optional[Configuration] = None,
**kwargs: typing.Type[Schema],
) -> 'oneOf_0':
) -> 'one_of_0':
return super().__new__(
cls,
*args,
@ -114,7 +114,7 @@ class OneofComplexTypes(
)
class oneOf_1(
class one_of_1(
AnyTypeSchema
):
_required_property_names = {
@ -128,7 +128,7 @@ class OneofComplexTypes(
foo: foo,
_configuration: typing.Optional[Configuration] = None,
**kwargs: typing.Type[Schema],
) -> 'oneOf_1':
) -> 'one_of_1':
return super().__new__(
cls,
*args,
@ -140,8 +140,8 @@ class OneofComplexTypes(
'allOf': [
],
'oneOf': [
oneOf_0,
oneOf_1,
one_of_0,
one_of_1,
],
'anyOf': [
],

View File

@ -91,7 +91,7 @@ class OneofWithBaseSchema(
# loading
class oneOf_0(
class one_of_0(
_SchemaValidator(
min_length=2,
),
@ -103,7 +103,7 @@ class OneofWithBaseSchema(
*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':
) -> 'one_of_0':
return super().__new__(
cls,
*args,
@ -112,7 +112,7 @@ class OneofWithBaseSchema(
)
class oneOf_1(
class one_of_1(
_SchemaValidator(
max_length=4,
),
@ -124,7 +124,7 @@ class OneofWithBaseSchema(
*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_1':
) -> 'one_of_1':
return super().__new__(
cls,
*args,
@ -135,8 +135,8 @@ class OneofWithBaseSchema(
'allOf': [
],
'oneOf': [
oneOf_0,
oneOf_1,
one_of_0,
one_of_1,
],
'anyOf': [
],

View File

@ -88,14 +88,14 @@ class OneofWithEmptySchema(
# code would be run when this module is imported, and these composed
# classes don't exist yet because their module has not finished
# loading
oneOf_0 = NumberSchema
oneOf_1 = AnyTypeSchema
one_of_0 = NumberSchema
one_of_1 = AnyTypeSchema
return {
'allOf': [
],
'oneOf': [
oneOf_0,
oneOf_1,
one_of_0,
one_of_1,
],
'anyOf': [
],

View File

@ -91,7 +91,7 @@ class OneofWithRequired(
# loading
class oneOf_0(
class one_of_0(
AnyTypeSchema
):
_required_property_names = {
@ -104,7 +104,7 @@ class OneofWithRequired(
*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':
) -> 'one_of_0':
return super().__new__(
cls,
*args,
@ -113,7 +113,7 @@ class OneofWithRequired(
)
class oneOf_1(
class one_of_1(
AnyTypeSchema
):
_required_property_names = {
@ -126,7 +126,7 @@ class OneofWithRequired(
*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_1':
) -> 'one_of_1':
return super().__new__(
cls,
*args,
@ -137,8 +137,8 @@ class OneofWithRequired(
'allOf': [
],
'oneOf': [
oneOf_0,
oneOf_1,
one_of_0,
one_of_1,
],
'anyOf': [
],

View File

@ -88,7 +88,7 @@ class SchemaForRequestBodyApplicationJson(
# loading
class NotSchema(
class not_schema(
DictSchema
):
foo = StrSchema
@ -100,7 +100,7 @@ class SchemaForRequestBodyApplicationJson(
foo: typing.Union[foo, Unset] = unset,
_configuration: typing.Optional[Configuration] = None,
**kwargs: typing.Type[Schema],
) -> 'NotSchema':
) -> 'not_schema':
return super().__new__(
cls,
*args,
@ -116,7 +116,7 @@ class SchemaForRequestBodyApplicationJson(
'anyOf': [
],
'not':
NotSchema
not_schema
}
def __new__(

View File

@ -86,7 +86,7 @@ class SchemaForRequestBodyApplicationJson(
# code would be run when this module is imported, and these composed
# classes don't exist yet because their module has not finished
# loading
NotSchema = IntSchema
not_schema = IntSchema
return {
'allOf': [
],
@ -95,7 +95,7 @@ class SchemaForRequestBodyApplicationJson(
'anyOf': [
],
'not':
NotSchema
not_schema
}
def __new__(

View File

@ -87,7 +87,7 @@ class SchemaFor200ResponseBodyApplicationJson(
# loading
class NotSchema(
class not_schema(
DictSchema
):
foo = StrSchema
@ -99,7 +99,7 @@ class SchemaFor200ResponseBodyApplicationJson(
foo: typing.Union[foo, Unset] = unset,
_configuration: typing.Optional[Configuration] = None,
**kwargs: typing.Type[Schema],
) -> 'NotSchema':
) -> 'not_schema':
return super().__new__(
cls,
*args,
@ -115,7 +115,7 @@ class SchemaFor200ResponseBodyApplicationJson(
'anyOf': [
],
'not':
NotSchema
not_schema
}
def __new__(

View File

@ -85,7 +85,7 @@ class SchemaFor200ResponseBodyApplicationJson(
# code would be run when this module is imported, and these composed
# classes don't exist yet because their module has not finished
# loading
NotSchema = IntSchema
not_schema = IntSchema
return {
'allOf': [
],
@ -94,7 +94,7 @@ class SchemaFor200ResponseBodyApplicationJson(
'anyOf': [
],
'not':
NotSchema
not_schema
}
def __new__(

View File

@ -1578,7 +1578,6 @@ class ComposedBase(Discriminable):
arg,
discriminated_cls,
validation_metadata: ValidationMetadata,
path_to_schemas: typing.Dict[typing.Tuple, typing.Set[typing.Type[Schema]]]
):
oneof_classes = []
path_to_schemas = defaultdict(set)
@ -1696,8 +1695,7 @@ class ComposedBase(Discriminable):
other_path_to_schemas = cls.__get_oneof_class(
arg,
discriminated_cls=discriminated_cls,
validation_metadata=updated_vm,
path_to_schemas=path_to_schemas
validation_metadata=updated_vm
)
update(path_to_schemas, other_path_to_schemas)
if cls._composed_schemas['anyOf']:

View File

@ -149,6 +149,84 @@ class ParameterSerializerBase:
def to_dict(name: str, value: str):
return {name: value}
@classmethod
def __ref6570_str_float_int_expansion(
cls,
variable_name: str,
in_data: typing.Any,
explode: bool,
percent_encode: bool,
prefix_separator_iterator: PrefixSeparatorIterator,
var_name_piece: str,
named_parameter_expansion: bool
) -> str:
item_value = cls.__ref6570_item_value(in_data, percent_encode)
if item_value is None or (item_value == '' and prefix_separator_iterator.separator == ';'):
return next(prefix_separator_iterator) + var_name_piece
value_pair_equals = '=' if named_parameter_expansion else ''
return next(prefix_separator_iterator) + var_name_piece + value_pair_equals + item_value
@classmethod
def __ref6570_list_expansion(
cls,
variable_name: str,
in_data: typing.Any,
explode: bool,
percent_encode: bool,
prefix_separator_iterator: PrefixSeparatorIterator,
var_name_piece: str,
named_parameter_expansion: bool
) -> str:
item_values = [cls.__ref6570_item_value(v, percent_encode) for v in in_data]
item_values = [v for v in item_values if v is not None]
if not item_values:
# ignored by the expansion process https://datatracker.ietf.org/doc/html/rfc6570#section-3.2.1
return ""
value_pair_equals = '=' if named_parameter_expansion else ''
if not explode:
return (
next(prefix_separator_iterator) +
var_name_piece +
value_pair_equals +
prefix_separator_iterator.item_separator.join(item_values)
)
# exploded
return next(prefix_separator_iterator) + next(prefix_separator_iterator).join(
[var_name_piece + value_pair_equals + val for val in item_values]
)
@classmethod
def __ref6570_dict_expansion(
cls,
variable_name: str,
in_data: typing.Any,
explode: bool,
percent_encode: bool,
prefix_separator_iterator: PrefixSeparatorIterator,
var_name_piece: str,
named_parameter_expansion: bool
) -> str:
in_data_transformed = {key: cls.__ref6570_item_value(val, percent_encode) for key, val in in_data.items()}
in_data_transformed = {key: val for key, val in in_data_transformed.items() if val is not None}
if not in_data_transformed:
# ignored by the expansion process https://datatracker.ietf.org/doc/html/rfc6570#section-3.2.1
return ""
value_pair_equals = '=' if named_parameter_expansion else ''
if not explode:
return (
next(prefix_separator_iterator) +
var_name_piece + value_pair_equals +
prefix_separator_iterator.item_separator.join(
prefix_separator_iterator.item_separator.join(
item_pair
) for item_pair in in_data_transformed.items()
)
)
# exploded
return next(prefix_separator_iterator) + next(prefix_separator_iterator).join(
[key + '=' + val for key, val in in_data_transformed.items()]
)
@classmethod
def ref6570_expansion(
cls,
@ -164,54 +242,37 @@ class ParameterSerializerBase:
named_parameter_expansion = prefix_separator_iterator.separator in {'&', ';'}
var_name_piece = variable_name if named_parameter_expansion else ''
if type(in_data) in {str, float, int}:
item_value = cls.__ref6570_item_value(in_data, percent_encode)
if item_value is None:
return next(prefix_separator_iterator) + var_name_piece
elif item_value == '' and prefix_separator_iterator.separator == ';':
return next(prefix_separator_iterator) + var_name_piece
value_pair_equals = '=' if named_parameter_expansion else ''
return next(prefix_separator_iterator) + var_name_piece + value_pair_equals + item_value
return cls.__ref6570_str_float_int_expansion(
variable_name,
in_data,
explode,
percent_encode,
prefix_separator_iterator,
var_name_piece,
named_parameter_expansion
)
elif isinstance(in_data, none_type):
# ignored by the expansion process https://datatracker.ietf.org/doc/html/rfc6570#section-3.2.1
return ""
elif isinstance(in_data, list):
item_values = [cls.__ref6570_item_value(v, percent_encode) for v in in_data]
item_values = [v for v in item_values if v is not None]
if not item_values:
# ignored by the expansion process https://datatracker.ietf.org/doc/html/rfc6570#section-3.2.1
return ""
value_pair_equals = '=' if named_parameter_expansion else ''
if not explode:
return (
next(prefix_separator_iterator) +
var_name_piece +
value_pair_equals +
prefix_separator_iterator.item_separator.join(item_values)
)
# exploded
return next(prefix_separator_iterator) + next(prefix_separator_iterator).join(
[var_name_piece + value_pair_equals + val for val in item_values]
return cls.__ref6570_list_expansion(
variable_name,
in_data,
explode,
percent_encode,
prefix_separator_iterator,
var_name_piece,
named_parameter_expansion
)
elif isinstance(in_data, dict):
in_data_transformed = {key: cls.__ref6570_item_value(val, percent_encode) for key, val in in_data.items()}
in_data_transformed = {key: val for key, val in in_data_transformed.items() if val is not None}
if not in_data_transformed:
# ignored by the expansion process https://datatracker.ietf.org/doc/html/rfc6570#section-3.2.1
return ""
value_pair_equals = '=' if named_parameter_expansion else ''
if not explode:
return (
next(prefix_separator_iterator) +
var_name_piece + value_pair_equals +
prefix_separator_iterator.item_separator.join(
prefix_separator_iterator.item_separator.join(
item_pair
) for item_pair in in_data_transformed.items()
)
)
# exploded
return next(prefix_separator_iterator) + next(prefix_separator_iterator).join(
[key + '=' + val for key, val in in_data_transformed.items()]
return cls.__ref6570_dict_expansion(
variable_name,
in_data,
explode,
percent_encode,
prefix_separator_iterator,
var_name_piece,
named_parameter_expansion
)
# bool, bytes, etc
raise ApiValueError('Unable to generate a ref6570 representation of {}'.format(in_data))
@ -907,7 +968,6 @@ class ApiClient:
"""
_pool = None
__json_encoder = JSONEncoder()
def __init__(
self,
@ -1161,31 +1221,32 @@ class ApiClient:
for auth in auth_settings:
auth_setting = self.configuration.auth_settings().get(auth)
if auth_setting:
if auth_setting['in'] == 'cookie':
headers.add('Cookie', auth_setting['value'])
elif auth_setting['in'] == 'header':
if auth_setting['type'] != 'http-signature':
headers.add(auth_setting['key'], auth_setting['value'])
else:
# The HTTP signature scheme requires multiple HTTP headers
# that are calculated dynamically.
signing_info = self.configuration.signing_info
querys = tuple()
auth_headers = signing_info.get_http_signature_headers(
resource_path, method, headers, body, querys)
for key, value in auth_headers.items():
headers.add(key, value)
elif auth_setting['in'] == 'query':
""" TODO implement auth in query
need to pass in prefix_separator_iterator
and need to output resource_path with query params added
"""
raise ApiValueError("Auth in query not yet implemented")
if not auth_setting:
continue
if auth_setting['in'] == 'cookie':
headers.add('Cookie', auth_setting['value'])
elif auth_setting['in'] == 'header':
if auth_setting['type'] != 'http-signature':
headers.add(auth_setting['key'], auth_setting['value'])
else:
raise ApiValueError(
'Authentication token must be in `query` or `header`'
)
# The HTTP signature scheme requires multiple HTTP headers
# that are calculated dynamically.
signing_info = self.configuration.signing_info
querys = tuple()
auth_headers = signing_info.get_http_signature_headers(
resource_path, method, headers, body, querys)
for key, value in auth_headers.items():
headers.add(key, value)
elif auth_setting['in'] == 'query':
""" TODO implement auth in query
need to pass in prefix_separator_iterator
and need to output resource_path with query params added
"""
raise ApiValueError("Auth in query not yet implemented")
else:
raise ApiValueError(
'Authentication token must be in `query` or `header`'
)
class Api:

View File

@ -88,7 +88,7 @@ class AnyTypeNotString(
# code would be run when this module is imported, and these composed
# classes don't exist yet because their module has not finished
# loading
NotSchema = StrSchema
not_schema = StrSchema
return {
'allOf': [
],
@ -97,7 +97,7 @@ class AnyTypeNotString(
'anyOf': [
],
'not':
NotSchema
not_schema
}
def __new__(

View File

@ -90,7 +90,7 @@ class Cat(
# loading
class allOf_1(
class all_of_1(
DictSchema
):
declawed = BoolSchema
@ -102,7 +102,7 @@ class Cat(
declawed: typing.Union[declawed, Unset] = unset,
_configuration: typing.Optional[Configuration] = None,
**kwargs: typing.Type[Schema],
) -> 'allOf_1':
) -> 'all_of_1':
return super().__new__(
cls,
*args,
@ -113,7 +113,7 @@ class Cat(
return {
'allOf': [
Animal,
allOf_1,
all_of_1,
],
'oneOf': [
],

View File

@ -90,7 +90,7 @@ class ChildCat(
# loading
class allOf_1(
class all_of_1(
DictSchema
):
name = StrSchema
@ -102,7 +102,7 @@ class ChildCat(
name: typing.Union[name, Unset] = unset,
_configuration: typing.Optional[Configuration] = None,
**kwargs: typing.Type[Schema],
) -> 'allOf_1':
) -> 'all_of_1':
return super().__new__(
cls,
*args,
@ -113,7 +113,7 @@ class ChildCat(
return {
'allOf': [
ParentPet,
allOf_1,
all_of_1,
],
'oneOf': [
],

View File

@ -90,7 +90,7 @@ class ComplexQuadrilateral(
# loading
class allOf_1(
class all_of_1(
DictSchema
):
@ -116,7 +116,7 @@ class ComplexQuadrilateral(
quadrilateralType: typing.Union[quadrilateralType, Unset] = unset,
_configuration: typing.Optional[Configuration] = None,
**kwargs: typing.Type[Schema],
) -> 'allOf_1':
) -> 'all_of_1':
return super().__new__(
cls,
*args,
@ -127,7 +127,7 @@ class ComplexQuadrilateral(
return {
'allOf': [
QuadrilateralInterface,
allOf_1,
all_of_1,
],
'oneOf': [
],

View File

@ -88,49 +88,49 @@ class ComposedAnyOfDifferentTypesNoValidations(
# code would be run when this module is imported, and these composed
# classes don't exist yet because their module has not finished
# loading
anyOf_0 = DictSchema
anyOf_1 = DateSchema
anyOf_2 = DateTimeSchema
anyOf_3 = BinarySchema
anyOf_4 = StrSchema
anyOf_5 = StrSchema
anyOf_6 = DictSchema
anyOf_7 = BoolSchema
anyOf_8 = NoneSchema
any_of_0 = DictSchema
any_of_1 = DateSchema
any_of_2 = DateTimeSchema
any_of_3 = BinarySchema
any_of_4 = StrSchema
any_of_5 = StrSchema
any_of_6 = DictSchema
any_of_7 = BoolSchema
any_of_8 = NoneSchema
class anyOf_9(
class any_of_9(
ListSchema
):
_items = AnyTypeSchema
anyOf_10 = NumberSchema
anyOf_11 = Float32Schema
anyOf_12 = Float64Schema
anyOf_13 = IntSchema
anyOf_14 = Int32Schema
anyOf_15 = Int64Schema
any_of_10 = NumberSchema
any_of_11 = Float32Schema
any_of_12 = Float64Schema
any_of_13 = IntSchema
any_of_14 = Int32Schema
any_of_15 = Int64Schema
return {
'allOf': [
],
'oneOf': [
],
'anyOf': [
anyOf_0,
anyOf_1,
anyOf_2,
anyOf_3,
anyOf_4,
anyOf_5,
anyOf_6,
anyOf_7,
anyOf_8,
anyOf_9,
anyOf_10,
anyOf_11,
anyOf_12,
anyOf_13,
anyOf_14,
anyOf_15,
any_of_0,
any_of_1,
any_of_2,
any_of_3,
any_of_4,
any_of_5,
any_of_6,
any_of_7,
any_of_8,
any_of_9,
any_of_10,
any_of_11,
any_of_12,
any_of_13,
any_of_14,
any_of_15,
],
'not':
None

View File

@ -89,10 +89,10 @@ class ComposedBool(
# 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
all_of_0 = AnyTypeSchema
return {
'allOf': [
allOf_0,
all_of_0,
],
'oneOf': [
],

View File

@ -89,10 +89,10 @@ class ComposedNone(
# 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
all_of_0 = AnyTypeSchema
return {
'allOf': [
allOf_0,
all_of_0,
],
'oneOf': [
],

View File

@ -89,10 +89,10 @@ class ComposedNumber(
# 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
all_of_0 = AnyTypeSchema
return {
'allOf': [
allOf_0,
all_of_0,
],
'oneOf': [
],

View File

@ -89,10 +89,10 @@ class ComposedObject(
# 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
all_of_0 = AnyTypeSchema
return {
'allOf': [
allOf_0,
all_of_0,
],
'oneOf': [
],

View File

@ -90,11 +90,11 @@ class ComposedOneOfDifferentTypes(
# code would be run when this module is imported, and these composed
# classes don't exist yet because their module has not finished
# loading
oneOf_2 = NoneSchema
oneOf_3 = DateSchema
one_of_2 = NoneSchema
one_of_3 = DateSchema
class oneOf_4(
class one_of_4(
_SchemaValidator(
max_properties=4,
min_properties=4,
@ -108,7 +108,7 @@ class ComposedOneOfDifferentTypes(
*args: typing.Union[dict, frozendict, ],
_configuration: typing.Optional[Configuration] = None,
**kwargs: typing.Type[Schema],
) -> 'oneOf_4':
) -> 'one_of_4':
return super().__new__(
cls,
*args,
@ -117,7 +117,7 @@ class ComposedOneOfDifferentTypes(
)
class oneOf_5(
class one_of_5(
_SchemaValidator(
max_items=4,
min_items=4,
@ -127,7 +127,7 @@ class ComposedOneOfDifferentTypes(
_items = AnyTypeSchema
class oneOf_6(
class one_of_6(
_SchemaValidator(
regex=[{
'pattern': r'^2020.*', # noqa: E501
@ -142,11 +142,11 @@ class ComposedOneOfDifferentTypes(
'oneOf': [
NumberWithValidations,
Animal,
oneOf_2,
oneOf_3,
oneOf_4,
oneOf_5,
oneOf_6,
one_of_2,
one_of_3,
one_of_4,
one_of_5,
one_of_6,
],
'anyOf': [
],

View File

@ -89,10 +89,10 @@ class ComposedString(
# 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
all_of_0 = AnyTypeSchema
return {
'allOf': [
allOf_0,
all_of_0,
],
'oneOf': [
],

View File

@ -90,7 +90,7 @@ class Dog(
# loading
class allOf_1(
class all_of_1(
DictSchema
):
breed = StrSchema
@ -102,7 +102,7 @@ class Dog(
breed: typing.Union[breed, Unset] = unset,
_configuration: typing.Optional[Configuration] = None,
**kwargs: typing.Type[Schema],
) -> 'allOf_1':
) -> 'all_of_1':
return super().__new__(
cls,
*args,
@ -113,7 +113,7 @@ class Dog(
return {
'allOf': [
Animal,
allOf_1,
all_of_1,
],
'oneOf': [
],

View File

@ -90,7 +90,7 @@ class EquilateralTriangle(
# loading
class allOf_1(
class all_of_1(
DictSchema
):
@ -116,7 +116,7 @@ class EquilateralTriangle(
triangleType: typing.Union[triangleType, Unset] = unset,
_configuration: typing.Optional[Configuration] = None,
**kwargs: typing.Type[Schema],
) -> 'allOf_1':
) -> 'all_of_1':
return super().__new__(
cls,
*args,
@ -127,7 +127,7 @@ class EquilateralTriangle(
return {
'allOf': [
TriangleInterface,
allOf_1,
all_of_1,
],
'oneOf': [
],

View File

@ -88,12 +88,12 @@ class FruitReq(
# code would be run when this module is imported, and these composed
# classes don't exist yet because their module has not finished
# loading
oneOf_0 = NoneSchema
one_of_0 = NoneSchema
return {
'allOf': [
],
'oneOf': [
oneOf_0,
one_of_0,
AppleReq,
BananaReq,
],

View File

@ -90,7 +90,7 @@ class IsoscelesTriangle(
# loading
class allOf_1(
class all_of_1(
DictSchema
):
@ -116,7 +116,7 @@ class IsoscelesTriangle(
triangleType: typing.Union[triangleType, Unset] = unset,
_configuration: typing.Optional[Configuration] = None,
**kwargs: typing.Type[Schema],
) -> 'allOf_1':
) -> 'all_of_1':
return super().__new__(
cls,
*args,
@ -127,7 +127,7 @@ class IsoscelesTriangle(
return {
'allOf': [
TriangleInterface,
allOf_1,
all_of_1,
],
'oneOf': [
],

View File

@ -90,14 +90,14 @@ class NullableShape(
# code would be run when this module is imported, and these composed
# classes don't exist yet because their module has not finished
# loading
oneOf_2 = NoneSchema
one_of_2 = NoneSchema
return {
'allOf': [
],
'oneOf': [
Triangle,
Quadrilateral,
oneOf_2,
one_of_2,
],
'anyOf': [
],

View File

@ -95,7 +95,7 @@ class ObjectWithInlineCompositionProperty(
# loading
class allOf_0(
class all_of_0(
_SchemaValidator(
min_length=1,
),
@ -104,7 +104,7 @@ class ObjectWithInlineCompositionProperty(
pass
return {
'allOf': [
allOf_0,
all_of_0,
],
'oneOf': [
],

View File

@ -90,7 +90,7 @@ class ScaleneTriangle(
# loading
class allOf_1(
class all_of_1(
DictSchema
):
@ -116,7 +116,7 @@ class ScaleneTriangle(
triangleType: typing.Union[triangleType, Unset] = unset,
_configuration: typing.Optional[Configuration] = None,
**kwargs: typing.Type[Schema],
) -> 'allOf_1':
) -> 'all_of_1':
return super().__new__(
cls,
*args,
@ -127,7 +127,7 @@ class ScaleneTriangle(
return {
'allOf': [
TriangleInterface,
allOf_1,
all_of_1,
],
'oneOf': [
],

View File

@ -100,12 +100,12 @@ class ShapeOrNull(
# code would be run when this module is imported, and these composed
# classes don't exist yet because their module has not finished
# loading
oneOf_0 = NoneSchema
one_of_0 = NoneSchema
return {
'allOf': [
],
'oneOf': [
oneOf_0,
one_of_0,
Triangle,
Quadrilateral,
],

View File

@ -90,7 +90,7 @@ class SimpleQuadrilateral(
# loading
class allOf_1(
class all_of_1(
DictSchema
):
@ -116,7 +116,7 @@ class SimpleQuadrilateral(
quadrilateralType: typing.Union[quadrilateralType, Unset] = unset,
_configuration: typing.Optional[Configuration] = None,
**kwargs: typing.Type[Schema],
) -> 'allOf_1':
) -> 'all_of_1':
return super().__new__(
cls,
*args,
@ -127,7 +127,7 @@ class SimpleQuadrilateral(
return {
'allOf': [
QuadrilateralInterface,
allOf_1,
all_of_1,
],
'oneOf': [
],

View File

@ -124,7 +124,7 @@ class User(
# code would be run when this module is imported, and these composed
# classes don't exist yet because their module has not finished
# loading
NotSchema = NoneSchema
not_schema = NoneSchema
return {
'allOf': [
],
@ -133,7 +133,7 @@ class User(
'anyOf': [
],
'not':
NotSchema
not_schema
}
def __new__(

View File

@ -88,7 +88,7 @@ class CompositionAtRootSchema(
# loading
class allOf_0(
class all_of_0(
_SchemaValidator(
min_length=1,
),
@ -97,7 +97,7 @@ class CompositionAtRootSchema(
pass
return {
'allOf': [
allOf_0,
all_of_0,
],
'oneOf': [
],
@ -143,7 +143,7 @@ class CompositionInPropertySchema(
# loading
class allOf_0(
class all_of_0(
_SchemaValidator(
min_length=1,
),
@ -152,7 +152,7 @@ class CompositionInPropertySchema(
pass
return {
'allOf': [
allOf_0,
all_of_0,
],
'oneOf': [
],
@ -241,7 +241,7 @@ class SchemaForRequestBodyApplicationJson(
# loading
class allOf_0(
class all_of_0(
_SchemaValidator(
min_length=1,
),
@ -250,7 +250,7 @@ class SchemaForRequestBodyApplicationJson(
pass
return {
'allOf': [
allOf_0,
all_of_0,
],
'oneOf': [
],
@ -296,7 +296,7 @@ class SchemaForRequestBodyMultipartFormData(
# loading
class allOf_0(
class all_of_0(
_SchemaValidator(
min_length=1,
),
@ -305,7 +305,7 @@ class SchemaForRequestBodyMultipartFormData(
pass
return {
'allOf': [
allOf_0,
all_of_0,
],
'oneOf': [
],
@ -372,7 +372,7 @@ class SchemaFor200ResponseBodyApplicationJson(
# loading
class allOf_0(
class all_of_0(
_SchemaValidator(
min_length=1,
),
@ -381,7 +381,7 @@ class SchemaFor200ResponseBodyApplicationJson(
pass
return {
'allOf': [
allOf_0,
all_of_0,
],
'oneOf': [
],
@ -427,7 +427,7 @@ class SchemaFor200ResponseBodyMultipartFormData(
# loading
class allOf_0(
class all_of_0(
_SchemaValidator(
min_length=1,
),
@ -436,7 +436,7 @@ class SchemaFor200ResponseBodyMultipartFormData(
pass
return {
'allOf': [
allOf_0,
all_of_0,
],
'oneOf': [
],

View File

@ -90,11 +90,11 @@ _auth = [
]
_servers = (
{
'url': "http://petstore.swagger.io/v2",
'url': "https://petstore.swagger.io/v2",
'description': "No description provided",
},
{
'url': "http://path-server-test.petstore.local/v2",
'url': "https://path-server-test.petstore.local/v2",
'description': "No description provided",
},
)

View File

@ -90,11 +90,11 @@ _auth = [
]
_servers = (
{
'url': "http://petstore.swagger.io/v2",
'url': "https://petstore.swagger.io/v2",
'description': "No description provided",
},
{
'url': "http://path-server-test.petstore.local/v2",
'url': "https://path-server-test.petstore.local/v2",
'description': "No description provided",
},
)

View File

@ -1578,7 +1578,6 @@ class ComposedBase(Discriminable):
arg,
discriminated_cls,
validation_metadata: ValidationMetadata,
path_to_schemas: typing.Dict[typing.Tuple, typing.Set[typing.Type[Schema]]]
):
oneof_classes = []
path_to_schemas = defaultdict(set)
@ -1696,8 +1695,7 @@ class ComposedBase(Discriminable):
other_path_to_schemas = cls.__get_oneof_class(
arg,
discriminated_cls=discriminated_cls,
validation_metadata=updated_vm,
path_to_schemas=path_to_schemas
validation_metadata=updated_vm
)
update(path_to_schemas, other_path_to_schemas)
if cls._composed_schemas['anyOf']:

View File

@ -24,7 +24,7 @@ class ConfigurationTests(unittest.TestCase):
def test_configuration(self):
config = petstore_api.Configuration()
config.host = 'http://localhost/'
config.host = 'https://localhost/'
config.disabled_client_side_validations = ("multipleOf,maximum,exclusiveMaximum,minimum,exclusiveMinimum,"
"maxLength,minLength,pattern,maxItems,minItems")
@ -42,7 +42,7 @@ class ConfigurationTests(unittest.TestCase):
api.add_pet({'name': 'pet', 'photoUrls': []})
mock_request.assert_called_with(
'POST',
'http://path-server-test.petstore.local/v2/pet',
'https://path-server-test.petstore.local/v2/pet',
headers=HTTPHeaderDict({
'Content-Type': 'application/json',
'User-Agent': 'OpenAPI-Generator/1.0.0/python'