Skip to content

Commit 3278eea

Browse files
authored
* add tests for OpenAPITools#16217 * add new files
1 parent 77311c3 commit 3278eea

File tree

28 files changed

+1044
-0
lines changed

28 files changed

+1044
-0
lines changed

modules/openapi-generator/src/test/resources/3_0/python/petstore-with-fake-endpoints-models-for-testing.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2246,3 +2246,30 @@ components:
22462246
description: Property
22472247
type: boolean
22482248
default: false
2249+
Creature:
2250+
type: object
2251+
required:
2252+
- info
2253+
- type
2254+
properties:
2255+
info:
2256+
$ref: "#/components/schemas/CreatureInfo"
2257+
type:
2258+
type: string
2259+
discriminator:
2260+
propertyName: type
2261+
CreatureInfo:
2262+
type: object
2263+
required:
2264+
- name
2265+
properties:
2266+
name:
2267+
type: string
2268+
Tiger:
2269+
allOf:
2270+
- $ref: "#/components/schemas/Tiger"
2271+
- type: object
2272+
properties:
2273+
skill:
2274+
type: string
2275+

samples/openapi3/client/petstore/python-aiohttp/.openapi-generator/FILES

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ docs/CircularReferenceModel.md
2222
docs/ClassModel.md
2323
docs/Client.md
2424
docs/Color.md
25+
docs/Creature.md
26+
docs/CreatureInfo.md
2527
docs/DanishPig.md
2628
docs/DefaultApi.md
2729
docs/DeprecatedObject.md
@@ -79,6 +81,7 @@ docs/SpecialModelName.md
7981
docs/SpecialName.md
8082
docs/StoreApi.md
8183
docs/Tag.md
84+
docs/Tiger.md
8285
docs/User.md
8386
docs/UserApi.md
8487
docs/WithNestedOneOf.md
@@ -115,6 +118,8 @@ petstore_api/models/circular_reference_model.py
115118
petstore_api/models/class_model.py
116119
petstore_api/models/client.py
117120
petstore_api/models/color.py
121+
petstore_api/models/creature.py
122+
petstore_api/models/creature_info.py
118123
petstore_api/models/danish_pig.py
119124
petstore_api/models/deprecated_object.py
120125
petstore_api/models/dog.py
@@ -167,6 +172,7 @@ petstore_api/models/special_character_enum.py
167172
petstore_api/models/special_model_name.py
168173
petstore_api/models/special_name.py
169174
petstore_api/models/tag.py
175+
petstore_api/models/tiger.py
170176
petstore_api/models/user.py
171177
petstore_api/models/with_nested_one_of.py
172178
petstore_api/py.typed

samples/openapi3/client/petstore/python-aiohttp/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@ Class | Method | HTTP request | Description
150150
- [ClassModel](docs/ClassModel.md)
151151
- [Client](docs/Client.md)
152152
- [Color](docs/Color.md)
153+
- [Creature](docs/Creature.md)
154+
- [CreatureInfo](docs/CreatureInfo.md)
153155
- [DanishPig](docs/DanishPig.md)
154156
- [DeprecatedObject](docs/DeprecatedObject.md)
155157
- [Dog](docs/Dog.md)
@@ -202,6 +204,7 @@ Class | Method | HTTP request | Description
202204
- [SpecialModelName](docs/SpecialModelName.md)
203205
- [SpecialName](docs/SpecialName.md)
204206
- [Tag](docs/Tag.md)
207+
- [Tiger](docs/Tiger.md)
205208
- [User](docs/User.md)
206209
- [WithNestedOneOf](docs/WithNestedOneOf.md)
207210

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Creature
2+
3+
4+
## Properties
5+
Name | Type | Description | Notes
6+
------------ | ------------- | ------------- | -------------
7+
**info** | [**CreatureInfo**](CreatureInfo.md) | |
8+
**type** | **str** | |
9+
10+
## Example
11+
12+
```python
13+
from petstore_api.models.creature import Creature
14+
15+
# TODO update the JSON string below
16+
json = "{}"
17+
# create an instance of Creature from a JSON string
18+
creature_instance = Creature.from_json(json)
19+
# print the JSON string representation of the object
20+
print Creature.to_json()
21+
22+
# convert the object into a dict
23+
creature_dict = creature_instance.to_dict()
24+
# create an instance of Creature from a dict
25+
creature_form_dict = creature.from_dict(creature_dict)
26+
```
27+
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
28+
29+
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# CreatureInfo
2+
3+
4+
## Properties
5+
Name | Type | Description | Notes
6+
------------ | ------------- | ------------- | -------------
7+
**name** | **str** | |
8+
9+
## Example
10+
11+
```python
12+
from petstore_api.models.creature_info import CreatureInfo
13+
14+
# TODO update the JSON string below
15+
json = "{}"
16+
# create an instance of CreatureInfo from a JSON string
17+
creature_info_instance = CreatureInfo.from_json(json)
18+
# print the JSON string representation of the object
19+
print CreatureInfo.to_json()
20+
21+
# convert the object into a dict
22+
creature_info_dict = creature_info_instance.to_dict()
23+
# create an instance of CreatureInfo from a dict
24+
creature_info_form_dict = creature_info.from_dict(creature_info_dict)
25+
```
26+
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
27+
28+
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Tiger
2+
3+
4+
## Properties
5+
Name | Type | Description | Notes
6+
------------ | ------------- | ------------- | -------------
7+
**skill** | **str** | | [optional]
8+
9+
## Example
10+
11+
```python
12+
from petstore_api.models.tiger import Tiger
13+
14+
# TODO update the JSON string below
15+
json = "{}"
16+
# create an instance of Tiger from a JSON string
17+
tiger_instance = Tiger.from_json(json)
18+
# print the JSON string representation of the object
19+
print Tiger.to_json()
20+
21+
# convert the object into a dict
22+
tiger_dict = tiger_instance.to_dict()
23+
# create an instance of Tiger from a dict
24+
tiger_form_dict = tiger.from_dict(tiger_dict)
25+
```
26+
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
27+
28+

samples/openapi3/client/petstore/python-aiohttp/petstore_api/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@
5656
from petstore_api.models.class_model import ClassModel
5757
from petstore_api.models.client import Client
5858
from petstore_api.models.color import Color
59+
from petstore_api.models.creature import Creature
60+
from petstore_api.models.creature_info import CreatureInfo
5961
from petstore_api.models.danish_pig import DanishPig
6062
from petstore_api.models.deprecated_object import DeprecatedObject
6163
from petstore_api.models.dog import Dog
@@ -108,5 +110,6 @@
108110
from petstore_api.models.special_model_name import SpecialModelName
109111
from petstore_api.models.special_name import SpecialName
110112
from petstore_api.models.tag import Tag
113+
from petstore_api.models.tiger import Tiger
111114
from petstore_api.models.user import User
112115
from petstore_api.models.with_nested_one_of import WithNestedOneOf

samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
from petstore_api.models.class_model import ClassModel
3333
from petstore_api.models.client import Client
3434
from petstore_api.models.color import Color
35+
from petstore_api.models.creature import Creature
36+
from petstore_api.models.creature_info import CreatureInfo
3537
from petstore_api.models.danish_pig import DanishPig
3638
from petstore_api.models.deprecated_object import DeprecatedObject
3739
from petstore_api.models.dog import Dog
@@ -84,5 +86,6 @@
8486
from petstore_api.models.special_model_name import SpecialModelName
8587
from petstore_api.models.special_name import SpecialName
8688
from petstore_api.models.tag import Tag
89+
from petstore_api.models.tiger import Tiger
8790
from petstore_api.models.user import User
8891
from petstore_api.models.with_nested_one_of import WithNestedOneOf
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# coding: utf-8
2+
3+
"""
4+
OpenAPI Petstore
5+
6+
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501
7+
8+
The version of the OpenAPI document: 1.0.0
9+
Generated by OpenAPI Generator (https://openapi-generator.tech)
10+
11+
Do not edit the class manually.
12+
"""
13+
14+
15+
from __future__ import annotations
16+
import pprint
17+
import re # noqa: F401
18+
import json
19+
20+
21+
22+
from pydantic import BaseModel, Field, StrictStr
23+
from petstore_api.models.creature_info import CreatureInfo
24+
25+
class Creature(BaseModel):
26+
"""
27+
Creature
28+
"""
29+
info: CreatureInfo = Field(...)
30+
type: StrictStr = Field(...)
31+
__properties = ["info", "type"]
32+
33+
class Config:
34+
"""Pydantic configuration"""
35+
allow_population_by_field_name = True
36+
validate_assignment = True
37+
38+
def to_str(self) -> str:
39+
"""Returns the string representation of the model using alias"""
40+
return pprint.pformat(self.dict(by_alias=True))
41+
42+
def to_json(self) -> str:
43+
"""Returns the JSON representation of the model using alias"""
44+
return json.dumps(self.to_dict())
45+
46+
@classmethod
47+
def from_json(cls, json_str: str) -> Creature:
48+
"""Create an instance of Creature from a JSON string"""
49+
return cls.from_dict(json.loads(json_str))
50+
51+
def to_dict(self):
52+
"""Returns the dictionary representation of the model using alias"""
53+
_dict = self.dict(by_alias=True,
54+
exclude={
55+
},
56+
exclude_none=True)
57+
# override the default output from pydantic by calling `to_dict()` of info
58+
if self.info:
59+
_dict['info'] = self.info.to_dict()
60+
return _dict
61+
62+
@classmethod
63+
def from_dict(cls, obj: dict) -> Creature:
64+
"""Create an instance of Creature from a dict"""
65+
if obj is None:
66+
return None
67+
68+
if not isinstance(obj, dict):
69+
return Creature.parse_obj(obj)
70+
71+
_obj = Creature.parse_obj({
72+
"info": CreatureInfo.from_dict(obj.get("info")) if obj.get("info") is not None else None,
73+
"type": obj.get("type")
74+
})
75+
return _obj
76+
77+
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# coding: utf-8
2+
3+
"""
4+
OpenAPI Petstore
5+
6+
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501
7+
8+
The version of the OpenAPI document: 1.0.0
9+
Generated by OpenAPI Generator (https://openapi-generator.tech)
10+
11+
Do not edit the class manually.
12+
"""
13+
14+
15+
from __future__ import annotations
16+
import pprint
17+
import re # noqa: F401
18+
import json
19+
20+
21+
22+
from pydantic import BaseModel, Field, StrictStr
23+
24+
class CreatureInfo(BaseModel):
25+
"""
26+
CreatureInfo
27+
"""
28+
name: StrictStr = Field(...)
29+
__properties = ["name"]
30+
31+
class Config:
32+
"""Pydantic configuration"""
33+
allow_population_by_field_name = True
34+
validate_assignment = True
35+
36+
def to_str(self) -> str:
37+
"""Returns the string representation of the model using alias"""
38+
return pprint.pformat(self.dict(by_alias=True))
39+
40+
def to_json(self) -> str:
41+
"""Returns the JSON representation of the model using alias"""
42+
return json.dumps(self.to_dict())
43+
44+
@classmethod
45+
def from_json(cls, json_str: str) -> CreatureInfo:
46+
"""Create an instance of CreatureInfo from a JSON string"""
47+
return cls.from_dict(json.loads(json_str))
48+
49+
def to_dict(self):
50+
"""Returns the dictionary representation of the model using alias"""
51+
_dict = self.dict(by_alias=True,
52+
exclude={
53+
},
54+
exclude_none=True)
55+
return _dict
56+
57+
@classmethod
58+
def from_dict(cls, obj: dict) -> CreatureInfo:
59+
"""Create an instance of CreatureInfo from a dict"""
60+
if obj is None:
61+
return None
62+
63+
if not isinstance(obj, dict):
64+
return CreatureInfo.parse_obj(obj)
65+
66+
_obj = CreatureInfo.parse_obj({
67+
"name": obj.get("name")
68+
})
69+
return _obj
70+
71+

0 commit comments

Comments
 (0)