forked from loafle/openapi-generator-original
		
	[Python] fix object arrays giving mypy error "Incompatible types in assignment" in to_dict() (#19223)
* [python] mypy fix for multiple arrays of objects * [python] mypy test for multiple arrays of objects
This commit is contained in:
		
							parent
							
								
									755b2efee4
								
							
						
					
					
						commit
						f082a35d2e
					
				| @ -166,10 +166,10 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} | ||||
|         # override the default output from pydantic by calling `to_dict()` of each item in {{{name}}} (list of list) | ||||
|         _items = [] | ||||
|         if self.{{{name}}}: | ||||
|             for _item in self.{{{name}}}: | ||||
|                 if _item: | ||||
|             for _item_{{{name}}} in self.{{{name}}}: | ||||
|                 if _item_{{{name}}}: | ||||
|                     _items.append( | ||||
|                          [_inner_item.to_dict() for _inner_item in _item if _inner_item is not None] | ||||
|                          [_inner_item.to_dict() for _inner_item in _item_{{{name}}} if _inner_item is not None] | ||||
|                     ) | ||||
|             _dict['{{{baseName}}}'] = _items | ||||
|         {{/items.items.isPrimitiveType}} | ||||
| @ -180,9 +180,9 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} | ||||
|         # override the default output from pydantic by calling `to_dict()` of each item in {{{name}}} (list) | ||||
|         _items = [] | ||||
|         if self.{{{name}}}: | ||||
|             for _item in self.{{{name}}}: | ||||
|                 if _item: | ||||
|                     _items.append(_item.to_dict()) | ||||
|             for _item_{{{name}}} in self.{{{name}}}: | ||||
|                 if _item_{{{name}}}: | ||||
|                     _items.append(_item_{{{name}}}.to_dict()) | ||||
|             _dict['{{{baseName}}}'] = _items | ||||
|         {{/items.isEnumOrRef}} | ||||
|         {{/items.isPrimitiveType}} | ||||
| @ -194,10 +194,10 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} | ||||
|         # override the default output from pydantic by calling `to_dict()` of each value in {{{name}}} (dict of array) | ||||
|         _field_dict_of_array = {} | ||||
|         if self.{{{name}}}: | ||||
|             for _key in self.{{{name}}}: | ||||
|                 if self.{{{name}}}[_key] is not None: | ||||
|                     _field_dict_of_array[_key] = [ | ||||
|                         _item.to_dict() for _item in self.{{{name}}}[_key] | ||||
|             for _key_{{{name}}} in self.{{{name}}}: | ||||
|                 if self.{{{name}}}[_key_{{{name}}}] is not None: | ||||
|                     _field_dict_of_array[_key_{{{name}}}] = [ | ||||
|                         _item.to_dict() for _item in self.{{{name}}}[_key_{{{name}}}] | ||||
|                     ] | ||||
|             _dict['{{{baseName}}}'] = _field_dict_of_array | ||||
|         {{/items.items.isPrimitiveType}} | ||||
| @ -208,9 +208,9 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}} | ||||
|         # override the default output from pydantic by calling `to_dict()` of each value in {{{name}}} (dict) | ||||
|         _field_dict = {} | ||||
|         if self.{{{name}}}: | ||||
|             for _key in self.{{{name}}}: | ||||
|                 if self.{{{name}}}[_key]: | ||||
|                     _field_dict[_key] = self.{{{name}}}[_key].to_dict() | ||||
|             for _key_{{{name}}} in self.{{{name}}}: | ||||
|                 if self.{{{name}}}[_key_{{{name}}}]: | ||||
|                     _field_dict[_key_{{{name}}}] = self.{{{name}}}[_key_{{{name}}}].to_dict() | ||||
|             _dict['{{{baseName}}}'] = _field_dict | ||||
|         {{/items.isEnumOrRef}} | ||||
|         {{/items.isPrimitiveType}} | ||||
|  | ||||
| @ -2253,6 +2253,18 @@ components: | ||||
|             enum: | ||||
|               - fish | ||||
|               - crab | ||||
|     MultiArrays: | ||||
|       type: object | ||||
|       properties: | ||||
|         tags: | ||||
|           type: array | ||||
|           items: | ||||
|             $ref: '#/components/schemas/Tag' | ||||
|         files: | ||||
|           type: array | ||||
|           description: Another array of objects in addition to tags (mypy check to not to reuse the same iterator) | ||||
|           items: | ||||
|             $ref: '#/components/schemas/File' | ||||
|     FreeFormObject: | ||||
|       type: object | ||||
|       description: A schema consisting only of additional properties | ||||
|  | ||||
| @ -92,9 +92,9 @@ class Pet(BaseModel): | ||||
|         # override the default output from pydantic by calling `to_dict()` of each item in tags (list) | ||||
|         _items = [] | ||||
|         if self.tags: | ||||
|             for _item in self.tags: | ||||
|                 if _item: | ||||
|                     _items.append(_item.to_dict()) | ||||
|             for _item_tags in self.tags: | ||||
|                 if _item_tags: | ||||
|                     _items.append(_item_tags.to_dict()) | ||||
|             _dict['tags'] = _items | ||||
|         return _dict | ||||
| 
 | ||||
|  | ||||
| @ -92,9 +92,9 @@ class Pet(BaseModel): | ||||
|         # override the default output from pydantic by calling `to_dict()` of each item in tags (list) | ||||
|         _items = [] | ||||
|         if self.tags: | ||||
|             for _item in self.tags: | ||||
|                 if _item: | ||||
|                     _items.append(_item.to_dict()) | ||||
|             for _item_tags in self.tags: | ||||
|                 if _item_tags: | ||||
|                     _items.append(_item_tags.to_dict()) | ||||
|             _dict['tags'] = _items | ||||
|         return _dict | ||||
| 
 | ||||
|  | ||||
| @ -66,6 +66,7 @@ docs/Model200Response.md | ||||
| docs/ModelApiResponse.md | ||||
| docs/ModelField.md | ||||
| docs/ModelReturn.md | ||||
| docs/MultiArrays.md | ||||
| docs/Name.md | ||||
| docs/NullableClass.md | ||||
| docs/NullableProperty.md | ||||
| @ -188,6 +189,7 @@ petstore_api/models/model200_response.py | ||||
| petstore_api/models/model_api_response.py | ||||
| petstore_api/models/model_field.py | ||||
| petstore_api/models/model_return.py | ||||
| petstore_api/models/multi_arrays.py | ||||
| petstore_api/models/name.py | ||||
| petstore_api/models/nullable_class.py | ||||
| petstore_api/models/nullable_property.py | ||||
|  | ||||
| @ -208,6 +208,7 @@ Class | Method | HTTP request | Description | ||||
|  - [ModelApiResponse](docs/ModelApiResponse.md) | ||||
|  - [ModelField](docs/ModelField.md) | ||||
|  - [ModelReturn](docs/ModelReturn.md) | ||||
|  - [MultiArrays](docs/MultiArrays.md) | ||||
|  - [Name](docs/Name.md) | ||||
|  - [NullableClass](docs/NullableClass.md) | ||||
|  - [NullableProperty](docs/NullableProperty.md) | ||||
|  | ||||
| @ -0,0 +1,30 @@ | ||||
| # MultiArrays | ||||
| 
 | ||||
| 
 | ||||
| ## Properties | ||||
| 
 | ||||
| Name | Type | Description | Notes | ||||
| ------------ | ------------- | ------------- | ------------- | ||||
| **tags** | [**List[Tag]**](Tag.md) |  | [optional]  | ||||
| **files** | [**List[File]**](File.md) | Another array of objects in addition to tags (mypy check to not to reuse the same iterator) | [optional]  | ||||
| 
 | ||||
| ## Example | ||||
| 
 | ||||
| ```python | ||||
| from petstore_api.models.multi_arrays import MultiArrays | ||||
| 
 | ||||
| # TODO update the JSON string below | ||||
| json = "{}" | ||||
| # create an instance of MultiArrays from a JSON string | ||||
| multi_arrays_instance = MultiArrays.from_json(json) | ||||
| # print the JSON string representation of the object | ||||
| print(MultiArrays.to_json()) | ||||
| 
 | ||||
| # convert the object into a dict | ||||
| multi_arrays_dict = multi_arrays_instance.to_dict() | ||||
| # create an instance of MultiArrays from a dict | ||||
| multi_arrays_from_dict = MultiArrays.from_dict(multi_arrays_dict) | ||||
| ``` | ||||
| [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) | ||||
| 
 | ||||
| 
 | ||||
| @ -97,6 +97,7 @@ from petstore_api.models.model200_response import Model200Response | ||||
| from petstore_api.models.model_api_response import ModelApiResponse | ||||
| from petstore_api.models.model_field import ModelField | ||||
| from petstore_api.models.model_return import ModelReturn | ||||
| from petstore_api.models.multi_arrays import MultiArrays | ||||
| from petstore_api.models.name import Name | ||||
| from petstore_api.models.nullable_class import NullableClass | ||||
| from petstore_api.models.nullable_property import NullableProperty | ||||
|  | ||||
| @ -72,6 +72,7 @@ from petstore_api.models.model200_response import Model200Response | ||||
| from petstore_api.models.model_api_response import ModelApiResponse | ||||
| from petstore_api.models.model_field import ModelField | ||||
| from petstore_api.models.model_return import ModelReturn | ||||
| from petstore_api.models.multi_arrays import MultiArrays | ||||
| from petstore_api.models.name import Name | ||||
| from petstore_api.models.nullable_class import NullableClass | ||||
| from petstore_api.models.nullable_property import NullableProperty | ||||
|  | ||||
| @ -72,10 +72,10 @@ class ArrayOfArrayOfModel(BaseModel): | ||||
|         # override the default output from pydantic by calling `to_dict()` of each item in another_property (list of list) | ||||
|         _items = [] | ||||
|         if self.another_property: | ||||
|             for _item in self.another_property: | ||||
|                 if _item: | ||||
|             for _item_another_property in self.another_property: | ||||
|                 if _item_another_property: | ||||
|                     _items.append( | ||||
|                          [_inner_item.to_dict() for _inner_item in _item if _inner_item is not None] | ||||
|                          [_inner_item.to_dict() for _inner_item in _item_another_property if _inner_item is not None] | ||||
|                     ) | ||||
|             _dict['another_property'] = _items | ||||
|         return _dict | ||||
|  | ||||
| @ -76,10 +76,10 @@ class ArrayTest(BaseModel): | ||||
|         # override the default output from pydantic by calling `to_dict()` of each item in array_array_of_model (list of list) | ||||
|         _items = [] | ||||
|         if self.array_array_of_model: | ||||
|             for _item in self.array_array_of_model: | ||||
|                 if _item: | ||||
|             for _item_array_array_of_model in self.array_array_of_model: | ||||
|                 if _item_array_array_of_model: | ||||
|                     _items.append( | ||||
|                          [_inner_item.to_dict() for _inner_item in _item if _inner_item is not None] | ||||
|                          [_inner_item.to_dict() for _inner_item in _item_array_array_of_model if _inner_item is not None] | ||||
|                     ) | ||||
|             _dict['array_array_of_model'] = _items | ||||
|         return _dict | ||||
|  | ||||
| @ -72,9 +72,9 @@ class CircularAllOfRef(BaseModel): | ||||
|         # override the default output from pydantic by calling `to_dict()` of each item in second_circular_all_of_ref (list) | ||||
|         _items = [] | ||||
|         if self.second_circular_all_of_ref: | ||||
|             for _item in self.second_circular_all_of_ref: | ||||
|                 if _item: | ||||
|                     _items.append(_item.to_dict()) | ||||
|             for _item_second_circular_all_of_ref in self.second_circular_all_of_ref: | ||||
|                 if _item_second_circular_all_of_ref: | ||||
|                     _items.append(_item_second_circular_all_of_ref.to_dict()) | ||||
|             _dict['secondCircularAllOfRef'] = _items | ||||
|         return _dict | ||||
| 
 | ||||
|  | ||||
| @ -76,9 +76,9 @@ class FileSchemaTestClass(BaseModel): | ||||
|         # override the default output from pydantic by calling `to_dict()` of each item in files (list) | ||||
|         _items = [] | ||||
|         if self.files: | ||||
|             for _item in self.files: | ||||
|                 if _item: | ||||
|                     _items.append(_item.to_dict()) | ||||
|             for _item_files in self.files: | ||||
|                 if _item_files: | ||||
|                     _items.append(_item_files.to_dict()) | ||||
|             _dict['files'] = _items | ||||
|         return _dict | ||||
| 
 | ||||
|  | ||||
| @ -72,9 +72,9 @@ class InputAllOf(BaseModel): | ||||
|         # override the default output from pydantic by calling `to_dict()` of each value in some_data (dict) | ||||
|         _field_dict = {} | ||||
|         if self.some_data: | ||||
|             for _key in self.some_data: | ||||
|                 if self.some_data[_key]: | ||||
|                     _field_dict[_key] = self.some_data[_key].to_dict() | ||||
|             for _key_some_data in self.some_data: | ||||
|                 if self.some_data[_key_some_data]: | ||||
|                     _field_dict[_key_some_data] = self.some_data[_key_some_data].to_dict() | ||||
|             _dict['some_data'] = _field_dict | ||||
|         return _dict | ||||
| 
 | ||||
|  | ||||
| @ -72,10 +72,10 @@ class MapOfArrayOfModel(BaseModel): | ||||
|         # override the default output from pydantic by calling `to_dict()` of each value in shop_id_to_org_online_lip_map (dict of array) | ||||
|         _field_dict_of_array = {} | ||||
|         if self.shop_id_to_org_online_lip_map: | ||||
|             for _key in self.shop_id_to_org_online_lip_map: | ||||
|                 if self.shop_id_to_org_online_lip_map[_key] is not None: | ||||
|                     _field_dict_of_array[_key] = [ | ||||
|                         _item.to_dict() for _item in self.shop_id_to_org_online_lip_map[_key] | ||||
|             for _key_shop_id_to_org_online_lip_map in self.shop_id_to_org_online_lip_map: | ||||
|                 if self.shop_id_to_org_online_lip_map[_key_shop_id_to_org_online_lip_map] is not None: | ||||
|                     _field_dict_of_array[_key_shop_id_to_org_online_lip_map] = [ | ||||
|                         _item.to_dict() for _item in self.shop_id_to_org_online_lip_map[_key_shop_id_to_org_online_lip_map] | ||||
|                     ] | ||||
|             _dict['shopIdToOrgOnlineLipMap'] = _field_dict_of_array | ||||
|         return _dict | ||||
|  | ||||
| @ -75,9 +75,9 @@ class MixedPropertiesAndAdditionalPropertiesClass(BaseModel): | ||||
|         # override the default output from pydantic by calling `to_dict()` of each value in map (dict) | ||||
|         _field_dict = {} | ||||
|         if self.map: | ||||
|             for _key in self.map: | ||||
|                 if self.map[_key]: | ||||
|                     _field_dict[_key] = self.map[_key].to_dict() | ||||
|             for _key_map in self.map: | ||||
|                 if self.map[_key_map]: | ||||
|                     _field_dict[_key_map] = self.map[_key_map].to_dict() | ||||
|             _dict['map'] = _field_dict | ||||
|         return _dict | ||||
| 
 | ||||
|  | ||||
| @ -0,0 +1,105 @@ | ||||
| # coding: utf-8 | ||||
| 
 | ||||
| """ | ||||
|     OpenAPI Petstore | ||||
| 
 | ||||
|     This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ | ||||
| 
 | ||||
|     The version of the OpenAPI document: 1.0.0 | ||||
|     Generated by OpenAPI Generator (https://openapi-generator.tech) | ||||
| 
 | ||||
|     Do not edit the class manually. | ||||
| """  # noqa: E501 | ||||
| 
 | ||||
| 
 | ||||
| from __future__ import annotations | ||||
| import pprint | ||||
| import re  # noqa: F401 | ||||
| import json | ||||
| 
 | ||||
| from pydantic import BaseModel, ConfigDict, Field | ||||
| from typing import Any, ClassVar, Dict, List, Optional | ||||
| from petstore_api.models.file import File | ||||
| from petstore_api.models.tag import Tag | ||||
| from typing import Optional, Set | ||||
| from typing_extensions import Self | ||||
| 
 | ||||
| class MultiArrays(BaseModel): | ||||
|     """ | ||||
|     MultiArrays | ||||
|     """ # noqa: E501 | ||||
|     tags: Optional[List[Tag]] = None | ||||
|     files: Optional[List[File]] = Field(default=None, description="Another array of objects in addition to tags (mypy check to not to reuse the same iterator)") | ||||
|     __properties: ClassVar[List[str]] = ["tags", "files"] | ||||
| 
 | ||||
|     model_config = ConfigDict( | ||||
|         populate_by_name=True, | ||||
|         validate_assignment=True, | ||||
|         protected_namespaces=(), | ||||
|     ) | ||||
| 
 | ||||
| 
 | ||||
|     def to_str(self) -> str: | ||||
|         """Returns the string representation of the model using alias""" | ||||
|         return pprint.pformat(self.model_dump(by_alias=True)) | ||||
| 
 | ||||
|     def to_json(self) -> str: | ||||
|         """Returns the JSON representation of the model using alias""" | ||||
|         # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead | ||||
|         return json.dumps(self.to_dict()) | ||||
| 
 | ||||
|     @classmethod | ||||
|     def from_json(cls, json_str: str) -> Optional[Self]: | ||||
|         """Create an instance of MultiArrays from a JSON string""" | ||||
|         return cls.from_dict(json.loads(json_str)) | ||||
| 
 | ||||
|     def to_dict(self) -> Dict[str, Any]: | ||||
|         """Return the dictionary representation of the model using alias. | ||||
| 
 | ||||
|         This has the following differences from calling pydantic's | ||||
|         `self.model_dump(by_alias=True)`: | ||||
| 
 | ||||
|         * `None` is only added to the output dict for nullable fields that | ||||
|           were set at model initialization. Other fields with value `None` | ||||
|           are ignored. | ||||
|         """ | ||||
|         excluded_fields: Set[str] = set([ | ||||
|         ]) | ||||
| 
 | ||||
|         _dict = self.model_dump( | ||||
|             by_alias=True, | ||||
|             exclude=excluded_fields, | ||||
|             exclude_none=True, | ||||
|         ) | ||||
|         # override the default output from pydantic by calling `to_dict()` of each item in tags (list) | ||||
|         _items = [] | ||||
|         if self.tags: | ||||
|             for _item_tags in self.tags: | ||||
|                 if _item_tags: | ||||
|                     _items.append(_item_tags.to_dict()) | ||||
|             _dict['tags'] = _items | ||||
|         # override the default output from pydantic by calling `to_dict()` of each item in files (list) | ||||
|         _items = [] | ||||
|         if self.files: | ||||
|             for _item_files in self.files: | ||||
|                 if _item_files: | ||||
|                     _items.append(_item_files.to_dict()) | ||||
|             _dict['files'] = _items | ||||
|         return _dict | ||||
| 
 | ||||
|     @classmethod | ||||
|     def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: | ||||
|         """Create an instance of MultiArrays from a dict""" | ||||
|         if obj is None: | ||||
|             return None | ||||
| 
 | ||||
|         if not isinstance(obj, dict): | ||||
|             return cls.model_validate(obj) | ||||
| 
 | ||||
|         _obj = cls.model_validate({ | ||||
|             "tags": [Tag.from_dict(_item) for _item in obj["tags"]] if obj.get("tags") is not None else None, | ||||
|             "files": [File.from_dict(_item) for _item in obj["files"]] if obj.get("files") is not None else None | ||||
|         }) | ||||
|         return _obj | ||||
| 
 | ||||
| 
 | ||||
| @ -72,9 +72,9 @@ class Parent(BaseModel): | ||||
|         # override the default output from pydantic by calling `to_dict()` of each value in optional_dict (dict) | ||||
|         _field_dict = {} | ||||
|         if self.optional_dict: | ||||
|             for _key in self.optional_dict: | ||||
|                 if self.optional_dict[_key]: | ||||
|                     _field_dict[_key] = self.optional_dict[_key].to_dict() | ||||
|             for _key_optional_dict in self.optional_dict: | ||||
|                 if self.optional_dict[_key_optional_dict]: | ||||
|                     _field_dict[_key_optional_dict] = self.optional_dict[_key_optional_dict].to_dict() | ||||
|             _dict['optionalDict'] = _field_dict | ||||
|         return _dict | ||||
| 
 | ||||
|  | ||||
| @ -72,9 +72,9 @@ class ParentWithOptionalDict(BaseModel): | ||||
|         # override the default output from pydantic by calling `to_dict()` of each value in optional_dict (dict) | ||||
|         _field_dict = {} | ||||
|         if self.optional_dict: | ||||
|             for _key in self.optional_dict: | ||||
|                 if self.optional_dict[_key]: | ||||
|                     _field_dict[_key] = self.optional_dict[_key].to_dict() | ||||
|             for _key_optional_dict in self.optional_dict: | ||||
|                 if self.optional_dict[_key_optional_dict]: | ||||
|                     _field_dict[_key_optional_dict] = self.optional_dict[_key_optional_dict].to_dict() | ||||
|             _dict['optionalDict'] = _field_dict | ||||
|         return _dict | ||||
| 
 | ||||
|  | ||||
| @ -92,9 +92,9 @@ class Pet(BaseModel): | ||||
|         # override the default output from pydantic by calling `to_dict()` of each item in tags (list) | ||||
|         _items = [] | ||||
|         if self.tags: | ||||
|             for _item in self.tags: | ||||
|                 if _item: | ||||
|                     _items.append(_item.to_dict()) | ||||
|             for _item_tags in self.tags: | ||||
|                 if _item_tags: | ||||
|                     _items.append(_item_tags.to_dict()) | ||||
|             _dict['tags'] = _items | ||||
|         return _dict | ||||
| 
 | ||||
|  | ||||
| @ -72,9 +72,9 @@ class PropertyMap(BaseModel): | ||||
|         # override the default output from pydantic by calling `to_dict()` of each value in some_data (dict) | ||||
|         _field_dict = {} | ||||
|         if self.some_data: | ||||
|             for _key in self.some_data: | ||||
|                 if self.some_data[_key]: | ||||
|                     _field_dict[_key] = self.some_data[_key].to_dict() | ||||
|             for _key_some_data in self.some_data: | ||||
|                 if self.some_data[_key_some_data]: | ||||
|                     _field_dict[_key_some_data] = self.some_data[_key_some_data].to_dict() | ||||
|             _dict['some_data'] = _field_dict | ||||
|         return _dict | ||||
| 
 | ||||
|  | ||||
| @ -72,9 +72,9 @@ class SecondCircularAllOfRef(BaseModel): | ||||
|         # override the default output from pydantic by calling `to_dict()` of each item in circular_all_of_ref (list) | ||||
|         _items = [] | ||||
|         if self.circular_all_of_ref: | ||||
|             for _item in self.circular_all_of_ref: | ||||
|                 if _item: | ||||
|                     _items.append(_item.to_dict()) | ||||
|             for _item_circular_all_of_ref in self.circular_all_of_ref: | ||||
|                 if _item_circular_all_of_ref: | ||||
|                     _items.append(_item_circular_all_of_ref.to_dict()) | ||||
|             _dict['circularAllOfRef'] = _items | ||||
|         return _dict | ||||
| 
 | ||||
|  | ||||
| @ -72,10 +72,10 @@ class UnnamedDictWithAdditionalModelListProperties(BaseModel): | ||||
|         # override the default output from pydantic by calling `to_dict()` of each value in dict_property (dict of array) | ||||
|         _field_dict_of_array = {} | ||||
|         if self.dict_property: | ||||
|             for _key in self.dict_property: | ||||
|                 if self.dict_property[_key] is not None: | ||||
|                     _field_dict_of_array[_key] = [ | ||||
|                         _item.to_dict() for _item in self.dict_property[_key] | ||||
|             for _key_dict_property in self.dict_property: | ||||
|                 if self.dict_property[_key_dict_property] is not None: | ||||
|                     _field_dict_of_array[_key_dict_property] = [ | ||||
|                         _item.to_dict() for _item in self.dict_property[_key_dict_property] | ||||
|                     ] | ||||
|             _dict['dictProperty'] = _field_dict_of_array | ||||
|         return _dict | ||||
|  | ||||
| @ -0,0 +1,59 @@ | ||||
| # coding: utf-8 | ||||
| 
 | ||||
| """ | ||||
|     OpenAPI Petstore | ||||
| 
 | ||||
|     This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ | ||||
| 
 | ||||
|     The version of the OpenAPI document: 1.0.0 | ||||
|     Generated by OpenAPI Generator (https://openapi-generator.tech) | ||||
| 
 | ||||
|     Do not edit the class manually. | ||||
| """  # noqa: E501 | ||||
| 
 | ||||
| 
 | ||||
| import unittest | ||||
| 
 | ||||
| from petstore_api.models.multi_arrays import MultiArrays | ||||
| 
 | ||||
| class TestMultiArrays(unittest.TestCase): | ||||
|     """MultiArrays unit test stubs""" | ||||
| 
 | ||||
|     def setUp(self): | ||||
|         pass | ||||
| 
 | ||||
|     def tearDown(self): | ||||
|         pass | ||||
| 
 | ||||
|     def make_instance(self, include_optional) -> MultiArrays: | ||||
|         """Test MultiArrays | ||||
|             include_optional is a boolean, when False only required | ||||
|             params are included, when True both required and | ||||
|             optional params are included """ | ||||
|         # uncomment below to create an instance of `MultiArrays` | ||||
|         """ | ||||
|         model = MultiArrays() | ||||
|         if include_optional: | ||||
|             return MultiArrays( | ||||
|                 tags = [ | ||||
|                     petstore_api.models.tag.Tag( | ||||
|                         id = 56,  | ||||
|                         name = '', ) | ||||
|                     ], | ||||
|                 files = [ | ||||
|                     petstore_api.models.file.File( | ||||
|                         source_uri = '', ) | ||||
|                     ] | ||||
|             ) | ||||
|         else: | ||||
|             return MultiArrays( | ||||
|         ) | ||||
|         """ | ||||
| 
 | ||||
|     def testMultiArrays(self): | ||||
|         """Test MultiArrays""" | ||||
|         # inst_req_only = self.make_instance(include_optional=False) | ||||
|         # inst_req_and_optional = self.make_instance(include_optional=True) | ||||
| 
 | ||||
| if __name__ == '__main__': | ||||
|     unittest.main() | ||||
| @ -66,6 +66,7 @@ docs/MapTest.md | ||||
| docs/MixedPropertiesAndAdditionalPropertiesClass.md | ||||
| docs/Model200Response.md | ||||
| docs/ModelReturn.md | ||||
| docs/MultiArrays.md | ||||
| docs/Name.md | ||||
| docs/NullableClass.md | ||||
| docs/NullableProperty.md | ||||
| @ -188,6 +189,7 @@ petstore_api/models/map_test.py | ||||
| petstore_api/models/mixed_properties_and_additional_properties_class.py | ||||
| petstore_api/models/model200_response.py | ||||
| petstore_api/models/model_return.py | ||||
| petstore_api/models/multi_arrays.py | ||||
| petstore_api/models/name.py | ||||
| petstore_api/models/nullable_class.py | ||||
| petstore_api/models/nullable_property.py | ||||
|  | ||||
| @ -209,6 +209,7 @@ Class | Method | HTTP request | Description | ||||
|  - [MixedPropertiesAndAdditionalPropertiesClass](docs/MixedPropertiesAndAdditionalPropertiesClass.md) | ||||
|  - [Model200Response](docs/Model200Response.md) | ||||
|  - [ModelReturn](docs/ModelReturn.md) | ||||
|  - [MultiArrays](docs/MultiArrays.md) | ||||
|  - [Name](docs/Name.md) | ||||
|  - [NullableClass](docs/NullableClass.md) | ||||
|  - [NullableProperty](docs/NullableProperty.md) | ||||
|  | ||||
| @ -0,0 +1,29 @@ | ||||
| # MultiArrays | ||||
| 
 | ||||
| 
 | ||||
| ## Properties | ||||
| Name | Type | Description | Notes | ||||
| ------------ | ------------- | ------------- | ------------- | ||||
| **tags** | [**List[Tag]**](Tag.md) |  | [optional]  | ||||
| **files** | [**List[File]**](File.md) | Another array of objects in addition to tags (mypy check to not to reuse the same iterator) | [optional]  | ||||
| 
 | ||||
| ## Example | ||||
| 
 | ||||
| ```python | ||||
| from petstore_api.models.multi_arrays import MultiArrays | ||||
| 
 | ||||
| # TODO update the JSON string below | ||||
| json = "{}" | ||||
| # create an instance of MultiArrays from a JSON string | ||||
| multi_arrays_instance = MultiArrays.from_json(json) | ||||
| # print the JSON string representation of the object | ||||
| print MultiArrays.to_json() | ||||
| 
 | ||||
| # convert the object into a dict | ||||
| multi_arrays_dict = multi_arrays_instance.to_dict() | ||||
| # create an instance of MultiArrays from a dict | ||||
| multi_arrays_from_dict = MultiArrays.from_dict(multi_arrays_dict) | ||||
| ``` | ||||
| [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) | ||||
| 
 | ||||
| 
 | ||||
| @ -97,6 +97,7 @@ from petstore_api.models.map_test import MapTest | ||||
| from petstore_api.models.mixed_properties_and_additional_properties_class import MixedPropertiesAndAdditionalPropertiesClass | ||||
| from petstore_api.models.model200_response import Model200Response | ||||
| from petstore_api.models.model_return import ModelReturn | ||||
| from petstore_api.models.multi_arrays import MultiArrays | ||||
| from petstore_api.models.name import Name | ||||
| from petstore_api.models.nullable_class import NullableClass | ||||
| from petstore_api.models.nullable_property import NullableProperty | ||||
|  | ||||
| @ -72,6 +72,7 @@ from petstore_api.models.map_test import MapTest | ||||
| from petstore_api.models.mixed_properties_and_additional_properties_class import MixedPropertiesAndAdditionalPropertiesClass | ||||
| from petstore_api.models.model200_response import Model200Response | ||||
| from petstore_api.models.model_return import ModelReturn | ||||
| from petstore_api.models.multi_arrays import MultiArrays | ||||
| from petstore_api.models.name import Name | ||||
| from petstore_api.models.nullable_class import NullableClass | ||||
| from petstore_api.models.nullable_property import NullableProperty | ||||
|  | ||||
| @ -0,0 +1,89 @@ | ||||
| # coding: utf-8 | ||||
| 
 | ||||
| """ | ||||
|     OpenAPI Petstore | ||||
| 
 | ||||
|     This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ | ||||
| 
 | ||||
|     The version of the OpenAPI document: 1.0.0 | ||||
|     Generated by OpenAPI Generator (https://openapi-generator.tech) | ||||
| 
 | ||||
|     Do not edit the class manually. | ||||
| """  # noqa: E501 | ||||
| 
 | ||||
| 
 | ||||
| from __future__ import annotations | ||||
| import pprint | ||||
| import re  # noqa: F401 | ||||
| import json | ||||
| 
 | ||||
| 
 | ||||
| from typing import List, Optional | ||||
| from pydantic import BaseModel, Field, conlist | ||||
| from petstore_api.models.file import File | ||||
| from petstore_api.models.tag import Tag | ||||
| 
 | ||||
| class MultiArrays(BaseModel): | ||||
|     """ | ||||
|     MultiArrays | ||||
|     """ | ||||
|     tags: Optional[conlist(Tag)] = None | ||||
|     files: Optional[conlist(File)] = Field(default=None, description="Another array of objects in addition to tags (mypy check to not to reuse the same iterator)") | ||||
|     __properties = ["tags", "files"] | ||||
| 
 | ||||
|     class Config: | ||||
|         """Pydantic configuration""" | ||||
|         allow_population_by_field_name = True | ||||
|         validate_assignment = True | ||||
| 
 | ||||
|     def to_str(self) -> str: | ||||
|         """Returns the string representation of the model using alias""" | ||||
|         return pprint.pformat(self.dict(by_alias=True)) | ||||
| 
 | ||||
|     def to_json(self) -> str: | ||||
|         """Returns the JSON representation of the model using alias""" | ||||
|         return json.dumps(self.to_dict()) | ||||
| 
 | ||||
|     @classmethod | ||||
|     def from_json(cls, json_str: str) -> MultiArrays: | ||||
|         """Create an instance of MultiArrays from a JSON string""" | ||||
|         return cls.from_dict(json.loads(json_str)) | ||||
| 
 | ||||
|     def to_dict(self): | ||||
|         """Returns the dictionary representation of the model using alias""" | ||||
|         _dict = self.dict(by_alias=True, | ||||
|                           exclude={ | ||||
|                           }, | ||||
|                           exclude_none=True) | ||||
|         # override the default output from pydantic by calling `to_dict()` of each item in tags (list) | ||||
|         _items = [] | ||||
|         if self.tags: | ||||
|             for _item in self.tags: | ||||
|                 if _item: | ||||
|                     _items.append(_item.to_dict()) | ||||
|             _dict['tags'] = _items | ||||
|         # override the default output from pydantic by calling `to_dict()` of each item in files (list) | ||||
|         _items = [] | ||||
|         if self.files: | ||||
|             for _item in self.files: | ||||
|                 if _item: | ||||
|                     _items.append(_item.to_dict()) | ||||
|             _dict['files'] = _items | ||||
|         return _dict | ||||
| 
 | ||||
|     @classmethod | ||||
|     def from_dict(cls, obj: dict) -> MultiArrays: | ||||
|         """Create an instance of MultiArrays from a dict""" | ||||
|         if obj is None: | ||||
|             return None | ||||
| 
 | ||||
|         if not isinstance(obj, dict): | ||||
|             return MultiArrays.parse_obj(obj) | ||||
| 
 | ||||
|         _obj = MultiArrays.parse_obj({ | ||||
|             "tags": [Tag.from_dict(_item) for _item in obj.get("tags")] if obj.get("tags") is not None else None, | ||||
|             "files": [File.from_dict(_item) for _item in obj.get("files")] if obj.get("files") is not None else None | ||||
|         }) | ||||
|         return _obj | ||||
| 
 | ||||
| 
 | ||||
| @ -0,0 +1,60 @@ | ||||
| # coding: utf-8 | ||||
| 
 | ||||
| """ | ||||
|     OpenAPI Petstore | ||||
| 
 | ||||
|     This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ | ||||
| 
 | ||||
|     The version of the OpenAPI document: 1.0.0 | ||||
|     Generated by OpenAPI Generator (https://openapi-generator.tech) | ||||
| 
 | ||||
|     Do not edit the class manually. | ||||
| """  # noqa: E501 | ||||
| 
 | ||||
| 
 | ||||
| import unittest | ||||
| import datetime | ||||
| 
 | ||||
| from petstore_api.models.multi_arrays import MultiArrays  # noqa: E501 | ||||
| 
 | ||||
| class TestMultiArrays(unittest.TestCase): | ||||
|     """MultiArrays unit test stubs""" | ||||
| 
 | ||||
|     def setUp(self): | ||||
|         pass | ||||
| 
 | ||||
|     def tearDown(self): | ||||
|         pass | ||||
| 
 | ||||
|     def make_instance(self, include_optional) -> MultiArrays: | ||||
|         """Test MultiArrays | ||||
|             include_option is a boolean, when False only required | ||||
|             params are included, when True both required and | ||||
|             optional params are included """ | ||||
|         # uncomment below to create an instance of `MultiArrays` | ||||
|         """ | ||||
|         model = MultiArrays()  # noqa: E501 | ||||
|         if include_optional: | ||||
|             return MultiArrays( | ||||
|                 tags = [ | ||||
|                     petstore_api.models.tag.Tag( | ||||
|                         id = 56,  | ||||
|                         name = '', ) | ||||
|                     ], | ||||
|                 files = [ | ||||
|                     petstore_api.models.file.File( | ||||
|                         source_uri = '', ) | ||||
|                     ] | ||||
|             ) | ||||
|         else: | ||||
|             return MultiArrays( | ||||
|         ) | ||||
|         """ | ||||
| 
 | ||||
|     def testMultiArrays(self): | ||||
|         """Test MultiArrays""" | ||||
|         # inst_req_only = self.make_instance(include_optional=False) | ||||
|         # inst_req_and_optional = self.make_instance(include_optional=True) | ||||
| 
 | ||||
| if __name__ == '__main__': | ||||
|     unittest.main() | ||||
| @ -66,6 +66,7 @@ docs/MapTest.md | ||||
| docs/MixedPropertiesAndAdditionalPropertiesClass.md | ||||
| docs/Model200Response.md | ||||
| docs/ModelReturn.md | ||||
| docs/MultiArrays.md | ||||
| docs/Name.md | ||||
| docs/NullableClass.md | ||||
| docs/NullableProperty.md | ||||
| @ -188,6 +189,7 @@ petstore_api/models/map_test.py | ||||
| petstore_api/models/mixed_properties_and_additional_properties_class.py | ||||
| petstore_api/models/model200_response.py | ||||
| petstore_api/models/model_return.py | ||||
| petstore_api/models/multi_arrays.py | ||||
| petstore_api/models/name.py | ||||
| petstore_api/models/nullable_class.py | ||||
| petstore_api/models/nullable_property.py | ||||
|  | ||||
| @ -209,6 +209,7 @@ Class | Method | HTTP request | Description | ||||
|  - [MixedPropertiesAndAdditionalPropertiesClass](docs/MixedPropertiesAndAdditionalPropertiesClass.md) | ||||
|  - [Model200Response](docs/Model200Response.md) | ||||
|  - [ModelReturn](docs/ModelReturn.md) | ||||
|  - [MultiArrays](docs/MultiArrays.md) | ||||
|  - [Name](docs/Name.md) | ||||
|  - [NullableClass](docs/NullableClass.md) | ||||
|  - [NullableProperty](docs/NullableProperty.md) | ||||
|  | ||||
| @ -0,0 +1,29 @@ | ||||
| # MultiArrays | ||||
| 
 | ||||
| 
 | ||||
| ## Properties | ||||
| Name | Type | Description | Notes | ||||
| ------------ | ------------- | ------------- | ------------- | ||||
| **tags** | [**List[Tag]**](Tag.md) |  | [optional]  | ||||
| **files** | [**List[File]**](File.md) | Another array of objects in addition to tags (mypy check to not to reuse the same iterator) | [optional]  | ||||
| 
 | ||||
| ## Example | ||||
| 
 | ||||
| ```python | ||||
| from petstore_api.models.multi_arrays import MultiArrays | ||||
| 
 | ||||
| # TODO update the JSON string below | ||||
| json = "{}" | ||||
| # create an instance of MultiArrays from a JSON string | ||||
| multi_arrays_instance = MultiArrays.from_json(json) | ||||
| # print the JSON string representation of the object | ||||
| print MultiArrays.to_json() | ||||
| 
 | ||||
| # convert the object into a dict | ||||
| multi_arrays_dict = multi_arrays_instance.to_dict() | ||||
| # create an instance of MultiArrays from a dict | ||||
| multi_arrays_from_dict = MultiArrays.from_dict(multi_arrays_dict) | ||||
| ``` | ||||
| [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) | ||||
| 
 | ||||
| 
 | ||||
| @ -97,6 +97,7 @@ from petstore_api.models.map_test import MapTest | ||||
| from petstore_api.models.mixed_properties_and_additional_properties_class import MixedPropertiesAndAdditionalPropertiesClass | ||||
| from petstore_api.models.model200_response import Model200Response | ||||
| from petstore_api.models.model_return import ModelReturn | ||||
| from petstore_api.models.multi_arrays import MultiArrays | ||||
| from petstore_api.models.name import Name | ||||
| from petstore_api.models.nullable_class import NullableClass | ||||
| from petstore_api.models.nullable_property import NullableProperty | ||||
|  | ||||
| @ -72,6 +72,7 @@ from petstore_api.models.map_test import MapTest | ||||
| from petstore_api.models.mixed_properties_and_additional_properties_class import MixedPropertiesAndAdditionalPropertiesClass | ||||
| from petstore_api.models.model200_response import Model200Response | ||||
| from petstore_api.models.model_return import ModelReturn | ||||
| from petstore_api.models.multi_arrays import MultiArrays | ||||
| from petstore_api.models.name import Name | ||||
| from petstore_api.models.nullable_class import NullableClass | ||||
| from petstore_api.models.nullable_property import NullableProperty | ||||
|  | ||||
| @ -0,0 +1,101 @@ | ||||
| # coding: utf-8 | ||||
| 
 | ||||
| """ | ||||
|     OpenAPI Petstore | ||||
| 
 | ||||
|     This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ | ||||
| 
 | ||||
|     The version of the OpenAPI document: 1.0.0 | ||||
|     Generated by OpenAPI Generator (https://openapi-generator.tech) | ||||
| 
 | ||||
|     Do not edit the class manually. | ||||
| """  # noqa: E501 | ||||
| 
 | ||||
| 
 | ||||
| from __future__ import annotations | ||||
| import pprint | ||||
| import re  # noqa: F401 | ||||
| import json | ||||
| 
 | ||||
| 
 | ||||
| from typing import Any, Dict, List, Optional | ||||
| from pydantic import BaseModel, Field, conlist | ||||
| from petstore_api.models.file import File | ||||
| from petstore_api.models.tag import Tag | ||||
| 
 | ||||
| class MultiArrays(BaseModel): | ||||
|     """ | ||||
|     MultiArrays | ||||
|     """ | ||||
|     tags: Optional[conlist(Tag)] = None | ||||
|     files: Optional[conlist(File)] = Field(default=None, description="Another array of objects in addition to tags (mypy check to not to reuse the same iterator)") | ||||
|     additional_properties: Dict[str, Any] = {} | ||||
|     __properties = ["tags", "files"] | ||||
| 
 | ||||
|     class Config: | ||||
|         """Pydantic configuration""" | ||||
|         allow_population_by_field_name = True | ||||
|         validate_assignment = True | ||||
| 
 | ||||
|     def to_str(self) -> str: | ||||
|         """Returns the string representation of the model using alias""" | ||||
|         return pprint.pformat(self.dict(by_alias=True)) | ||||
| 
 | ||||
|     def to_json(self) -> str: | ||||
|         """Returns the JSON representation of the model using alias""" | ||||
|         return json.dumps(self.to_dict()) | ||||
| 
 | ||||
|     @classmethod | ||||
|     def from_json(cls, json_str: str) -> MultiArrays: | ||||
|         """Create an instance of MultiArrays from a JSON string""" | ||||
|         return cls.from_dict(json.loads(json_str)) | ||||
| 
 | ||||
|     def to_dict(self): | ||||
|         """Returns the dictionary representation of the model using alias""" | ||||
|         _dict = self.dict(by_alias=True, | ||||
|                           exclude={ | ||||
|                             "additional_properties" | ||||
|                           }, | ||||
|                           exclude_none=True) | ||||
|         # override the default output from pydantic by calling `to_dict()` of each item in tags (list) | ||||
|         _items = [] | ||||
|         if self.tags: | ||||
|             for _item in self.tags: | ||||
|                 if _item: | ||||
|                     _items.append(_item.to_dict()) | ||||
|             _dict['tags'] = _items | ||||
|         # override the default output from pydantic by calling `to_dict()` of each item in files (list) | ||||
|         _items = [] | ||||
|         if self.files: | ||||
|             for _item in self.files: | ||||
|                 if _item: | ||||
|                     _items.append(_item.to_dict()) | ||||
|             _dict['files'] = _items | ||||
|         # puts key-value pairs in additional_properties in the top level | ||||
|         if self.additional_properties is not None: | ||||
|             for _key, _value in self.additional_properties.items(): | ||||
|                 _dict[_key] = _value | ||||
| 
 | ||||
|         return _dict | ||||
| 
 | ||||
|     @classmethod | ||||
|     def from_dict(cls, obj: dict) -> MultiArrays: | ||||
|         """Create an instance of MultiArrays from a dict""" | ||||
|         if obj is None: | ||||
|             return None | ||||
| 
 | ||||
|         if not isinstance(obj, dict): | ||||
|             return MultiArrays.parse_obj(obj) | ||||
| 
 | ||||
|         _obj = MultiArrays.parse_obj({ | ||||
|             "tags": [Tag.from_dict(_item) for _item in obj.get("tags")] if obj.get("tags") is not None else None, | ||||
|             "files": [File.from_dict(_item) for _item in obj.get("files")] if obj.get("files") is not None else None | ||||
|         }) | ||||
|         # store additional fields in additional_properties | ||||
|         for _key in obj.keys(): | ||||
|             if _key not in cls.__properties: | ||||
|                 _obj.additional_properties[_key] = obj.get(_key) | ||||
| 
 | ||||
|         return _obj | ||||
| 
 | ||||
| 
 | ||||
| @ -0,0 +1,60 @@ | ||||
| # coding: utf-8 | ||||
| 
 | ||||
| """ | ||||
|     OpenAPI Petstore | ||||
| 
 | ||||
|     This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ | ||||
| 
 | ||||
|     The version of the OpenAPI document: 1.0.0 | ||||
|     Generated by OpenAPI Generator (https://openapi-generator.tech) | ||||
| 
 | ||||
|     Do not edit the class manually. | ||||
| """  # noqa: E501 | ||||
| 
 | ||||
| 
 | ||||
| import unittest | ||||
| import datetime | ||||
| 
 | ||||
| from petstore_api.models.multi_arrays import MultiArrays  # noqa: E501 | ||||
| 
 | ||||
| class TestMultiArrays(unittest.TestCase): | ||||
|     """MultiArrays unit test stubs""" | ||||
| 
 | ||||
|     def setUp(self): | ||||
|         pass | ||||
| 
 | ||||
|     def tearDown(self): | ||||
|         pass | ||||
| 
 | ||||
|     def make_instance(self, include_optional) -> MultiArrays: | ||||
|         """Test MultiArrays | ||||
|             include_option is a boolean, when False only required | ||||
|             params are included, when True both required and | ||||
|             optional params are included """ | ||||
|         # uncomment below to create an instance of `MultiArrays` | ||||
|         """ | ||||
|         model = MultiArrays()  # noqa: E501 | ||||
|         if include_optional: | ||||
|             return MultiArrays( | ||||
|                 tags = [ | ||||
|                     petstore_api.models.tag.Tag( | ||||
|                         id = 56,  | ||||
|                         name = '', ) | ||||
|                     ], | ||||
|                 files = [ | ||||
|                     petstore_api.models.file.File( | ||||
|                         source_uri = '', ) | ||||
|                     ] | ||||
|             ) | ||||
|         else: | ||||
|             return MultiArrays( | ||||
|         ) | ||||
|         """ | ||||
| 
 | ||||
|     def testMultiArrays(self): | ||||
|         """Test MultiArrays""" | ||||
|         # inst_req_only = self.make_instance(include_optional=False) | ||||
|         # inst_req_and_optional = self.make_instance(include_optional=True) | ||||
| 
 | ||||
| if __name__ == '__main__': | ||||
|     unittest.main() | ||||
| @ -66,6 +66,7 @@ docs/Model200Response.md | ||||
| docs/ModelApiResponse.md | ||||
| docs/ModelField.md | ||||
| docs/ModelReturn.md | ||||
| docs/MultiArrays.md | ||||
| docs/Name.md | ||||
| docs/NullableClass.md | ||||
| docs/NullableProperty.md | ||||
| @ -188,6 +189,7 @@ petstore_api/models/model200_response.py | ||||
| petstore_api/models/model_api_response.py | ||||
| petstore_api/models/model_field.py | ||||
| petstore_api/models/model_return.py | ||||
| petstore_api/models/multi_arrays.py | ||||
| petstore_api/models/name.py | ||||
| petstore_api/models/nullable_class.py | ||||
| petstore_api/models/nullable_property.py | ||||
|  | ||||
| @ -208,6 +208,7 @@ Class | Method | HTTP request | Description | ||||
|  - [ModelApiResponse](docs/ModelApiResponse.md) | ||||
|  - [ModelField](docs/ModelField.md) | ||||
|  - [ModelReturn](docs/ModelReturn.md) | ||||
|  - [MultiArrays](docs/MultiArrays.md) | ||||
|  - [Name](docs/Name.md) | ||||
|  - [NullableClass](docs/NullableClass.md) | ||||
|  - [NullableProperty](docs/NullableProperty.md) | ||||
|  | ||||
							
								
								
									
										30
									
								
								samples/openapi3/client/petstore/python/docs/MultiArrays.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								samples/openapi3/client/petstore/python/docs/MultiArrays.md
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,30 @@ | ||||
| # MultiArrays | ||||
| 
 | ||||
| 
 | ||||
| ## Properties | ||||
| 
 | ||||
| Name | Type | Description | Notes | ||||
| ------------ | ------------- | ------------- | ------------- | ||||
| **tags** | [**List[Tag]**](Tag.md) |  | [optional]  | ||||
| **files** | [**List[File]**](File.md) | Another array of objects in addition to tags (mypy check to not to reuse the same iterator) | [optional]  | ||||
| 
 | ||||
| ## Example | ||||
| 
 | ||||
| ```python | ||||
| from petstore_api.models.multi_arrays import MultiArrays | ||||
| 
 | ||||
| # TODO update the JSON string below | ||||
| json = "{}" | ||||
| # create an instance of MultiArrays from a JSON string | ||||
| multi_arrays_instance = MultiArrays.from_json(json) | ||||
| # print the JSON string representation of the object | ||||
| print(MultiArrays.to_json()) | ||||
| 
 | ||||
| # convert the object into a dict | ||||
| multi_arrays_dict = multi_arrays_instance.to_dict() | ||||
| # create an instance of MultiArrays from a dict | ||||
| multi_arrays_from_dict = MultiArrays.from_dict(multi_arrays_dict) | ||||
| ``` | ||||
| [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) | ||||
| 
 | ||||
| 
 | ||||
| @ -97,6 +97,7 @@ from petstore_api.models.model200_response import Model200Response | ||||
| from petstore_api.models.model_api_response import ModelApiResponse | ||||
| from petstore_api.models.model_field import ModelField | ||||
| from petstore_api.models.model_return import ModelReturn | ||||
| from petstore_api.models.multi_arrays import MultiArrays | ||||
| from petstore_api.models.name import Name | ||||
| from petstore_api.models.nullable_class import NullableClass | ||||
| from petstore_api.models.nullable_property import NullableProperty | ||||
|  | ||||
| @ -72,6 +72,7 @@ from petstore_api.models.model200_response import Model200Response | ||||
| from petstore_api.models.model_api_response import ModelApiResponse | ||||
| from petstore_api.models.model_field import ModelField | ||||
| from petstore_api.models.model_return import ModelReturn | ||||
| from petstore_api.models.multi_arrays import MultiArrays | ||||
| from petstore_api.models.name import Name | ||||
| from petstore_api.models.nullable_class import NullableClass | ||||
| from petstore_api.models.nullable_property import NullableProperty | ||||
|  | ||||
| @ -75,10 +75,10 @@ class ArrayOfArrayOfModel(BaseModel): | ||||
|         # override the default output from pydantic by calling `to_dict()` of each item in another_property (list of list) | ||||
|         _items = [] | ||||
|         if self.another_property: | ||||
|             for _item in self.another_property: | ||||
|                 if _item: | ||||
|             for _item_another_property in self.another_property: | ||||
|                 if _item_another_property: | ||||
|                     _items.append( | ||||
|                          [_inner_item.to_dict() for _inner_item in _item if _inner_item is not None] | ||||
|                          [_inner_item.to_dict() for _inner_item in _item_another_property if _inner_item is not None] | ||||
|                     ) | ||||
|             _dict['another_property'] = _items | ||||
|         # puts key-value pairs in additional_properties in the top level | ||||
|  | ||||
| @ -79,10 +79,10 @@ class ArrayTest(BaseModel): | ||||
|         # override the default output from pydantic by calling `to_dict()` of each item in array_array_of_model (list of list) | ||||
|         _items = [] | ||||
|         if self.array_array_of_model: | ||||
|             for _item in self.array_array_of_model: | ||||
|                 if _item: | ||||
|             for _item_array_array_of_model in self.array_array_of_model: | ||||
|                 if _item_array_array_of_model: | ||||
|                     _items.append( | ||||
|                          [_inner_item.to_dict() for _inner_item in _item if _inner_item is not None] | ||||
|                          [_inner_item.to_dict() for _inner_item in _item_array_array_of_model if _inner_item is not None] | ||||
|                     ) | ||||
|             _dict['array_array_of_model'] = _items | ||||
|         # puts key-value pairs in additional_properties in the top level | ||||
|  | ||||
| @ -75,9 +75,9 @@ class CircularAllOfRef(BaseModel): | ||||
|         # override the default output from pydantic by calling `to_dict()` of each item in second_circular_all_of_ref (list) | ||||
|         _items = [] | ||||
|         if self.second_circular_all_of_ref: | ||||
|             for _item in self.second_circular_all_of_ref: | ||||
|                 if _item: | ||||
|                     _items.append(_item.to_dict()) | ||||
|             for _item_second_circular_all_of_ref in self.second_circular_all_of_ref: | ||||
|                 if _item_second_circular_all_of_ref: | ||||
|                     _items.append(_item_second_circular_all_of_ref.to_dict()) | ||||
|             _dict['secondCircularAllOfRef'] = _items | ||||
|         # puts key-value pairs in additional_properties in the top level | ||||
|         if self.additional_properties is not None: | ||||
|  | ||||
| @ -79,9 +79,9 @@ class FileSchemaTestClass(BaseModel): | ||||
|         # override the default output from pydantic by calling `to_dict()` of each item in files (list) | ||||
|         _items = [] | ||||
|         if self.files: | ||||
|             for _item in self.files: | ||||
|                 if _item: | ||||
|                     _items.append(_item.to_dict()) | ||||
|             for _item_files in self.files: | ||||
|                 if _item_files: | ||||
|                     _items.append(_item_files.to_dict()) | ||||
|             _dict['files'] = _items | ||||
|         # puts key-value pairs in additional_properties in the top level | ||||
|         if self.additional_properties is not None: | ||||
|  | ||||
| @ -75,9 +75,9 @@ class InputAllOf(BaseModel): | ||||
|         # override the default output from pydantic by calling `to_dict()` of each value in some_data (dict) | ||||
|         _field_dict = {} | ||||
|         if self.some_data: | ||||
|             for _key in self.some_data: | ||||
|                 if self.some_data[_key]: | ||||
|                     _field_dict[_key] = self.some_data[_key].to_dict() | ||||
|             for _key_some_data in self.some_data: | ||||
|                 if self.some_data[_key_some_data]: | ||||
|                     _field_dict[_key_some_data] = self.some_data[_key_some_data].to_dict() | ||||
|             _dict['some_data'] = _field_dict | ||||
|         # puts key-value pairs in additional_properties in the top level | ||||
|         if self.additional_properties is not None: | ||||
|  | ||||
| @ -75,10 +75,10 @@ class MapOfArrayOfModel(BaseModel): | ||||
|         # override the default output from pydantic by calling `to_dict()` of each value in shop_id_to_org_online_lip_map (dict of array) | ||||
|         _field_dict_of_array = {} | ||||
|         if self.shop_id_to_org_online_lip_map: | ||||
|             for _key in self.shop_id_to_org_online_lip_map: | ||||
|                 if self.shop_id_to_org_online_lip_map[_key] is not None: | ||||
|                     _field_dict_of_array[_key] = [ | ||||
|                         _item.to_dict() for _item in self.shop_id_to_org_online_lip_map[_key] | ||||
|             for _key_shop_id_to_org_online_lip_map in self.shop_id_to_org_online_lip_map: | ||||
|                 if self.shop_id_to_org_online_lip_map[_key_shop_id_to_org_online_lip_map] is not None: | ||||
|                     _field_dict_of_array[_key_shop_id_to_org_online_lip_map] = [ | ||||
|                         _item.to_dict() for _item in self.shop_id_to_org_online_lip_map[_key_shop_id_to_org_online_lip_map] | ||||
|                     ] | ||||
|             _dict['shopIdToOrgOnlineLipMap'] = _field_dict_of_array | ||||
|         # puts key-value pairs in additional_properties in the top level | ||||
|  | ||||
| @ -78,9 +78,9 @@ class MixedPropertiesAndAdditionalPropertiesClass(BaseModel): | ||||
|         # override the default output from pydantic by calling `to_dict()` of each value in map (dict) | ||||
|         _field_dict = {} | ||||
|         if self.map: | ||||
|             for _key in self.map: | ||||
|                 if self.map[_key]: | ||||
|                     _field_dict[_key] = self.map[_key].to_dict() | ||||
|             for _key_map in self.map: | ||||
|                 if self.map[_key_map]: | ||||
|                     _field_dict[_key_map] = self.map[_key_map].to_dict() | ||||
|             _dict['map'] = _field_dict | ||||
|         # puts key-value pairs in additional_properties in the top level | ||||
|         if self.additional_properties is not None: | ||||
|  | ||||
| @ -0,0 +1,118 @@ | ||||
| # coding: utf-8 | ||||
| 
 | ||||
| """ | ||||
|     OpenAPI Petstore | ||||
| 
 | ||||
|     This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ | ||||
| 
 | ||||
|     The version of the OpenAPI document: 1.0.0 | ||||
|     Generated by OpenAPI Generator (https://openapi-generator.tech) | ||||
| 
 | ||||
|     Do not edit the class manually. | ||||
| """  # noqa: E501 | ||||
| 
 | ||||
| 
 | ||||
| from __future__ import annotations | ||||
| import pprint | ||||
| import re  # noqa: F401 | ||||
| import json | ||||
| 
 | ||||
| from pydantic import BaseModel, ConfigDict, Field | ||||
| from typing import Any, ClassVar, Dict, List, Optional | ||||
| from petstore_api.models.file import File | ||||
| from petstore_api.models.tag import Tag | ||||
| from typing import Optional, Set | ||||
| from typing_extensions import Self | ||||
| 
 | ||||
| class MultiArrays(BaseModel): | ||||
|     """ | ||||
|     MultiArrays | ||||
|     """ # noqa: E501 | ||||
|     tags: Optional[List[Tag]] = None | ||||
|     files: Optional[List[File]] = Field(default=None, description="Another array of objects in addition to tags (mypy check to not to reuse the same iterator)") | ||||
|     additional_properties: Dict[str, Any] = {} | ||||
|     __properties: ClassVar[List[str]] = ["tags", "files"] | ||||
| 
 | ||||
|     model_config = ConfigDict( | ||||
|         populate_by_name=True, | ||||
|         validate_assignment=True, | ||||
|         protected_namespaces=(), | ||||
|     ) | ||||
| 
 | ||||
| 
 | ||||
|     def to_str(self) -> str: | ||||
|         """Returns the string representation of the model using alias""" | ||||
|         return pprint.pformat(self.model_dump(by_alias=True)) | ||||
| 
 | ||||
|     def to_json(self) -> str: | ||||
|         """Returns the JSON representation of the model using alias""" | ||||
|         # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead | ||||
|         return json.dumps(self.to_dict()) | ||||
| 
 | ||||
|     @classmethod | ||||
|     def from_json(cls, json_str: str) -> Optional[Self]: | ||||
|         """Create an instance of MultiArrays from a JSON string""" | ||||
|         return cls.from_dict(json.loads(json_str)) | ||||
| 
 | ||||
|     def to_dict(self) -> Dict[str, Any]: | ||||
|         """Return the dictionary representation of the model using alias. | ||||
| 
 | ||||
|         This has the following differences from calling pydantic's | ||||
|         `self.model_dump(by_alias=True)`: | ||||
| 
 | ||||
|         * `None` is only added to the output dict for nullable fields that | ||||
|           were set at model initialization. Other fields with value `None` | ||||
|           are ignored. | ||||
|         * Fields in `self.additional_properties` are added to the output dict. | ||||
|         """ | ||||
|         excluded_fields: Set[str] = set([ | ||||
|             "additional_properties", | ||||
|         ]) | ||||
| 
 | ||||
|         _dict = self.model_dump( | ||||
|             by_alias=True, | ||||
|             exclude=excluded_fields, | ||||
|             exclude_none=True, | ||||
|         ) | ||||
|         # override the default output from pydantic by calling `to_dict()` of each item in tags (list) | ||||
|         _items = [] | ||||
|         if self.tags: | ||||
|             for _item_tags in self.tags: | ||||
|                 if _item_tags: | ||||
|                     _items.append(_item_tags.to_dict()) | ||||
|             _dict['tags'] = _items | ||||
|         # override the default output from pydantic by calling `to_dict()` of each item in files (list) | ||||
|         _items = [] | ||||
|         if self.files: | ||||
|             for _item_files in self.files: | ||||
|                 if _item_files: | ||||
|                     _items.append(_item_files.to_dict()) | ||||
|             _dict['files'] = _items | ||||
|         # puts key-value pairs in additional_properties in the top level | ||||
|         if self.additional_properties is not None: | ||||
|             for _key, _value in self.additional_properties.items(): | ||||
|                 _dict[_key] = _value | ||||
| 
 | ||||
|         return _dict | ||||
| 
 | ||||
|     @classmethod | ||||
|     def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: | ||||
|         """Create an instance of MultiArrays from a dict""" | ||||
|         if obj is None: | ||||
|             return None | ||||
| 
 | ||||
|         if not isinstance(obj, dict): | ||||
|             return cls.model_validate(obj) | ||||
| 
 | ||||
|         _obj = cls.model_validate({ | ||||
|             "tags": [Tag.from_dict(_item) for _item in obj["tags"]] if obj.get("tags") is not None else None, | ||||
|             "files": [File.from_dict(_item) for _item in obj["files"]] if obj.get("files") is not None else None | ||||
|         }) | ||||
|         # store additional fields in additional_properties | ||||
|         for _key in obj.keys(): | ||||
|             if _key not in cls.__properties: | ||||
|                 _obj.additional_properties[_key] = obj.get(_key) | ||||
| 
 | ||||
|         return _obj | ||||
| 
 | ||||
| 
 | ||||
| @ -75,9 +75,9 @@ class Parent(BaseModel): | ||||
|         # override the default output from pydantic by calling `to_dict()` of each value in optional_dict (dict) | ||||
|         _field_dict = {} | ||||
|         if self.optional_dict: | ||||
|             for _key in self.optional_dict: | ||||
|                 if self.optional_dict[_key]: | ||||
|                     _field_dict[_key] = self.optional_dict[_key].to_dict() | ||||
|             for _key_optional_dict in self.optional_dict: | ||||
|                 if self.optional_dict[_key_optional_dict]: | ||||
|                     _field_dict[_key_optional_dict] = self.optional_dict[_key_optional_dict].to_dict() | ||||
|             _dict['optionalDict'] = _field_dict | ||||
|         # puts key-value pairs in additional_properties in the top level | ||||
|         if self.additional_properties is not None: | ||||
|  | ||||
| @ -75,9 +75,9 @@ class ParentWithOptionalDict(BaseModel): | ||||
|         # override the default output from pydantic by calling `to_dict()` of each value in optional_dict (dict) | ||||
|         _field_dict = {} | ||||
|         if self.optional_dict: | ||||
|             for _key in self.optional_dict: | ||||
|                 if self.optional_dict[_key]: | ||||
|                     _field_dict[_key] = self.optional_dict[_key].to_dict() | ||||
|             for _key_optional_dict in self.optional_dict: | ||||
|                 if self.optional_dict[_key_optional_dict]: | ||||
|                     _field_dict[_key_optional_dict] = self.optional_dict[_key_optional_dict].to_dict() | ||||
|             _dict['optionalDict'] = _field_dict | ||||
|         # puts key-value pairs in additional_properties in the top level | ||||
|         if self.additional_properties is not None: | ||||
|  | ||||
| @ -95,9 +95,9 @@ class Pet(BaseModel): | ||||
|         # override the default output from pydantic by calling `to_dict()` of each item in tags (list) | ||||
|         _items = [] | ||||
|         if self.tags: | ||||
|             for _item in self.tags: | ||||
|                 if _item: | ||||
|                     _items.append(_item.to_dict()) | ||||
|             for _item_tags in self.tags: | ||||
|                 if _item_tags: | ||||
|                     _items.append(_item_tags.to_dict()) | ||||
|             _dict['tags'] = _items | ||||
|         # puts key-value pairs in additional_properties in the top level | ||||
|         if self.additional_properties is not None: | ||||
|  | ||||
| @ -75,9 +75,9 @@ class PropertyMap(BaseModel): | ||||
|         # override the default output from pydantic by calling `to_dict()` of each value in some_data (dict) | ||||
|         _field_dict = {} | ||||
|         if self.some_data: | ||||
|             for _key in self.some_data: | ||||
|                 if self.some_data[_key]: | ||||
|                     _field_dict[_key] = self.some_data[_key].to_dict() | ||||
|             for _key_some_data in self.some_data: | ||||
|                 if self.some_data[_key_some_data]: | ||||
|                     _field_dict[_key_some_data] = self.some_data[_key_some_data].to_dict() | ||||
|             _dict['some_data'] = _field_dict | ||||
|         # puts key-value pairs in additional_properties in the top level | ||||
|         if self.additional_properties is not None: | ||||
|  | ||||
| @ -75,9 +75,9 @@ class SecondCircularAllOfRef(BaseModel): | ||||
|         # override the default output from pydantic by calling `to_dict()` of each item in circular_all_of_ref (list) | ||||
|         _items = [] | ||||
|         if self.circular_all_of_ref: | ||||
|             for _item in self.circular_all_of_ref: | ||||
|                 if _item: | ||||
|                     _items.append(_item.to_dict()) | ||||
|             for _item_circular_all_of_ref in self.circular_all_of_ref: | ||||
|                 if _item_circular_all_of_ref: | ||||
|                     _items.append(_item_circular_all_of_ref.to_dict()) | ||||
|             _dict['circularAllOfRef'] = _items | ||||
|         # puts key-value pairs in additional_properties in the top level | ||||
|         if self.additional_properties is not None: | ||||
|  | ||||
| @ -75,10 +75,10 @@ class UnnamedDictWithAdditionalModelListProperties(BaseModel): | ||||
|         # override the default output from pydantic by calling `to_dict()` of each value in dict_property (dict of array) | ||||
|         _field_dict_of_array = {} | ||||
|         if self.dict_property: | ||||
|             for _key in self.dict_property: | ||||
|                 if self.dict_property[_key] is not None: | ||||
|                     _field_dict_of_array[_key] = [ | ||||
|                         _item.to_dict() for _item in self.dict_property[_key] | ||||
|             for _key_dict_property in self.dict_property: | ||||
|                 if self.dict_property[_key_dict_property] is not None: | ||||
|                     _field_dict_of_array[_key_dict_property] = [ | ||||
|                         _item.to_dict() for _item in self.dict_property[_key_dict_property] | ||||
|                     ] | ||||
|             _dict['dictProperty'] = _field_dict_of_array | ||||
|         # puts key-value pairs in additional_properties in the top level | ||||
|  | ||||
| @ -0,0 +1,59 @@ | ||||
| # coding: utf-8 | ||||
| 
 | ||||
| """ | ||||
|     OpenAPI Petstore | ||||
| 
 | ||||
|     This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ | ||||
| 
 | ||||
|     The version of the OpenAPI document: 1.0.0 | ||||
|     Generated by OpenAPI Generator (https://openapi-generator.tech) | ||||
| 
 | ||||
|     Do not edit the class manually. | ||||
| """  # noqa: E501 | ||||
| 
 | ||||
| 
 | ||||
| import unittest | ||||
| 
 | ||||
| from petstore_api.models.multi_arrays import MultiArrays | ||||
| 
 | ||||
| class TestMultiArrays(unittest.TestCase): | ||||
|     """MultiArrays unit test stubs""" | ||||
| 
 | ||||
|     def setUp(self): | ||||
|         pass | ||||
| 
 | ||||
|     def tearDown(self): | ||||
|         pass | ||||
| 
 | ||||
|     def make_instance(self, include_optional) -> MultiArrays: | ||||
|         """Test MultiArrays | ||||
|             include_optional is a boolean, when False only required | ||||
|             params are included, when True both required and | ||||
|             optional params are included """ | ||||
|         # uncomment below to create an instance of `MultiArrays` | ||||
|         """ | ||||
|         model = MultiArrays() | ||||
|         if include_optional: | ||||
|             return MultiArrays( | ||||
|                 tags = [ | ||||
|                     petstore_api.models.tag.Tag( | ||||
|                         id = 56,  | ||||
|                         name = '', ) | ||||
|                     ], | ||||
|                 files = [ | ||||
|                     petstore_api.models.file.File( | ||||
|                         source_uri = '', ) | ||||
|                     ] | ||||
|             ) | ||||
|         else: | ||||
|             return MultiArrays( | ||||
|         ) | ||||
|         """ | ||||
| 
 | ||||
|     def testMultiArrays(self): | ||||
|         """Test MultiArrays""" | ||||
|         # inst_req_only = self.make_instance(include_optional=False) | ||||
|         # inst_req_and_optional = self.make_instance(include_optional=True) | ||||
| 
 | ||||
| if __name__ == '__main__': | ||||
|     unittest.main() | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user