Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,8 @@ cython_debug/
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

# mac
*.DS_Store

.VSCodeCounter
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,18 @@ via vscode code counter tool
| -------- | ----- | ---- |
| openapi_generator_python_nextgen | 27 | 2712 |
| openapi_generator_python_prior | 30 | 5075 |
| openapi_json_schema_generator_python | 365 | 12875
| openapi_json_schema_generator_python | 365 | 9911


### openapi_json_schema_generator_python breakdown
- 7.8k src/openapi_client/paths
- most of this comes from the 3x operation typing overloads

Reasons for the openapi json scheme generator difference
- has overload type hints on all endpoints, allows input content type selection
- json paths used to create files so many files made
- object models have getters written for optional properties
- object models have `__getitem__` methods for properties
- most of the code comes from paths, can itbe reduced?

## Generate

Expand All @@ -49,7 +55,7 @@ docker run --rm -v "${PWD}:/local" openapitools/openapi-generator-cli:v6.5.0 gen
-g python-nextgen \
-o /local/openapi_generator_python_nextgen

docker run --rm -v "${PWD}:/local" openapjsonschematools/openapi-json-schema-generator-cli:2.0.0 generate \
docker run --rm -v "${PWD}:/local" openapijsonschematools/openapi-json-schema-generator-cli:3.0.0-latest generate \
-i /local/petstore.yaml \
-g python \
-o /local/openapi_json_schema_generator_python
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
.gitignore
.gitlab-ci.yml
.openapi-generator-ignore
.travis.yml
README.md
docs/apis/tags/pet_api.md
Expand Down Expand Up @@ -366,12 +365,6 @@ test-requirements.txt
test/__init__.py
test/components/__init__.py
test/components/schema/__init__.py
test/components/schema/test_api_response.py
test/components/schema/test_category.py
test/components/schema/test_order.py
test/components/schema/test_pet.py
test/components/schema/test_tag.py
test/components/schema/test_user.py
test/test_paths/__init__.py
test/test_paths/__init__.py
test/test_paths/__init__.py
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.0.0
3.0.0
1 change: 0 additions & 1 deletion petstore/openapi_json_schema_generator_python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ This means that one can use normal dict methods on instances of these classes.
- optional properties which were not set will not exist in the instance
- None is only allowed in as a value if type: "null" was included or nullable: true was set
- type hints are written for accessing values by key literals like instance["hi-there"]
- and there is a method instance.get_item_["hi-there"] which returns an schemas.Unset value if the key was not set
- required properties with valid python names are accessible with instance.SomeRequiredProp
which uses the exact key from the openapi document
- preserving the original key names is required to properly validate a payload to multiple json schemas
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,8 @@ When switching from other python client generators you will need to make some ch
- Only required keys with valid python names are properties like .someProp and have type hints
- All optional keys may not exist, so properties are not defined for them
- One can access optional values with dict_instance['optionalProp'] and KeyError will be raised if it does not exist
- Use get_item_ if you need a way to always get a value whether or not the key exists
- If the key does not exist, schemas.unset is returned from calling dict_instance.get_item_('optionalProp')
- All required and optional keys have type hints for this method, and @typing.overload is used
- A type hint is also generated for additionalProperties accessed using this method
- if you need a way to always get a value whether or not the key exists use:
- dict_instance.get('optionalProp', schemas.unset)
- So you will need to update you code to use some_instance['optionalProp'] to access optional property
and additionalProperty values
8. The location of the api classes has changed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,29 +71,6 @@ def __getitem__(
):
# dict_instance[name] accessor
return super().__getitem__(name)

@typing.overload
def get_item_(self, name: typing_extensions.Literal["code"]) -> typing.Union[Schema_.Properties.Code, schemas.Unset]: ...

@typing.overload
def get_item_(self, name: typing_extensions.Literal["type"]) -> typing.Union[Schema_.Properties.Type, schemas.Unset]: ...

@typing.overload
def get_item_(self, name: typing_extensions.Literal["message"]) -> typing.Union[Schema_.Properties.Message, schemas.Unset]: ...

@typing.overload
def get_item_(self, name: str) -> typing.Union[schemas.UnsetAnyTypeSchema, schemas.Unset]: ...

def get_item_(
self,
name: typing.Union[
typing_extensions.Literal["code"],
typing_extensions.Literal["type"],
typing_extensions.Literal["message"],
str
]
):
return super().get_item_(name)

def __new__(
cls,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,25 +78,6 @@ def __getitem__(
):
# dict_instance[name] accessor
return super().__getitem__(name)

@typing.overload
def get_item_(self, name: typing_extensions.Literal["id"]) -> typing.Union[Schema_.Properties.Id, schemas.Unset]: ...

@typing.overload
def get_item_(self, name: typing_extensions.Literal["name"]) -> typing.Union[Schema_.Properties.Name, schemas.Unset]: ...

@typing.overload
def get_item_(self, name: str) -> typing.Union[schemas.UnsetAnyTypeSchema, schemas.Unset]: ...

def get_item_(
self,
name: typing.Union[
typing_extensions.Literal["id"],
typing_extensions.Literal["name"],
str
]
):
return super().get_item_(name)

def __new__(
cls,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,41 +127,6 @@ def __getitem__(
):
# dict_instance[name] accessor
return super().__getitem__(name)

@typing.overload
def get_item_(self, name: typing_extensions.Literal["id"]) -> typing.Union[Schema_.Properties.Id, schemas.Unset]: ...

@typing.overload
def get_item_(self, name: typing_extensions.Literal["petId"]) -> typing.Union[Schema_.Properties.PetId, schemas.Unset]: ...

@typing.overload
def get_item_(self, name: typing_extensions.Literal["quantity"]) -> typing.Union[Schema_.Properties.Quantity, schemas.Unset]: ...

@typing.overload
def get_item_(self, name: typing_extensions.Literal["shipDate"]) -> typing.Union[Schema_.Properties.ShipDate, schemas.Unset]: ...

@typing.overload
def get_item_(self, name: typing_extensions.Literal["status"]) -> typing.Union[Schema_.Properties.Status, schemas.Unset]: ...

@typing.overload
def get_item_(self, name: typing_extensions.Literal["complete"]) -> typing.Union[Schema_.Properties.Complete, schemas.Unset]: ...

@typing.overload
def get_item_(self, name: str) -> typing.Union[schemas.UnsetAnyTypeSchema, schemas.Unset]: ...

def get_item_(
self,
name: typing.Union[
typing_extensions.Literal["id"],
typing_extensions.Literal["petId"],
typing_extensions.Literal["quantity"],
typing_extensions.Literal["shipDate"],
typing_extensions.Literal["status"],
typing_extensions.Literal["complete"],
str
]
):
return super().get_item_(name)

def __new__(
cls,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,41 +189,6 @@ def __getitem__(
):
# dict_instance[name] accessor
return super().__getitem__(name)

@typing.overload
def get_item_(self, name: typing_extensions.Literal["name"]) -> Schema_.Properties.Name: ...

@typing.overload
def get_item_(self, name: typing_extensions.Literal["photoUrls"]) -> Schema_.Properties.PhotoUrls: ...

@typing.overload
def get_item_(self, name: typing_extensions.Literal["id"]) -> typing.Union[Schema_.Properties.Id, schemas.Unset]: ...

@typing.overload
def get_item_(self, name: typing_extensions.Literal["category"]) -> typing.Union['category.Category', schemas.Unset]: ...

@typing.overload
def get_item_(self, name: typing_extensions.Literal["tags"]) -> typing.Union[Schema_.Properties.Tags, schemas.Unset]: ...

@typing.overload
def get_item_(self, name: typing_extensions.Literal["status"]) -> typing.Union[Schema_.Properties.Status, schemas.Unset]: ...

@typing.overload
def get_item_(self, name: str) -> typing.Union[schemas.UnsetAnyTypeSchema, schemas.Unset]: ...

def get_item_(
self,
name: typing.Union[
typing_extensions.Literal["name"],
typing_extensions.Literal["photoUrls"],
typing_extensions.Literal["id"],
typing_extensions.Literal["category"],
typing_extensions.Literal["tags"],
typing_extensions.Literal["status"],
str
]
):
return super().get_item_(name)

def __new__(
cls,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,25 +65,6 @@ def __getitem__(
):
# dict_instance[name] accessor
return super().__getitem__(name)

@typing.overload
def get_item_(self, name: typing_extensions.Literal["id"]) -> typing.Union[Schema_.Properties.Id, schemas.Unset]: ...

@typing.overload
def get_item_(self, name: typing_extensions.Literal["name"]) -> typing.Union[Schema_.Properties.Name, schemas.Unset]: ...

@typing.overload
def get_item_(self, name: str) -> typing.Union[schemas.UnsetAnyTypeSchema, schemas.Unset]: ...

def get_item_(
self,
name: typing.Union[
typing_extensions.Literal["id"],
typing_extensions.Literal["name"],
str
]
):
return super().get_item_(name)

def __new__(
cls,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,49 +101,6 @@ def __getitem__(
):
# dict_instance[name] accessor
return super().__getitem__(name)

@typing.overload
def get_item_(self, name: typing_extensions.Literal["id"]) -> typing.Union[Schema_.Properties.Id, schemas.Unset]: ...

@typing.overload
def get_item_(self, name: typing_extensions.Literal["username"]) -> typing.Union[Schema_.Properties.Username, schemas.Unset]: ...

@typing.overload
def get_item_(self, name: typing_extensions.Literal["firstName"]) -> typing.Union[Schema_.Properties.FirstName, schemas.Unset]: ...

@typing.overload
def get_item_(self, name: typing_extensions.Literal["lastName"]) -> typing.Union[Schema_.Properties.LastName, schemas.Unset]: ...

@typing.overload
def get_item_(self, name: typing_extensions.Literal["email"]) -> typing.Union[Schema_.Properties.Email, schemas.Unset]: ...

@typing.overload
def get_item_(self, name: typing_extensions.Literal["password"]) -> typing.Union[Schema_.Properties.Password, schemas.Unset]: ...

@typing.overload
def get_item_(self, name: typing_extensions.Literal["phone"]) -> typing.Union[Schema_.Properties.Phone, schemas.Unset]: ...

@typing.overload
def get_item_(self, name: typing_extensions.Literal["userStatus"]) -> typing.Union[Schema_.Properties.UserStatus, schemas.Unset]: ...

@typing.overload
def get_item_(self, name: str) -> typing.Union[schemas.UnsetAnyTypeSchema, schemas.Unset]: ...

def get_item_(
self,
name: typing.Union[
typing_extensions.Literal["id"],
typing_extensions.Literal["username"],
typing_extensions.Literal["firstName"],
typing_extensions.Literal["lastName"],
typing_extensions.Literal["email"],
typing_extensions.Literal["password"],
typing_extensions.Literal["phone"],
typing_extensions.Literal["userStatus"],
str
]
):
return super().get_item_(name)

def __new__(
cls,
Expand Down
Loading