Skip to content
This repository was archived by the owner on Dec 25, 2024. It is now read-only.

Commit 3af90e2

Browse files
committed
Adds dataclases
1 parent b0a0170 commit 3af90e2

File tree

80 files changed

+287
-133
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+287
-133
lines changed

modules/openapi-json-schema-generator/src/main/resources/python/api_client.handlebars

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# coding: utf-8
22
{{>partial_header}}
33

4-
from dataclasses import dataclass
4+
import dataclasses
55
from decimal import Decimal
66
import enum
77
import email
@@ -339,7 +339,7 @@ class JSONDetector:
339339
return False
340340

341341

342-
@dataclass
342+
@dataclasses.dataclass
343343
class ParameterBase(JSONDetector):
344344
name: str
345345
in_type: ParameterInType
@@ -779,7 +779,7 @@ class Encoding:
779779
self.allow_reserved = allow_reserved
780780

781781

782-
@dataclass
782+
@dataclasses.dataclass
783783
class MediaType:
784784
"""
785785
Used to store request and response body schema information
@@ -793,7 +793,7 @@ class MediaType:
793793
encoding: typing.Optional[typing.Dict[str, Encoding]] = None
794794

795795

796-
@dataclass
796+
@dataclasses.dataclass
797797
class ApiResponse:
798798
response: urllib3.HTTPResponse
799799
body: typing.Union[Unset, Schema]
@@ -813,7 +813,7 @@ class ApiResponse:
813813
self.headers = headers
814814

815815

816-
@dataclass
816+
@dataclasses.dataclass
817817
class ApiResponseWithoutDeserialization(ApiResponse):
818818
response: urllib3.HTTPResponse
819819
body: typing.Union[Unset, typing.Type[Schema]] = unset

modules/openapi-json-schema-generator/src/main/resources/python/endpoint_response.handlebars

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import dataclasses
12
import urllib3
23

34
from {{packageName}} import api_client
@@ -21,6 +22,7 @@ class BodySchemas:
2122
{{/if}}
2223

2324

25+
@dataclasses.dataclass
2426
class ApiResponse(api_client.ApiResponse):
2527
response: urllib3.HTTPResponse
2628
{{#and responseHeaders content}}
@@ -40,7 +42,7 @@ class ApiResponse(api_client.ApiResponse):
4042
{{#or responseHeaders content}}
4143
{{#if responseHeaders}}
4244
headers: Header.Params
43-
body: schemas.Unset
45+
body: schemas.Unset = schemas.unset
4446
{{else}}
4547
body: typing.Union[
4648
{{#each content}}
@@ -53,14 +55,14 @@ class ApiResponse(api_client.ApiResponse):
5355
{{/if}}
5456
{{/each}}
5557
]
56-
headers: schemas.Unset
58+
headers: schemas.Unset = schemas.unset
5759
{{/if}}
5860
{{/or}}
5961
{{/and}}
6062
{{#unless responseHeaders}}
6163
{{#unless content}}
62-
body: schemas.Unset
63-
headers: schemas.Unset
64+
body: schemas.Unset = schemas.unset
65+
headers: schemas.Unset = schemas.unset
6466
{{/unless}}
6567
{{/unless}}
6668

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.0.0
1+
unset

samples/openapi3/client/petstore/python/petstore_api/api_client.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
Generated by: https://openapi-generator.tech
99
"""
1010

11-
from dataclasses import dataclass
11+
import dataclasses
1212
from decimal import Decimal
1313
import enum
1414
import email
@@ -343,7 +343,7 @@ def _content_type_is_json(cls, content_type: str) -> bool:
343343
return False
344344

345345

346-
@dataclass
346+
@dataclasses.dataclass
347347
class ParameterBase(JSONDetector):
348348
name: str
349349
in_type: ParameterInType
@@ -783,7 +783,7 @@ def __init__(
783783
self.allow_reserved = allow_reserved
784784

785785

786-
@dataclass
786+
@dataclasses.dataclass
787787
class MediaType:
788788
"""
789789
Used to store request and response body schema information
@@ -797,7 +797,7 @@ class MediaType:
797797
encoding: typing.Optional[typing.Dict[str, Encoding]] = None
798798

799799

800-
@dataclass
800+
@dataclasses.dataclass
801801
class ApiResponse:
802802
response: urllib3.HTTPResponse
803803
body: typing.Union[Unset, Schema]
@@ -817,7 +817,7 @@ def __init__(
817817
self.headers = headers
818818

819819

820-
@dataclass
820+
@dataclasses.dataclass
821821
class ApiResponseWithoutDeserialization(ApiResponse):
822822
response: urllib3.HTTPResponse
823823
body: typing.Union[Unset, typing.Type[Schema]] = unset

samples/openapi3/client/petstore/python/petstore_api/paths/another_fake_dummy/patch/response_for_200.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import dataclasses
12
import urllib3
23

34
from petstore_api import api_client
@@ -23,12 +24,13 @@ class BodySchemas:
2324
pass
2425

2526

27+
@dataclasses.dataclass
2628
class ApiResponse(api_client.ApiResponse):
2729
response: urllib3.HTTPResponse
2830
body: typing.Union[
2931
BodySchemas.application_json,
3032
]
31-
headers: schemas.Unset
33+
headers: schemas.Unset = schemas.unset
3234

3335

3436
response = api_client.OpenApiResponse(

samples/openapi3/client/petstore/python/petstore_api/paths/fake/delete/response_for_200.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import dataclasses
12
import urllib3
23

34
from petstore_api import api_client
@@ -15,10 +16,11 @@
1516
from petstore_api import schemas # noqa: F401
1617

1718

19+
@dataclasses.dataclass
1820
class ApiResponse(api_client.ApiResponse):
1921
response: urllib3.HTTPResponse
20-
body: schemas.Unset
21-
headers: schemas.Unset
22+
body: schemas.Unset = schemas.unset
23+
headers: schemas.Unset = schemas.unset
2224

2325

2426
response = api_client.OpenApiResponse(

samples/openapi3/client/petstore/python/petstore_api/paths/fake/get/response_for_200.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import dataclasses
12
import urllib3
23

34
from petstore_api import api_client
@@ -15,10 +16,11 @@
1516
from petstore_api import schemas # noqa: F401
1617

1718

19+
@dataclasses.dataclass
1820
class ApiResponse(api_client.ApiResponse):
1921
response: urllib3.HTTPResponse
20-
body: schemas.Unset
21-
headers: schemas.Unset
22+
body: schemas.Unset = schemas.unset
23+
headers: schemas.Unset = schemas.unset
2224

2325

2426
response = api_client.OpenApiResponse(

samples/openapi3/client/petstore/python/petstore_api/paths/fake/get/response_for_404.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import dataclasses
12
import urllib3
23

34
from petstore_api import api_client
@@ -15,10 +16,11 @@
1516
from petstore_api import schemas # noqa: F401
1617

1718

19+
@dataclasses.dataclass
1820
class ApiResponse(api_client.ApiResponse):
1921
response: urllib3.HTTPResponse
20-
body: schemas.Unset
21-
headers: schemas.Unset
22+
body: schemas.Unset = schemas.unset
23+
headers: schemas.Unset = schemas.unset
2224

2325

2426
response = api_client.OpenApiResponse(

samples/openapi3/client/petstore/python/petstore_api/paths/fake/patch/response_for_200.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import dataclasses
12
import urllib3
23

34
from petstore_api import api_client
@@ -23,12 +24,13 @@ class BodySchemas:
2324
pass
2425

2526

27+
@dataclasses.dataclass
2628
class ApiResponse(api_client.ApiResponse):
2729
response: urllib3.HTTPResponse
2830
body: typing.Union[
2931
BodySchemas.application_json,
3032
]
31-
headers: schemas.Unset
33+
headers: schemas.Unset = schemas.unset
3234

3335

3436
response = api_client.OpenApiResponse(

samples/openapi3/client/petstore/python/petstore_api/paths/fake/post/response_for_200.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import dataclasses
12
import urllib3
23

34
from petstore_api import api_client
@@ -15,10 +16,11 @@
1516
from petstore_api import schemas # noqa: F401
1617

1718

19+
@dataclasses.dataclass
1820
class ApiResponse(api_client.ApiResponse):
1921
response: urllib3.HTTPResponse
20-
body: schemas.Unset
21-
headers: schemas.Unset
22+
body: schemas.Unset = schemas.unset
23+
headers: schemas.Unset = schemas.unset
2224

2325

2426
response = api_client.OpenApiResponse(

samples/openapi3/client/petstore/python/petstore_api/paths/fake/post/response_for_404.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import dataclasses
12
import urllib3
23

34
from petstore_api import api_client
@@ -15,10 +16,11 @@
1516
from petstore_api import schemas # noqa: F401
1617

1718

19+
@dataclasses.dataclass
1820
class ApiResponse(api_client.ApiResponse):
1921
response: urllib3.HTTPResponse
20-
body: schemas.Unset
21-
headers: schemas.Unset
22+
body: schemas.Unset = schemas.unset
23+
headers: schemas.Unset = schemas.unset
2224

2325

2426
response = api_client.OpenApiResponse(

samples/openapi3/client/petstore/python/petstore_api/paths/fake_additional_properties_with_array_of_enums/get/response_for_200.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import dataclasses
12
import urllib3
23

34
from petstore_api import api_client
@@ -23,12 +24,13 @@ class BodySchemas:
2324
pass
2425

2526

27+
@dataclasses.dataclass
2628
class ApiResponse(api_client.ApiResponse):
2729
response: urllib3.HTTPResponse
2830
body: typing.Union[
2931
BodySchemas.application_json,
3032
]
31-
headers: schemas.Unset
33+
headers: schemas.Unset = schemas.unset
3234

3335

3436
response = api_client.OpenApiResponse(

samples/openapi3/client/petstore/python/petstore_api/paths/fake_body_with_file_schema/put/response_for_200.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import dataclasses
12
import urllib3
23

34
from petstore_api import api_client
@@ -15,10 +16,11 @@
1516
from petstore_api import schemas # noqa: F401
1617

1718

19+
@dataclasses.dataclass
1820
class ApiResponse(api_client.ApiResponse):
1921
response: urllib3.HTTPResponse
20-
body: schemas.Unset
21-
headers: schemas.Unset
22+
body: schemas.Unset = schemas.unset
23+
headers: schemas.Unset = schemas.unset
2224

2325

2426
response = api_client.OpenApiResponse(

samples/openapi3/client/petstore/python/petstore_api/paths/fake_body_with_query_params/put/response_for_200.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import dataclasses
12
import urllib3
23

34
from petstore_api import api_client
@@ -15,10 +16,11 @@
1516
from petstore_api import schemas # noqa: F401
1617

1718

19+
@dataclasses.dataclass
1820
class ApiResponse(api_client.ApiResponse):
1921
response: urllib3.HTTPResponse
20-
body: schemas.Unset
21-
headers: schemas.Unset
22+
body: schemas.Unset = schemas.unset
23+
headers: schemas.Unset = schemas.unset
2224

2325

2426
response = api_client.OpenApiResponse(

samples/openapi3/client/petstore/python/petstore_api/paths/fake_case_sensitive_params/put/response_for_200.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import dataclasses
12
import urllib3
23

34
from petstore_api import api_client
@@ -15,10 +16,11 @@
1516
from petstore_api import schemas # noqa: F401
1617

1718

19+
@dataclasses.dataclass
1820
class ApiResponse(api_client.ApiResponse):
1921
response: urllib3.HTTPResponse
20-
body: schemas.Unset
21-
headers: schemas.Unset
22+
body: schemas.Unset = schemas.unset
23+
headers: schemas.Unset = schemas.unset
2224

2325

2426
response = api_client.OpenApiResponse(

samples/openapi3/client/petstore/python/petstore_api/paths/fake_classname_test/patch/response_for_200.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import dataclasses
12
import urllib3
23

34
from petstore_api import api_client
@@ -23,12 +24,13 @@ class BodySchemas:
2324
pass
2425

2526

27+
@dataclasses.dataclass
2628
class ApiResponse(api_client.ApiResponse):
2729
response: urllib3.HTTPResponse
2830
body: typing.Union[
2931
BodySchemas.application_json,
3032
]
31-
headers: schemas.Unset
33+
headers: schemas.Unset = schemas.unset
3234

3335

3436
response = api_client.OpenApiResponse(

samples/openapi3/client/petstore/python/petstore_api/paths/fake_delete_coffee_id/delete/response_for_200.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import dataclasses
12
import urllib3
23

34
from petstore_api import api_client
@@ -15,10 +16,11 @@
1516
from petstore_api import schemas # noqa: F401
1617

1718

19+
@dataclasses.dataclass
1820
class ApiResponse(api_client.ApiResponse):
1921
response: urllib3.HTTPResponse
20-
body: schemas.Unset
21-
headers: schemas.Unset
22+
body: schemas.Unset = schemas.unset
23+
headers: schemas.Unset = schemas.unset
2224

2325

2426
response = api_client.OpenApiResponse(

0 commit comments

Comments
 (0)