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

Commit bd2894c

Browse files
committed
Adds content info to parameters
1 parent 4ada96b commit bd2894c

File tree

4 files changed

+41
-6
lines changed

4 files changed

+41
-6
lines changed

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,16 @@ request_{{#if isQueryParam}}query{{/if}}{{#if isPathParam}}path{{/if}}{{#if isHe
44
style=api_client.ParameterStyle.{{style}},
55
{{/if}}
66
{{#if schema}}
7-
{{#with schema}}
7+
{{#with schema}}
88
schema={{baseName}},
9-
{{/with}}
9+
{{/with}}
10+
{{/if}}
11+
{{#if getContent}}
12+
content={
13+
{{#each getContent}}
14+
"{{@key}}": {{#with this}}{{#with schema}}{{baseName}}{{/with}}{{/with}},
15+
{{/each}}
16+
},
1017
{{/if}}
1118
{{#if required}}
1219
required=True,

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

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,31 @@
11
# {{xParamsName}} params
22
{{#each xParams}}
3-
{{#with schema}}
3+
{{#if schema}}
4+
{{#with schema}}
45
{{> model_templates/schema }}
5-
{{/with}}
6+
{{/with}}
7+
{{else}}
8+
{{#if getContent}}
9+
{{#each getContent}}
10+
{{#with this}}
11+
{{#with schema}}
12+
{{> model_templates/schema }}
13+
{{/with}}
14+
{{/with}}
15+
{{/each}}
16+
{{/if}}
17+
{{/if}}
618
{{/each}}
719
RequestRequired{{xParamsName}}Params = typing_extensions.TypedDict(
820
'RequestRequired{{xParamsName}}Params',
921
{
1022
{{#each xParams}}
1123
{{#if required}}
24+
{{#if schema}}
1225
'{{baseName}}': {{#with schema}}typing.Union[{{baseName}}, {{> model_templates/schema_python_types }}],{{/with}}
26+
{{else}}
27+
'{{baseName}}': {{#each getContent}}{{#with this}}{{#with schema}}typing.Union[{{baseName}}, {{> model_templates/schema_python_types }}],{{/with}}{{/with}}{{/each}}
28+
{{/if}}
1329
{{/if}}
1430
{{/each}}
1531
}
@@ -19,7 +35,11 @@ RequestOptional{{xParamsName}}Params = typing_extensions.TypedDict(
1935
{
2036
{{#each xParams}}
2137
{{#unless required}}
38+
{{#if schema}}
2239
'{{baseName}}': {{#with schema}}typing.Union[{{baseName}}, {{> model_templates/schema_python_types }}],{{/with}}
40+
{{else}}
41+
'{{baseName}}': {{#each getContent}}{{#with this}}{{#with schema}}typing.Union[{{baseName}}, {{> model_templates/schema_python_types }}],{{/with}}{{/with}}{{/each}}
42+
{{/if}}
2343
{{/unless}}
2444
{{/each}}
2545
},

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,11 @@
2828
from . import path
2929

3030
# Query params
31+
SchemaForRequestParameterSomeParamApplicationJson = schemas.AnyTypeSchema
3132
RequestRequiredQueryParams = typing_extensions.TypedDict(
3233
'RequestRequiredQueryParams',
3334
{
34-
'someParam':
35+
'someParam': typing.Union[SchemaForRequestParameterSomeParamApplicationJson, dict, frozendict.frozendict, str, date, datetime, uuid.UUID, int, float, decimal.Decimal, bool, None, list, tuple, bytes, io.FileIO, io.BufferedReader, ],
3536
}
3637
)
3738
RequestOptionalQueryParams = typing_extensions.TypedDict(
@@ -48,6 +49,9 @@ class RequestQueryParams(RequestRequiredQueryParams, RequestOptionalQueryParams)
4849

4950
request_query_some_param = api_client.QueryParameter(
5051
name="someParam",
52+
content={
53+
"application/json": SchemaForRequestParameterSomeParamApplicationJson,
54+
},
5155
required=True,
5256
)
5357
SchemaFor200ResponseBodyApplicationJson = schemas.AnyTypeSchema

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,11 @@ import frozendict # noqa: F401
2626
from petstore_api import schemas # noqa: F401
2727

2828
# Query params
29+
SchemaForRequestParameterSomeParamApplicationJson = schemas.AnyTypeSchema
2930
RequestRequiredQueryParams = typing_extensions.TypedDict(
3031
'RequestRequiredQueryParams',
3132
{
32-
'someParam':
33+
'someParam': typing.Union[SchemaForRequestParameterSomeParamApplicationJson, dict, frozendict.frozendict, str, date, datetime, uuid.UUID, int, float, decimal.Decimal, bool, None, list, tuple, bytes, io.FileIO, io.BufferedReader, ],
3334
}
3435
)
3536
RequestOptionalQueryParams = typing_extensions.TypedDict(
@@ -46,6 +47,9 @@ class RequestQueryParams(RequestRequiredQueryParams, RequestOptionalQueryParams)
4647

4748
request_query_some_param = api_client.QueryParameter(
4849
name="someParam",
50+
content={
51+
"application/json": SchemaForRequestParameterSomeParamApplicationJson,
52+
},
4953
required=True,
5054
)
5155
SchemaFor200ResponseBodyApplicationJson = schemas.AnyTypeSchema

0 commit comments

Comments
 (0)