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

Commit 4d7f315

Browse files
committed
Generates sample with new endpoint
1 parent 03c7ba7 commit 4d7f315

File tree

15 files changed

+764
-1
lines changed

15 files changed

+764
-1
lines changed

modules/openapi-json-schema-generator/src/main/java/org/openapitools/codegen/languages/PythonClientCodegen.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -997,12 +997,13 @@ public CodegenParameter fromParameter(Parameter parameter, Set<String> imports)
997997
}
998998
}
999999
// clone this so we can change some properties on it
1000-
CodegenProperty schemaProp = cp.getSchema().clone();
1000+
CodegenProperty schemaProp = cp.getSchema();
10011001
// parameters may have valid python names like some_val or invalid ones like Content-Type
10021002
// we always set nameInSnakeCase to null so special handling will not be done for these names
10031003
// invalid python names will be handled in python by using a TypedDict which will allow us to have a type hint
10041004
// for keys that cannot be variable names to the schema baseName
10051005
if (schemaProp != null) {
1006+
schemaProp = schemaProp.clone();
10061007
schemaProp.nameInSnakeCase = null;
10071008
schemaProp.baseName = toModelName(cp.baseName) + "Schema";
10081009
cp.setSchema(schemaProp);

modules/openapi-json-schema-generator/src/test/resources/3_0/python/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1592,6 +1592,26 @@ paths:
15921592
description: OK
15931593
default:
15941594
description: Unexpected error
1595+
/fake/queryParamWithJsonContentType:
1596+
get:
1597+
operationId: queryParamWithJsonContentType
1598+
summary: query param with json content-type
1599+
tags:
1600+
- fake
1601+
parameters:
1602+
- name: someParam
1603+
in: query
1604+
description: The internal object id
1605+
required: true
1606+
content:
1607+
application/json:
1608+
schema: {}
1609+
responses:
1610+
200:
1611+
description: success
1612+
content:
1613+
application/json:
1614+
schema: {}
15951615
servers:
15961616
- url: 'http://{server}.swagger.io:{port}/v2'
15971617
description: petstore server

samples/openapi3/client/petstore/python/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ Class | Method | HTTP request | Description
197197
*FakeApi* | [**object_in_query**](docs/apis/tags/FakeApi.md#object_in_query) | **get** /fake/objInQuery | user list
198198
*FakeApi* | [**object_model_with_ref_props**](docs/apis/tags/FakeApi.md#object_model_with_ref_props) | **post** /fake/refs/object_model_with_ref_props |
199199
*FakeApi* | [**parameter_collisions**](docs/apis/tags/FakeApi.md#parameter_collisions) | **post** /fake/parameterCollisions/{1}/{aB}/{Ab}/{self}/{A-B}/ | parameter collision case
200+
*FakeApi* | [**query_param_with_json_content_type**](docs/apis/tags/FakeApi.md#query_param_with_json_content_type) | **get** /fake/queryParamWithJsonContentType | query param with json content-type
200201
*FakeApi* | [**query_parameter_collection_format**](docs/apis/tags/FakeApi.md#query_parameter_collection_format) | **put** /fake/test-query-paramters |
201202
*FakeApi* | [**ref_object_in_query**](docs/apis/tags/FakeApi.md#ref_object_in_query) | **get** /fake/refObjInQuery | user list
202203
*FakeApi* | [**response_without_schema**](docs/apis/tags/FakeApi.md#response_without_schema) | **get** /fake/responseWithoutSchema | receives a response without schema

samples/openapi3/client/petstore/python/docs/apis/tags/FakeApi.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Method | HTTP request | Description
2929
[**object_in_query**](#object_in_query) | **get** /fake/objInQuery | user list
3030
[**object_model_with_ref_props**](#object_model_with_ref_props) | **post** /fake/refs/object_model_with_ref_props |
3131
[**parameter_collisions**](#parameter_collisions) | **post** /fake/parameterCollisions/{1}/{aB}/{Ab}/{self}/{A-B}/ | parameter collision case
32+
[**query_param_with_json_content_type**](#query_param_with_json_content_type) | **get** /fake/queryParamWithJsonContentType | query param with json content-type
3233
[**query_parameter_collection_format**](#query_parameter_collection_format) | **put** /fake/test-query-paramters |
3334
[**ref_object_in_query**](#ref_object_in_query) | **get** /fake/refObjInQuery | user list
3435
[**response_without_schema**](#response_without_schema) | **get** /fake/responseWithoutSchema | receives a response without schema
@@ -2671,6 +2672,87 @@ No authorization required
26712672

26722673
[[Back to top]](#__pageTop) [[Back to API list]](../../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../../README.md#documentation-for-models) [[Back to README]](../../../README.md)
26732674

2675+
# **query_param_with_json_content_type**
2676+
<a name="query_param_with_json_content_type"></a>
2677+
> bool, date, datetime, dict, float, int, list, str, none_type query_param_with_json_content_type(some_param)
2678+
2679+
query param with json content-type
2680+
2681+
### Example
2682+
2683+
```python
2684+
import petstore_api
2685+
from petstore_api.apis.tags import fake_api
2686+
from pprint import pprint
2687+
# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2
2688+
# See configuration.py for a list of all supported configuration parameters.
2689+
configuration = petstore_api.Configuration(
2690+
host = "http://petstore.swagger.io:80/v2"
2691+
)
2692+
2693+
# Enter a context with an instance of the API client
2694+
with petstore_api.ApiClient(configuration) as api_client:
2695+
# Create an instance of the API class
2696+
api_instance = fake_api.FakeApi(api_client)
2697+
2698+
# example passing only required values which don't have defaults set
2699+
query_params = {
2700+
'someParam': ,
2701+
}
2702+
try:
2703+
# query param with json content-type
2704+
api_response = api_instance.query_param_with_json_content_type(
2705+
query_params=query_params,
2706+
)
2707+
pprint(api_response)
2708+
except petstore_api.ApiException as e:
2709+
print("Exception when calling FakeApi->query_param_with_json_content_type: %s\n" % e)
2710+
```
2711+
### Parameters
2712+
2713+
Name | Type | Description | Notes
2714+
------------- | ------------- | ------------- | -------------
2715+
query_params | RequestQueryParams | |
2716+
accept_content_types | typing.Tuple[str] | default is ('application/json', ) | Tells the server the content type(s) that are accepted by the client
2717+
stream | bool | default is False | if True then the response.content will be streamed and loaded from a file like object. When downloading a file, set this to True to force the code to deserialize the content to a FileSchema file
2718+
timeout | typing.Optional[typing.Union[int, typing.Tuple]] | default is None | the timeout used by the rest client
2719+
skip_deserialization | bool | default is False | when True, headers and body will be unset and an instance of api_client.ApiResponseWithoutDeserialization will be returned
2720+
2721+
### query_params
2722+
#### RequestQueryParams
2723+
2724+
Name | Type | Description | Notes
2725+
------------- | ------------- | ------------- | -------------
2726+
someParam | | |
2727+
2728+
2729+
### Return Types, Responses
2730+
2731+
Code | Class | Description
2732+
------------- | ------------- | -------------
2733+
n/a | api_client.ApiResponseWithoutDeserialization | When skip_deserialization is True this response is returned
2734+
200 | [ApiResponseFor200](#query_param_with_json_content_type.ApiResponseFor200) | success
2735+
2736+
#### query_param_with_json_content_type.ApiResponseFor200
2737+
Name | Type | Description | Notes
2738+
------------- | ------------- | ------------- | -------------
2739+
response | urllib3.HTTPResponse | Raw response |
2740+
body | typing.Union[SchemaFor200ResponseBodyApplicationJson, ] | |
2741+
headers | Unset | headers were not defined |
2742+
2743+
# SchemaFor200ResponseBodyApplicationJson
2744+
2745+
## Model Type Info
2746+
Input Type | Accessed Type | Description | Notes
2747+
------------ | ------------- | ------------- | -------------
2748+
dict, frozendict.frozendict, str, date, datetime, uuid.UUID, int, float, decimal.Decimal, bool, None, list, tuple, bytes, io.FileIO, io.BufferedReader, | frozendict.frozendict, str, decimal.Decimal, BoolClass, NoneClass, tuple, bytes, FileIO | |
2749+
2750+
### Authorization
2751+
2752+
No authorization required
2753+
2754+
[[Back to top]](#__pageTop) [[Back to API list]](../../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../../README.md#documentation-for-models) [[Back to README]](../../../README.md)
2755+
26742756
# **query_parameter_collection_format**
26752757
<a name="query_parameter_collection_format"></a>
26762758
> query_parameter_collection_format(pipeioutilhttpurlcontextref_param)

samples/openapi3/client/petstore/python/petstore_api/apis/path_to_api.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
from petstore_api.apis.paths.fake_response_without_schema import FakeResponseWithoutSchema
4949
from petstore_api.apis.paths.fake_json_patch import FakeJsonPatch
5050
from petstore_api.apis.paths.fake_delete_coffee_id import FakeDeleteCoffeeId
51+
from petstore_api.apis.paths.fake_query_param_with_json_content_type import FakeQueryParamWithJsonContentType
5152

5253
PathToApi = typing_extensions.TypedDict(
5354
'PathToApi',
@@ -99,6 +100,7 @@
99100
PathValues.FAKE_RESPONSE_WITHOUT_SCHEMA: FakeResponseWithoutSchema,
100101
PathValues.FAKE_JSON_PATCH: FakeJsonPatch,
101102
PathValues.FAKE_DELETE_COFFEE_ID: FakeDeleteCoffeeId,
103+
PathValues.FAKE_QUERY_PARAM_WITH_JSON_CONTENT_TYPE: FakeQueryParamWithJsonContentType,
102104
}
103105
)
104106

@@ -151,5 +153,6 @@
151153
PathValues.FAKE_RESPONSE_WITHOUT_SCHEMA: FakeResponseWithoutSchema,
152154
PathValues.FAKE_JSON_PATCH: FakeJsonPatch,
153155
PathValues.FAKE_DELETE_COFFEE_ID: FakeDeleteCoffeeId,
156+
PathValues.FAKE_QUERY_PARAM_WITH_JSON_CONTENT_TYPE: FakeQueryParamWithJsonContentType,
154157
}
155158
)
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from petstore_api.paths.fake_query_param_with_json_content_type.get import ApiForget
2+
3+
4+
class FakeQueryParamWithJsonContentType(
5+
ApiForget,
6+
):
7+
pass

samples/openapi3/client/petstore/python/petstore_api/apis/tags/fake_api.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
from petstore_api.paths.fake_obj_in_query.get import ObjectInQuery
3434
from petstore_api.paths.fake_refs_object_model_with_ref_props.post import ObjectModelWithRefProps
3535
from petstore_api.paths.fake_parameter_collisions_1_a_b_ab_self_a_b_.post import ParameterCollisions
36+
from petstore_api.paths.fake_query_param_with_json_content_type.get import QueryParamWithJsonContentType
3637
from petstore_api.paths.fake_test_query_paramters.put import QueryParameterCollectionFormat
3738
from petstore_api.paths.fake_ref_obj_in_query.get import RefObjectInQuery
3839
from petstore_api.paths.fake_response_without_schema.get import ResponseWithoutSchema
@@ -68,6 +69,7 @@ class FakeApi(
6869
ObjectInQuery,
6970
ObjectModelWithRefProps,
7071
ParameterCollisions,
72+
QueryParamWithJsonContentType,
7173
QueryParameterCollectionFormat,
7274
RefObjectInQuery,
7375
ResponseWithoutSchema,

samples/openapi3/client/petstore/python/petstore_api/paths/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,4 @@ class PathValues(str, enum.Enum):
5353
FAKE_RESPONSE_WITHOUT_SCHEMA = "/fake/responseWithoutSchema"
5454
FAKE_JSON_PATCH = "/fake/jsonPatch"
5555
FAKE_DELETE_COFFEE_ID = "/fake/deleteCoffee/{id}"
56+
FAKE_QUERY_PARAM_WITH_JSON_CONTENT_TYPE = "/fake/queryParamWithJsonContentType"
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# do not import all endpoints into this module because that uses a lot of memory and stack frames
2+
# if you need the ability to import all endpoints from this module, import them with
3+
# from petstore_api.paths.fake_query_param_with_json_content_type import Api
4+
5+
from petstore_api.paths import PathValues
6+
7+
path = PathValues.FAKE_QUERY_PARAM_WITH_JSON_CONTENT_TYPE

0 commit comments

Comments
 (0)