Skip to content

Commit f281371

Browse files
authored
[Python] Add __all__ variable in the package __init__.py file for Python APIs (#21185)
* Add __all__ to the package __init__.py file for Python APIs * Remove empty line before closing bracket * Add missing samples
1 parent 3048fb0 commit f281371

File tree

9 files changed

+647
-0
lines changed

9 files changed

+647
-0
lines changed

modules/openapi-generator/src/main/resources/python-pydantic-v1/__init__package.mustache

+17
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,23 @@
66

77
__version__ = "{{packageVersion}}"
88

9+
# Define package exports
10+
__all__ = [
11+
{{#apiInfo}}{{#apis}}"{{classname}}",
12+
{{/apis}}{{/apiInfo}}"ApiResponse",
13+
"ApiClient",
14+
"Configuration",
15+
"OpenApiException",
16+
"ApiTypeError",
17+
"ApiValueError",
18+
"ApiKeyError",
19+
"ApiAttributeError",
20+
"ApiException",
21+
{{#hasHttpSignatureMethods}}"HttpSigningConfiguration",
22+
{{/hasHttpSignatureMethods}}{{#models}}{{#model}}"{{classname}}"{{^-last}},
23+
{{/-last}}{{#-last}},{{/-last}}{{/model}}{{/models}}
24+
]
25+
926
# import apis into sdk package
1027
{{#apiInfo}}{{#apis}}from {{apiPackage}}.{{classFilename}} import {{classname}}
1128
{{/apis}}{{/apiInfo}}

modules/openapi-generator/src/main/resources/python/__init__package.mustache

+17
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,23 @@
66

77
__version__ = "{{packageVersion}}"
88

9+
# Define package exports
10+
__all__ = [
11+
{{#apiInfo}}{{#apis}}"{{classname}}",
12+
{{/apis}}{{/apiInfo}}"ApiResponse",
13+
"ApiClient",
14+
"Configuration",
15+
"OpenApiException",
16+
"ApiTypeError",
17+
"ApiValueError",
18+
"ApiKeyError",
19+
"ApiAttributeError",
20+
"ApiException",
21+
{{#hasHttpSignatureMethods}}"HttpSigningConfiguration",
22+
{{/hasHttpSignatureMethods}}{{#models}}{{#model}}"{{classname}}"{{^-last}},
23+
{{/-last}}{{#-last}},{{/-last}}{{/model}}{{/models}}
24+
]
25+
926
# import apis into sdk package
1027
{{#apiInfo}}{{#apis}}from {{apiPackage}}.{{classFilename}} import {{classname}}
1128
{{/apis}}{{/apiInfo}}

samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/__init__.py

+31
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,37 @@
1717

1818
__version__ = "1.0.0"
1919

20+
# Define package exports
21+
__all__ = [
22+
"AuthApi",
23+
"BodyApi",
24+
"FormApi",
25+
"HeaderApi",
26+
"PathApi",
27+
"QueryApi",
28+
"ApiResponse",
29+
"ApiClient",
30+
"Configuration",
31+
"OpenApiException",
32+
"ApiTypeError",
33+
"ApiValueError",
34+
"ApiKeyError",
35+
"ApiAttributeError",
36+
"ApiException",
37+
"Bird",
38+
"Category",
39+
"DataQuery",
40+
"DefaultValue",
41+
"NumberPropertiesOnly",
42+
"Pet",
43+
"Query",
44+
"StringEnumRef",
45+
"Tag",
46+
"TestFormObjectMultipartRequestMarker",
47+
"TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter",
48+
"TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter",
49+
]
50+
2051
# import apis into sdk package
2152
from openapi_client.api.auth_api import AuthApi
2253
from openapi_client.api.body_api import BodyApi

samples/client/echo_api/python-pydantic-v1/openapi_client/__init__.py

+31
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,37 @@
1717

1818
__version__ = "1.0.0"
1919

20+
# Define package exports
21+
__all__ = [
22+
"AuthApi",
23+
"BodyApi",
24+
"FormApi",
25+
"HeaderApi",
26+
"PathApi",
27+
"QueryApi",
28+
"ApiResponse",
29+
"ApiClient",
30+
"Configuration",
31+
"OpenApiException",
32+
"ApiTypeError",
33+
"ApiValueError",
34+
"ApiKeyError",
35+
"ApiAttributeError",
36+
"ApiException",
37+
"Bird",
38+
"Category",
39+
"DataQuery",
40+
"DefaultValue",
41+
"NumberPropertiesOnly",
42+
"Pet",
43+
"Query",
44+
"StringEnumRef",
45+
"Tag",
46+
"TestFormObjectMultipartRequestMarker",
47+
"TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter",
48+
"TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter",
49+
]
50+
2051
# import apis into sdk package
2152
from openapi_client.api.auth_api import AuthApi
2253
from openapi_client.api.body_api import BodyApi

samples/client/echo_api/python/openapi_client/__init__.py

+31
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,37 @@
1717

1818
__version__ = "1.0.0"
1919

20+
# Define package exports
21+
__all__ = [
22+
"AuthApi",
23+
"BodyApi",
24+
"FormApi",
25+
"HeaderApi",
26+
"PathApi",
27+
"QueryApi",
28+
"ApiResponse",
29+
"ApiClient",
30+
"Configuration",
31+
"OpenApiException",
32+
"ApiTypeError",
33+
"ApiValueError",
34+
"ApiKeyError",
35+
"ApiAttributeError",
36+
"ApiException",
37+
"Bird",
38+
"Category",
39+
"DataQuery",
40+
"DefaultValue",
41+
"NumberPropertiesOnly",
42+
"Pet",
43+
"Query",
44+
"StringEnumRef",
45+
"Tag",
46+
"TestFormObjectMultipartRequestMarker",
47+
"TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter",
48+
"TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter",
49+
]
50+
2051
# import apis into sdk package
2152
from openapi_client.api.auth_api import AuthApi
2253
from openapi_client.api.body_api import BodyApi

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

+130
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,136 @@
1616

1717
__version__ = "1.0.0"
1818

19+
# Define package exports
20+
__all__ = [
21+
"AnotherFakeApi",
22+
"DefaultApi",
23+
"FakeApi",
24+
"FakeClassnameTags123Api",
25+
"ImportTestDatetimeApi",
26+
"PetApi",
27+
"StoreApi",
28+
"UserApi",
29+
"ApiResponse",
30+
"ApiClient",
31+
"Configuration",
32+
"OpenApiException",
33+
"ApiTypeError",
34+
"ApiValueError",
35+
"ApiKeyError",
36+
"ApiAttributeError",
37+
"ApiException",
38+
"HttpSigningConfiguration",
39+
"AdditionalPropertiesAnyType",
40+
"AdditionalPropertiesClass",
41+
"AdditionalPropertiesObject",
42+
"AdditionalPropertiesWithDescriptionOnly",
43+
"AllOfSuperModel",
44+
"AllOfWithSingleRef",
45+
"Animal",
46+
"AnyOfColor",
47+
"AnyOfPig",
48+
"ArrayOfArrayOfModel",
49+
"ArrayOfArrayOfNumberOnly",
50+
"ArrayOfNumberOnly",
51+
"ArrayTest",
52+
"BaseDiscriminator",
53+
"BasquePig",
54+
"Bathing",
55+
"Capitalization",
56+
"Cat",
57+
"Category",
58+
"CircularAllOfRef",
59+
"CircularReferenceModel",
60+
"ClassModel",
61+
"Client",
62+
"Color",
63+
"Creature",
64+
"CreatureInfo",
65+
"DanishPig",
66+
"DeprecatedObject",
67+
"DiscriminatorAllOfSub",
68+
"DiscriminatorAllOfSuper",
69+
"Dog",
70+
"DummyModel",
71+
"EnumArrays",
72+
"EnumClass",
73+
"EnumNumberVendorExt",
74+
"EnumString1",
75+
"EnumString2",
76+
"EnumStringVendorExt",
77+
"EnumTest",
78+
"Feeding",
79+
"File",
80+
"FileSchemaTestClass",
81+
"FirstRef",
82+
"Foo",
83+
"FooGetDefaultResponse",
84+
"FormatTest",
85+
"HasOnlyReadOnly",
86+
"HealthCheckResult",
87+
"HuntingDog",
88+
"Info",
89+
"InnerDictWithProperty",
90+
"InputAllOf",
91+
"IntOrString",
92+
"ListClass",
93+
"MapOfArrayOfModel",
94+
"MapTest",
95+
"MixedPropertiesAndAdditionalPropertiesClass",
96+
"Model200Response",
97+
"ModelApiResponse",
98+
"ModelField",
99+
"ModelReturn",
100+
"MultiArrays",
101+
"Name",
102+
"NullableClass",
103+
"NullableProperty",
104+
"NumberOnly",
105+
"ObjectToTestAdditionalProperties",
106+
"ObjectWithDeprecatedFields",
107+
"OneOfEnumString",
108+
"Order",
109+
"OuterComposite",
110+
"OuterEnum",
111+
"OuterEnumDefaultValue",
112+
"OuterEnumInteger",
113+
"OuterEnumIntegerDefaultValue",
114+
"OuterObjectWithEnumProperty",
115+
"Parent",
116+
"ParentWithOptionalDict",
117+
"Pet",
118+
"Pig",
119+
"PoopCleaning",
120+
"PrimitiveString",
121+
"PropertyMap",
122+
"PropertyNameCollision",
123+
"ReadOnlyFirst",
124+
"SecondCircularAllOfRef",
125+
"SecondRef",
126+
"SelfReferenceModel",
127+
"SingleRefType",
128+
"SpecialCharacterEnum",
129+
"SpecialModelName",
130+
"SpecialName",
131+
"Tag",
132+
"Task",
133+
"TaskActivity",
134+
"TestEnum",
135+
"TestEnumWithDefault",
136+
"TestErrorResponsesWithModel400Response",
137+
"TestErrorResponsesWithModel404Response",
138+
"TestInlineFreeformAdditionalPropertiesRequest",
139+
"TestModelWithEnumDefault",
140+
"TestObjectForMultipartRequestsRequestMarker",
141+
"Tiger",
142+
"UnnamedDictWithAdditionalModelListProperties",
143+
"UnnamedDictWithAdditionalStringListProperties",
144+
"UploadFileWithAdditionalPropertiesRequestObject",
145+
"User",
146+
"WithNestedOneOf",
147+
]
148+
19149
# import apis into sdk package
20150
from petstore_api.api.another_fake_api import AnotherFakeApi
21151
from petstore_api.api.default_api import DefaultApi

0 commit comments

Comments
 (0)