Skip to content

Commit 69e1956

Browse files
committed
Sample updated
1 parent 4a8595f commit 69e1956

File tree

15 files changed

+5
-239
lines changed

15 files changed

+5
-239
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,3 +158,6 @@ cython_debug/
158158
# and can be added to the global gitignore or merged into this file. For a more nuclear
159159
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
160160
#.idea/
161+
162+
# mac
163+
*.DS_Store

petstore/openapi_json_schema_generator_python/.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,3 @@ target/
6565

6666
#Ipython Notebook
6767
.ipynb_checkpoints
68-
69-
# mac
70-
*.DS_Store

petstore/openapi_json_schema_generator_python/.openapi-generator/FILES

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
.gitignore
22
.gitlab-ci.yml
3-
.openapi-generator-ignore
43
.travis.yml
54
README.md
65
docs/apis/tags/pet_api.md
@@ -366,12 +365,6 @@ test-requirements.txt
366365
test/__init__.py
367366
test/components/__init__.py
368367
test/components/schema/__init__.py
369-
test/components/schema/test_api_response.py
370-
test/components/schema/test_category.py
371-
test/components/schema/test_order.py
372-
test/components/schema/test_pet.py
373-
test/components/schema/test_tag.py
374-
test/components/schema/test_user.py
375368
test/test_paths/__init__.py
376369
test/test_paths/__init__.py
377370
test/test_paths/__init__.py

petstore/openapi_json_schema_generator_python/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@ This means that one can use normal dict methods on instances of these classes.
133133
- optional properties which were not set will not exist in the instance
134134
- None is only allowed in as a value if type: "null" was included or nullable: true was set
135135
- type hints are written for accessing values by key literals like instance["hi-there"]
136-
- and there is a method instance.get_item_["hi-there"] which returns an schemas.Unset value if the key was not set
137136
- required properties with valid python names are accessible with instance.SomeRequiredProp
138137
which uses the exact key from the openapi document
139138
- preserving the original key names is required to properly validate a payload to multiple json schemas

petstore/openapi_json_schema_generator_python/migration_other_python_generators.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,8 @@ When switching from other python client generators you will need to make some ch
3535
- Only required keys with valid python names are properties like .someProp and have type hints
3636
- All optional keys may not exist, so properties are not defined for them
3737
- One can access optional values with dict_instance['optionalProp'] and KeyError will be raised if it does not exist
38-
- Use get_item_ if you need a way to always get a value whether or not the key exists
39-
- If the key does not exist, schemas.unset is returned from calling dict_instance.get_item_('optionalProp')
40-
- All required and optional keys have type hints for this method, and @typing.overload is used
41-
- A type hint is also generated for additionalProperties accessed using this method
38+
- if you need a way to always get a value whether or not the key exists use:
39+
- dict_instance.get('optionalProp', schemas.unset)
4240
- So you will need to update you code to use some_instance['optionalProp'] to access optional property
4341
and additionalProperty values
4442
8. The location of the api classes has changed

petstore/openapi_json_schema_generator_python/src/openapi_client/components/schema/api_response.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -71,29 +71,6 @@ def __getitem__(
7171
):
7272
# dict_instance[name] accessor
7373
return super().__getitem__(name)
74-
75-
@typing.overload
76-
def get_item_(self, name: typing_extensions.Literal["code"]) -> typing.Union[Schema_.Properties.Code, schemas.Unset]: ...
77-
78-
@typing.overload
79-
def get_item_(self, name: typing_extensions.Literal["type"]) -> typing.Union[Schema_.Properties.Type, schemas.Unset]: ...
80-
81-
@typing.overload
82-
def get_item_(self, name: typing_extensions.Literal["message"]) -> typing.Union[Schema_.Properties.Message, schemas.Unset]: ...
83-
84-
@typing.overload
85-
def get_item_(self, name: str) -> typing.Union[schemas.UnsetAnyTypeSchema, schemas.Unset]: ...
86-
87-
def get_item_(
88-
self,
89-
name: typing.Union[
90-
typing_extensions.Literal["code"],
91-
typing_extensions.Literal["type"],
92-
typing_extensions.Literal["message"],
93-
str
94-
]
95-
):
96-
return super().get_item_(name)
9774

9875
def __new__(
9976
cls,

petstore/openapi_json_schema_generator_python/src/openapi_client/components/schema/category.py

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -78,25 +78,6 @@ def __getitem__(
7878
):
7979
# dict_instance[name] accessor
8080
return super().__getitem__(name)
81-
82-
@typing.overload
83-
def get_item_(self, name: typing_extensions.Literal["id"]) -> typing.Union[Schema_.Properties.Id, schemas.Unset]: ...
84-
85-
@typing.overload
86-
def get_item_(self, name: typing_extensions.Literal["name"]) -> typing.Union[Schema_.Properties.Name, schemas.Unset]: ...
87-
88-
@typing.overload
89-
def get_item_(self, name: str) -> typing.Union[schemas.UnsetAnyTypeSchema, schemas.Unset]: ...
90-
91-
def get_item_(
92-
self,
93-
name: typing.Union[
94-
typing_extensions.Literal["id"],
95-
typing_extensions.Literal["name"],
96-
str
97-
]
98-
):
99-
return super().get_item_(name)
10081

10182
def __new__(
10283
cls,

petstore/openapi_json_schema_generator_python/src/openapi_client/components/schema/order.py

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -127,41 +127,6 @@ def __getitem__(
127127
):
128128
# dict_instance[name] accessor
129129
return super().__getitem__(name)
130-
131-
@typing.overload
132-
def get_item_(self, name: typing_extensions.Literal["id"]) -> typing.Union[Schema_.Properties.Id, schemas.Unset]: ...
133-
134-
@typing.overload
135-
def get_item_(self, name: typing_extensions.Literal["petId"]) -> typing.Union[Schema_.Properties.PetId, schemas.Unset]: ...
136-
137-
@typing.overload
138-
def get_item_(self, name: typing_extensions.Literal["quantity"]) -> typing.Union[Schema_.Properties.Quantity, schemas.Unset]: ...
139-
140-
@typing.overload
141-
def get_item_(self, name: typing_extensions.Literal["shipDate"]) -> typing.Union[Schema_.Properties.ShipDate, schemas.Unset]: ...
142-
143-
@typing.overload
144-
def get_item_(self, name: typing_extensions.Literal["status"]) -> typing.Union[Schema_.Properties.Status, schemas.Unset]: ...
145-
146-
@typing.overload
147-
def get_item_(self, name: typing_extensions.Literal["complete"]) -> typing.Union[Schema_.Properties.Complete, schemas.Unset]: ...
148-
149-
@typing.overload
150-
def get_item_(self, name: str) -> typing.Union[schemas.UnsetAnyTypeSchema, schemas.Unset]: ...
151-
152-
def get_item_(
153-
self,
154-
name: typing.Union[
155-
typing_extensions.Literal["id"],
156-
typing_extensions.Literal["petId"],
157-
typing_extensions.Literal["quantity"],
158-
typing_extensions.Literal["shipDate"],
159-
typing_extensions.Literal["status"],
160-
typing_extensions.Literal["complete"],
161-
str
162-
]
163-
):
164-
return super().get_item_(name)
165130

166131
def __new__(
167132
cls,

petstore/openapi_json_schema_generator_python/src/openapi_client/components/schema/pet.py

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -189,41 +189,6 @@ def __getitem__(
189189
):
190190
# dict_instance[name] accessor
191191
return super().__getitem__(name)
192-
193-
@typing.overload
194-
def get_item_(self, name: typing_extensions.Literal["name"]) -> Schema_.Properties.Name: ...
195-
196-
@typing.overload
197-
def get_item_(self, name: typing_extensions.Literal["photoUrls"]) -> Schema_.Properties.PhotoUrls: ...
198-
199-
@typing.overload
200-
def get_item_(self, name: typing_extensions.Literal["id"]) -> typing.Union[Schema_.Properties.Id, schemas.Unset]: ...
201-
202-
@typing.overload
203-
def get_item_(self, name: typing_extensions.Literal["category"]) -> typing.Union['category.Category', schemas.Unset]: ...
204-
205-
@typing.overload
206-
def get_item_(self, name: typing_extensions.Literal["tags"]) -> typing.Union[Schema_.Properties.Tags, schemas.Unset]: ...
207-
208-
@typing.overload
209-
def get_item_(self, name: typing_extensions.Literal["status"]) -> typing.Union[Schema_.Properties.Status, schemas.Unset]: ...
210-
211-
@typing.overload
212-
def get_item_(self, name: str) -> typing.Union[schemas.UnsetAnyTypeSchema, schemas.Unset]: ...
213-
214-
def get_item_(
215-
self,
216-
name: typing.Union[
217-
typing_extensions.Literal["name"],
218-
typing_extensions.Literal["photoUrls"],
219-
typing_extensions.Literal["id"],
220-
typing_extensions.Literal["category"],
221-
typing_extensions.Literal["tags"],
222-
typing_extensions.Literal["status"],
223-
str
224-
]
225-
):
226-
return super().get_item_(name)
227192

228193
def __new__(
229194
cls,

petstore/openapi_json_schema_generator_python/src/openapi_client/components/schema/tag.py

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -65,25 +65,6 @@ def __getitem__(
6565
):
6666
# dict_instance[name] accessor
6767
return super().__getitem__(name)
68-
69-
@typing.overload
70-
def get_item_(self, name: typing_extensions.Literal["id"]) -> typing.Union[Schema_.Properties.Id, schemas.Unset]: ...
71-
72-
@typing.overload
73-
def get_item_(self, name: typing_extensions.Literal["name"]) -> typing.Union[Schema_.Properties.Name, schemas.Unset]: ...
74-
75-
@typing.overload
76-
def get_item_(self, name: str) -> typing.Union[schemas.UnsetAnyTypeSchema, schemas.Unset]: ...
77-
78-
def get_item_(
79-
self,
80-
name: typing.Union[
81-
typing_extensions.Literal["id"],
82-
typing_extensions.Literal["name"],
83-
str
84-
]
85-
):
86-
return super().get_item_(name)
8768

8869
def __new__(
8970
cls,

petstore/openapi_json_schema_generator_python/src/openapi_client/components/schema/user.py

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -101,49 +101,6 @@ def __getitem__(
101101
):
102102
# dict_instance[name] accessor
103103
return super().__getitem__(name)
104-
105-
@typing.overload
106-
def get_item_(self, name: typing_extensions.Literal["id"]) -> typing.Union[Schema_.Properties.Id, schemas.Unset]: ...
107-
108-
@typing.overload
109-
def get_item_(self, name: typing_extensions.Literal["username"]) -> typing.Union[Schema_.Properties.Username, schemas.Unset]: ...
110-
111-
@typing.overload
112-
def get_item_(self, name: typing_extensions.Literal["firstName"]) -> typing.Union[Schema_.Properties.FirstName, schemas.Unset]: ...
113-
114-
@typing.overload
115-
def get_item_(self, name: typing_extensions.Literal["lastName"]) -> typing.Union[Schema_.Properties.LastName, schemas.Unset]: ...
116-
117-
@typing.overload
118-
def get_item_(self, name: typing_extensions.Literal["email"]) -> typing.Union[Schema_.Properties.Email, schemas.Unset]: ...
119-
120-
@typing.overload
121-
def get_item_(self, name: typing_extensions.Literal["password"]) -> typing.Union[Schema_.Properties.Password, schemas.Unset]: ...
122-
123-
@typing.overload
124-
def get_item_(self, name: typing_extensions.Literal["phone"]) -> typing.Union[Schema_.Properties.Phone, schemas.Unset]: ...
125-
126-
@typing.overload
127-
def get_item_(self, name: typing_extensions.Literal["userStatus"]) -> typing.Union[Schema_.Properties.UserStatus, schemas.Unset]: ...
128-
129-
@typing.overload
130-
def get_item_(self, name: str) -> typing.Union[schemas.UnsetAnyTypeSchema, schemas.Unset]: ...
131-
132-
def get_item_(
133-
self,
134-
name: typing.Union[
135-
typing_extensions.Literal["id"],
136-
typing_extensions.Literal["username"],
137-
typing_extensions.Literal["firstName"],
138-
typing_extensions.Literal["lastName"],
139-
typing_extensions.Literal["email"],
140-
typing_extensions.Literal["password"],
141-
typing_extensions.Literal["phone"],
142-
typing_extensions.Literal["userStatus"],
143-
str
144-
]
145-
):
146-
return super().get_item_(name)
147104

148105
def __new__(
149106
cls,

petstore/openapi_json_schema_generator_python/src/openapi_client/paths/pet_pet_id/post/request_body/content/application_x_www_form_urlencoded/schema.py

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -58,25 +58,6 @@ def __getitem__(
5858
):
5959
# dict_instance[name] accessor
6060
return super().__getitem__(name)
61-
62-
@typing.overload
63-
def get_item_(self, name: typing_extensions.Literal["name"]) -> typing.Union[Schema_.Properties.Name, schemas.Unset]: ...
64-
65-
@typing.overload
66-
def get_item_(self, name: typing_extensions.Literal["status"]) -> typing.Union[Schema_.Properties.Status, schemas.Unset]: ...
67-
68-
@typing.overload
69-
def get_item_(self, name: str) -> typing.Union[schemas.UnsetAnyTypeSchema, schemas.Unset]: ...
70-
71-
def get_item_(
72-
self,
73-
name: typing.Union[
74-
typing_extensions.Literal["name"],
75-
typing_extensions.Literal["status"],
76-
str
77-
]
78-
):
79-
return super().get_item_(name)
8061

8162
def __new__(
8263
cls,

petstore/openapi_json_schema_generator_python/src/openapi_client/paths/pet_pet_id_upload_image/post/request_body/content/multipart_form_data/schema.py

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -58,25 +58,6 @@ def __getitem__(
5858
):
5959
# dict_instance[name] accessor
6060
return super().__getitem__(name)
61-
62-
@typing.overload
63-
def get_item_(self, name: typing_extensions.Literal["additionalMetadata"]) -> typing.Union[Schema_.Properties.AdditionalMetadata, schemas.Unset]: ...
64-
65-
@typing.overload
66-
def get_item_(self, name: typing_extensions.Literal["file"]) -> typing.Union[Schema_.Properties.File, schemas.Unset]: ...
67-
68-
@typing.overload
69-
def get_item_(self, name: str) -> typing.Union[schemas.UnsetAnyTypeSchema, schemas.Unset]: ...
70-
71-
def get_item_(
72-
self,
73-
name: typing.Union[
74-
typing_extensions.Literal["additionalMetadata"],
75-
typing_extensions.Literal["file"],
76-
str
77-
]
78-
):
79-
return super().get_item_(name)
8061

8162
def __new__(
8263
cls,

petstore/openapi_json_schema_generator_python/src/openapi_client/paths/store_inventory/get/responses/response_200/content/application_json/schema.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,6 @@ class Schema_:
3535
def __getitem__(self, name: str) -> Schema_.AdditionalProperties:
3636
# dict_instance[name] accessor
3737
return super().__getitem__(name)
38-
39-
def get_item_(self, name: str) -> Schema_.AdditionalProperties:
40-
return super().get_item_(name)
4138

4239
def __new__(
4340
cls,

petstore/openapi_json_schema_generator_python/src/openapi_client/schemas.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1912,15 +1912,6 @@ def __getattr__(self, name: str):
19121912
except KeyError as ex:
19131913
raise AttributeError(str(ex))
19141914

1915-
def get_item_(self, name: str) -> typing.Union['AnyTypeSchema', Unset]:
1916-
# dict_instance[name] accessor
1917-
if not isinstance(self, frozendict.frozendict):
1918-
raise NotImplementedError()
1919-
try:
1920-
return super().__getitem__(name)
1921-
except KeyError:
1922-
return unset
1923-
19241915

19251916
def cast_to_allowed_types(
19261917
arg: typing.Union[

0 commit comments

Comments
 (0)