mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-19 00:27:07 +00:00
[Python-experimental] JSON schema 'null' type should be modeled as 'none_type' (#6121)
* Handle null type * Handle null type * Handle null type. Add 'null' type in the OAS document for testing purpose * Handle null type. Add 'null' type in the OAS document for testing purpose * Handle null type. Add 'null' type in the OAS document for testing purpose * Handle null type. Add 'null' type in the OAS document for testing purpose * Handle null type. Add 'null' type in the OAS document for testing purpose * Handle null type. Add 'null' type in the OAS document for testing purpose * improve documentation * Handle 'null' type * Handle 'null' type. Add unit tests * Add NullType for go * Add NullType for go * fix modeling of AnyType for go-experimental * execute scripts in bin directory * Add review comments * Add 'null' type in oneOf * Improve OAS YAML file for golang openapi3 samples * 'Any type' includes the null value, so 'isNullable' should be set to TRUE * 'Any type' includes the null value, so 'isNullable' should be set to TRUE * Handle AnyType and NullType * handle anytype for go-experimental * Log warning instead of error * anyOf/oneOf * Change x-golang-is-container extension to x-golang-has-wrapper * Add code comments * Handle Object and any type * Handle Object and any type * Handle object and any type * add code comments * handle additional properties * handle additional properties * handle additional properties * handle anytype and objecttype for go-exerimental * Move golang changes to a separate branch * Move golang changes to a separate branch * Better names for the OAS document test properties * Move golang changes to a separate branch * Run samples scripts * Run samples scripts * fix unit test issues * Handle none type * Fix index out of range exception * fix formatting issues * fix formatting issues * fix formatting issues. Finally figured out how to check formatting in local workspace * fix formatting issues * run samples scripts
This commit is contained in:
@@ -1419,7 +1419,7 @@ def get_oneof_instance(self, model_args, constant_args):
|
||||
and path to item.
|
||||
|
||||
Returns
|
||||
oneof_instance (instance/None)
|
||||
oneof_instance (instance)
|
||||
"""
|
||||
if len(self._composed_schemas['oneOf']) == 0:
|
||||
return None
|
||||
@@ -1428,6 +1428,13 @@ def get_oneof_instance(self, model_args, constant_args):
|
||||
# Iterate over each oneOf schema and determine if the input data
|
||||
# matches the oneOf schemas.
|
||||
for oneof_class in self._composed_schemas['oneOf']:
|
||||
# The composed oneOf schema allows the 'null' type and the input data
|
||||
# is the null value. This is a OAS >= 3.1 feature.
|
||||
if oneof_class is none_type:
|
||||
# skip none_types because we are deserializing dict data.
|
||||
# none_type deserialization is handled in the __new__ method
|
||||
continue
|
||||
|
||||
# transform js keys from input data to python keys in fixed_model_args
|
||||
fixed_model_args = change_keys_js_to_python(
|
||||
model_args, oneof_class)
|
||||
@@ -1473,9 +1480,11 @@ def get_anyof_instances(self, model_args, constant_args):
|
||||
Args:
|
||||
self: the class we are handling
|
||||
model_args (dict): var_name to var_value
|
||||
used to make instances
|
||||
The input data, e.g. the payload that must match at least one
|
||||
anyOf child schema in the OpenAPI document.
|
||||
constant_args (dict): var_name to var_value
|
||||
used to make instances
|
||||
args that every model requires, including configuration, server
|
||||
and path to item.
|
||||
|
||||
Returns
|
||||
anyof_instances (list)
|
||||
@@ -1485,6 +1494,13 @@ def get_anyof_instances(self, model_args, constant_args):
|
||||
return anyof_instances
|
||||
|
||||
for anyof_class in self._composed_schemas['anyOf']:
|
||||
# The composed oneOf schema allows the 'null' type and the input data
|
||||
# is the null value. This is a OAS >= 3.1 feature.
|
||||
if anyof_class is none_type:
|
||||
# skip none_types because we are deserializing dict data.
|
||||
# none_type deserialization is handled in the __new__ method
|
||||
continue
|
||||
|
||||
# transform js keys to python keys in fixed_model_args
|
||||
fixed_model_args = change_keys_js_to_python(model_args, anyof_class)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user