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

Commit 4ada96b

Browse files
committed
Adds and uses template for all non body endpoint request params
1 parent 4d7f315 commit 4ada96b

File tree

50 files changed

+100
-204
lines changed

Some content is hidden

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

50 files changed

+100
-204
lines changed

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

Lines changed: 4 additions & 144 deletions
Original file line numberDiff line numberDiff line change
@@ -21,156 +21,16 @@ from . import path
2121
{{/unless}}
2222
{{#with operation}}
2323
{{#if queryParams}}
24-
# query params
25-
{{#each queryParams}}
26-
{{#with schema}}
27-
{{> model_templates/schema }}
28-
{{/with}}
29-
{{/each}}
30-
RequestRequiredQueryParams = typing_extensions.TypedDict(
31-
'RequestRequiredQueryParams',
32-
{
33-
{{#each queryParams}}
34-
{{#if required}}
35-
'{{baseName}}': {{#with schema}}typing.Union[{{baseName}}, {{> model_templates/schema_python_types }}],{{/with}}
36-
{{/if}}
37-
{{/each}}
38-
}
39-
)
40-
RequestOptionalQueryParams = typing_extensions.TypedDict(
41-
'RequestOptionalQueryParams',
42-
{
43-
{{#each queryParams}}
44-
{{#unless required}}
45-
'{{baseName}}': {{#with schema}}typing.Union[{{baseName}}, {{> model_templates/schema_python_types }}],{{/with}}
46-
{{/unless}}
47-
{{/each}}
48-
},
49-
total=False
50-
)
51-
52-
53-
class RequestQueryParams(RequestRequiredQueryParams, RequestOptionalQueryParams):
54-
pass
55-
56-
57-
{{#each queryParams}}
58-
{{> endpoint_parameter }}
59-
{{/each}}
24+
{{> endpoint_parameter_schema_and_def xParams=queryParams xParamsName="Query" }}
6025
{{/if}}
6126
{{#if headerParams}}
62-
# header params
63-
{{#each headerParams}}
64-
{{#with schema}}
65-
{{> model_templates/schema }}
66-
{{/with}}
67-
{{/each}}
68-
RequestRequiredHeaderParams = typing_extensions.TypedDict(
69-
'RequestRequiredHeaderParams',
70-
{
71-
{{#each headerParams}}
72-
{{#if required}}
73-
'{{baseName}}': {{#with schema}}typing.Union[{{baseName}}, {{> model_templates/schema_python_types }}],{{/with}}
74-
{{/if}}
75-
{{/each}}
76-
}
77-
)
78-
RequestOptionalHeaderParams = typing_extensions.TypedDict(
79-
'RequestOptionalHeaderParams',
80-
{
81-
{{#each headerParams}}
82-
{{#unless required}}
83-
'{{baseName}}': {{#with schema}}typing.Union[{{baseName}}, {{> model_templates/schema_python_types }}],{{/with}}
84-
{{/unless}}
85-
{{/each}}
86-
},
87-
total=False
88-
)
89-
90-
91-
class RequestHeaderParams(RequestRequiredHeaderParams, RequestOptionalHeaderParams):
92-
pass
93-
94-
95-
{{#each headerParams}}
96-
{{> endpoint_parameter }}
97-
{{/each}}
27+
{{> endpoint_parameter_schema_and_def xParams=headerParams xParamsName="Header" }}
9828
{{/if}}
9929
{{#if pathParams}}
100-
# path params
101-
{{#each pathParams}}
102-
{{#with schema}}
103-
{{> model_templates/schema }}
104-
{{/with}}
105-
{{/each}}
106-
RequestRequiredPathParams = typing_extensions.TypedDict(
107-
'RequestRequiredPathParams',
108-
{
109-
{{#each pathParams}}
110-
{{#if required}}
111-
'{{baseName}}': {{#with schema}}typing.Union[{{baseName}}, {{> model_templates/schema_python_types }}],{{/with}}
112-
{{/if}}
113-
{{/each}}
114-
}
115-
)
116-
RequestOptionalPathParams = typing_extensions.TypedDict(
117-
'RequestOptionalPathParams',
118-
{
119-
{{#each pathParams}}
120-
{{#unless required}}
121-
'{{baseName}}': {{#with schema}}typing.Union[{{baseName}}, {{> model_templates/schema_python_types }}],{{/with}}
122-
{{/unless}}
123-
{{/each}}
124-
},
125-
total=False
126-
)
127-
128-
129-
class RequestPathParams(RequestRequiredPathParams, RequestOptionalPathParams):
130-
pass
131-
132-
133-
{{#each pathParams}}
134-
{{> endpoint_parameter }}
135-
{{/each}}
30+
{{> endpoint_parameter_schema_and_def xParams=pathParams xParamsName="Path" }}
13631
{{/if}}
13732
{{#if cookieParams}}
138-
# cookie params
139-
{{#each cookieParams}}
140-
{{#with schema}}
141-
{{> model_templates/schema }}
142-
{{/with}}
143-
{{/each}}
144-
RequestRequiredCookieParams = typing_extensions.TypedDict(
145-
'RequestRequiredCookieParams',
146-
{
147-
{{#each cookieParams}}
148-
{{#if required}}
149-
'{{baseName}}': {{#with schema}}typing.Union[{{baseName}}, {{> model_templates/schema_python_types }}],{{/with}}
150-
{{/if}}
151-
{{/each}}
152-
}
153-
)
154-
RequestOptionalCookieParams = typing_extensions.TypedDict(
155-
'RequestOptionalCookieParams',
156-
{
157-
{{#each cookieParams}}
158-
{{#unless required}}
159-
'{{baseName}}': {{#with schema}}typing.Union[{{baseName}}, {{> model_templates/schema_python_types }}],{{/with}}
160-
{{/unless}}
161-
{{/each}}
162-
},
163-
total=False
164-
)
165-
166-
167-
class RequestCookieParams(RequestRequiredCookieParams, RequestOptionalCookieParams):
168-
pass
169-
170-
171-
{{#each cookieParams}}
172-
{{> endpoint_parameter }}
173-
{{/each}}
33+
{{> endpoint_parameter_schema_and_def xParams=cookieParams xParamsName="Cookie" }}
17434
{{/if}}
17535
{{#with bodyParam}}
17636
# body param
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# {{xParamsName}} params
2+
{{#each xParams}}
3+
{{#with schema}}
4+
{{> model_templates/schema }}
5+
{{/with}}
6+
{{/each}}
7+
RequestRequired{{xParamsName}}Params = typing_extensions.TypedDict(
8+
'RequestRequired{{xParamsName}}Params',
9+
{
10+
{{#each xParams}}
11+
{{#if required}}
12+
'{{baseName}}': {{#with schema}}typing.Union[{{baseName}}, {{> model_templates/schema_python_types }}],{{/with}}
13+
{{/if}}
14+
{{/each}}
15+
}
16+
)
17+
RequestOptional{{xParamsName}}Params = typing_extensions.TypedDict(
18+
'RequestOptional{{xParamsName}}Params',
19+
{
20+
{{#each xParams}}
21+
{{#unless required}}
22+
'{{baseName}}': {{#with schema}}typing.Union[{{baseName}}, {{> model_templates/schema_python_types }}],{{/with}}
23+
{{/unless}}
24+
{{/each}}
25+
},
26+
total=False
27+
)
28+
29+
30+
class Request{{xParamsName}}Params(RequestRequired{{xParamsName}}Params, RequestOptional{{xParamsName}}Params):
31+
pass
32+
33+
34+
{{#each xParams}}
35+
{{> endpoint_parameter }}
36+
{{/each}}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
from . import path
2929

30-
# query params
30+
# Query params
3131
RequiredStringGroupSchema = schemas.IntSchema
3232
RequiredInt64GroupSchema = schemas.Int64Schema
3333
StringGroupSchema = schemas.IntSchema
@@ -79,7 +79,7 @@ class RequestQueryParams(RequestRequiredQueryParams, RequestOptionalQueryParams)
7979
schema=Int64GroupSchema,
8080
explode=True,
8181
)
82-
# header params
82+
# Header params
8383
RequiredBooleanGroupSchema = schemas.BoolSchema
8484
BooleanGroupSchema = schemas.BoolSchema
8585
RequestRequiredHeaderParams = typing_extensions.TypedDict(

samples/openapi3/client/petstore/python/petstore_api/paths/fake/delete.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import frozendict # noqa: F401
2525

2626
from petstore_api import schemas # noqa: F401
2727

28-
# query params
28+
# Query params
2929
RequiredStringGroupSchema = schemas.IntSchema
3030
RequiredInt64GroupSchema = schemas.Int64Schema
3131
StringGroupSchema = schemas.IntSchema
@@ -77,7 +77,7 @@ request_query_int64_group = api_client.QueryParameter(
7777
schema=Int64GroupSchema,
7878
explode=True,
7979
)
80-
# header params
80+
# Header params
8181
RequiredBooleanGroupSchema = schemas.BoolSchema
8282
BooleanGroupSchema = schemas.BoolSchema
8383
RequestRequiredHeaderParams = typing_extensions.TypedDict(

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
from . import path
2929

30-
# query params
30+
# Query params
3131

3232

3333
class EnumQueryStringArraySchema(
@@ -186,7 +186,7 @@ class RequestQueryParams(RequestRequiredQueryParams, RequestOptionalQueryParams)
186186
schema=EnumQueryDoubleSchema,
187187
explode=True,
188188
)
189-
# header params
189+
# Header params
190190

191191

192192
class EnumHeaderStringArraySchema(

samples/openapi3/client/petstore/python/petstore_api/paths/fake/get.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import frozendict # noqa: F401
2525

2626
from petstore_api import schemas # noqa: F401
2727

28-
# query params
28+
# Query params
2929

3030

3131
class EnumQueryStringArraySchema(
@@ -153,7 +153,7 @@ request_query_enum_query_double = api_client.QueryParameter(
153153
schema=EnumQueryDoubleSchema,
154154
explode=True,
155155
)
156-
# header params
156+
# Header params
157157

158158

159159
class EnumHeaderStringArraySchema(

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
from . import path
3131

32-
# query params
32+
# Query params
3333
QuerySchema = schemas.StrSchema
3434
RequestRequiredQueryParams = typing_extensions.TypedDict(
3535
'RequestRequiredQueryParams',

samples/openapi3/client/petstore/python/petstore_api/paths/fake_body_with_query_params/put.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ from petstore_api import schemas # noqa: F401
2727

2828
from petstore_api.model.user import User
2929

30-
# query params
30+
# Query params
3131
QuerySchema = schemas.StrSchema
3232
RequestRequiredQueryParams = typing_extensions.TypedDict(
3333
'RequestRequiredQueryParams',

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
from . import path
2828

29-
# query params
29+
# Query params
3030
SomeVarSchema = schemas.StrSchema
3131
SomeVarSchema = schemas.StrSchema
3232
SomeVarSchema = schemas.StrSchema

samples/openapi3/client/petstore/python/petstore_api/paths/fake_case_sensitive_params/put.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import frozendict # noqa: F401
2424

2525
from petstore_api import schemas # noqa: F401
2626

27-
# query params
27+
# Query params
2828
SomeVarSchema = schemas.StrSchema
2929
SomeVarSchema = schemas.StrSchema
3030
SomeVarSchema = schemas.StrSchema

0 commit comments

Comments
 (0)