forked from loafle/openapi-generator-original
Fixes issue where object in query parameter generates a NPE (#12010)
* Fixes issue 11946 * Fixes items assignment for deep object query params * Adds fix for inline query param object schemas * Fixes keyword name, changes it from mapBean[keyword] * Reverts version file
This commit is contained in:
parent
0c825ad301
commit
a4e2dde745
@ -269,6 +269,8 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
// A cache to efficiently lookup schema `toModelName()` based on the schema Key
|
||||
private final Map<String, String> schemaKeyToModelNameCache = new HashMap<>();
|
||||
|
||||
protected boolean loadDeepObjectIntoItems = true;
|
||||
|
||||
@Override
|
||||
public List<CliOption> cliOptions() {
|
||||
return cliOptions;
|
||||
@ -4748,10 +4750,12 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
codegenParameter.pattern = toRegularExpression(parameterSchema.getPattern());
|
||||
|
||||
if (codegenParameter.isQueryParam && codegenParameter.isDeepObject) {
|
||||
Schema schema = ModelUtils.getSchema(openAPI, codegenParameter.dataType);
|
||||
if (codegenParameter.isQueryParam && codegenParameter.isDeepObject && loadDeepObjectIntoItems) {
|
||||
Schema schema = parameterSchema;
|
||||
if (schema.get$ref() != null) {
|
||||
schema = ModelUtils.getReferencedSchema(openAPI, schema);
|
||||
}
|
||||
codegenParameter.items = fromProperty(codegenParameter.paramName, schema);
|
||||
// TODO Check why schema is actually null for a schema of type object defined inline
|
||||
// https://swagger.io/docs/specification/serialization/
|
||||
if (schema != null) {
|
||||
Map<String, Schema<?>> properties = schema.getProperties();
|
||||
|
@ -87,6 +87,7 @@ public class PythonExperimentalClientCodegen extends AbstractPythonCodegen {
|
||||
|
||||
public PythonExperimentalClientCodegen() {
|
||||
super();
|
||||
loadDeepObjectIntoItems = false;
|
||||
|
||||
modifyFeatureSet(features -> features
|
||||
.includeSchemaSupportFeatures(
|
||||
|
@ -1490,6 +1490,46 @@ paths:
|
||||
allOf:
|
||||
- type: string
|
||||
minLength: 1
|
||||
'/fake/objInQuery':
|
||||
get:
|
||||
tags:
|
||||
- fake
|
||||
summary: user list
|
||||
operationId: objectInQuery
|
||||
parameters:
|
||||
- name: mapBean
|
||||
in: query
|
||||
required: false
|
||||
description: mapBean
|
||||
style: deepObject
|
||||
explode: true
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
keyword:
|
||||
title: keyword
|
||||
type: string
|
||||
responses:
|
||||
'200':
|
||||
description: ok
|
||||
'/fake/refObjInQuery':
|
||||
get:
|
||||
tags:
|
||||
- fake
|
||||
summary: user list
|
||||
operationId: refObjectInQuery
|
||||
parameters:
|
||||
- name: mapBean
|
||||
in: query
|
||||
required: false
|
||||
description: mapBean
|
||||
style: deepObject
|
||||
explode: true
|
||||
schema:
|
||||
$ref: '#/components/schemas/Foo'
|
||||
responses:
|
||||
'200':
|
||||
description: ok
|
||||
servers:
|
||||
- url: 'http://{server}.swagger.io:{port}/v2'
|
||||
description: petstore server
|
||||
|
@ -79,6 +79,7 @@ docs/IntegerMin15.md
|
||||
docs/IsoscelesTriangle.md
|
||||
docs/IsoscelesTriangleAllOf.md
|
||||
docs/Mammal.md
|
||||
docs/MapBean.md
|
||||
docs/MapTest.md
|
||||
docs/MixedPropertiesAndAdditionalPropertiesClass.md
|
||||
docs/Model200Response.md
|
||||
@ -216,6 +217,7 @@ petstore_api/model/integer_min15.py
|
||||
petstore_api/model/isosceles_triangle.py
|
||||
petstore_api/model/isosceles_triangle_all_of.py
|
||||
petstore_api/model/mammal.py
|
||||
petstore_api/model/map_bean.py
|
||||
petstore_api/model/map_test.py
|
||||
petstore_api/model/mixed_properties_and_additional_properties_class.py
|
||||
petstore_api/model/model200_response.py
|
||||
|
@ -102,9 +102,11 @@ Class | Method | HTTP request | Description
|
||||
*FakeApi* | [**json_form_data**](docs/FakeApi.md#json_form_data) | **GET** /fake/jsonFormData | test json serialization of form data
|
||||
*FakeApi* | [**mammal**](docs/FakeApi.md#mammal) | **POST** /fake/refs/mammal |
|
||||
*FakeApi* | [**number_with_validations**](docs/FakeApi.md#number_with_validations) | **POST** /fake/refs/number |
|
||||
*FakeApi* | [**object_in_query**](docs/FakeApi.md#object_in_query) | **GET** /fake/objInQuery | user list
|
||||
*FakeApi* | [**object_model_with_ref_props**](docs/FakeApi.md#object_model_with_ref_props) | **POST** /fake/refs/object_model_with_ref_props |
|
||||
*FakeApi* | [**parameter_collisions**](docs/FakeApi.md#parameter_collisions) | **POST** /fake/parameterCollisions/{1}/{aB}/{Ab}/{self}/{A-B}/ | parameter collision case
|
||||
*FakeApi* | [**query_parameter_collection_format**](docs/FakeApi.md#query_parameter_collection_format) | **PUT** /fake/test-query-paramters |
|
||||
*FakeApi* | [**ref_object_in_query**](docs/FakeApi.md#ref_object_in_query) | **GET** /fake/refObjInQuery | user list
|
||||
*FakeApi* | [**string**](docs/FakeApi.md#string) | **POST** /fake/refs/string |
|
||||
*FakeApi* | [**string_enum**](docs/FakeApi.md#string_enum) | **POST** /fake/refs/enum |
|
||||
*FakeApi* | [**upload_download_file**](docs/FakeApi.md#upload_download_file) | **POST** /fake/uploadDownloadFile | uploads a file and downloads a file using application/octet-stream
|
||||
@ -208,6 +210,7 @@ Class | Method | HTTP request | Description
|
||||
- [IsoscelesTriangle](docs/IsoscelesTriangle.md)
|
||||
- [IsoscelesTriangleAllOf](docs/IsoscelesTriangleAllOf.md)
|
||||
- [Mammal](docs/Mammal.md)
|
||||
- [MapBean](docs/MapBean.md)
|
||||
- [MapTest](docs/MapTest.md)
|
||||
- [MixedPropertiesAndAdditionalPropertiesClass](docs/MixedPropertiesAndAdditionalPropertiesClass.md)
|
||||
- [Model200Response](docs/Model200Response.md)
|
||||
|
@ -22,9 +22,11 @@ Method | HTTP request | Description
|
||||
[**json_form_data**](FakeApi.md#json_form_data) | **GET** /fake/jsonFormData | test json serialization of form data
|
||||
[**mammal**](FakeApi.md#mammal) | **POST** /fake/refs/mammal |
|
||||
[**number_with_validations**](FakeApi.md#number_with_validations) | **POST** /fake/refs/number |
|
||||
[**object_in_query**](FakeApi.md#object_in_query) | **GET** /fake/objInQuery | user list
|
||||
[**object_model_with_ref_props**](FakeApi.md#object_model_with_ref_props) | **POST** /fake/refs/object_model_with_ref_props |
|
||||
[**parameter_collisions**](FakeApi.md#parameter_collisions) | **POST** /fake/parameterCollisions/{1}/{aB}/{Ab}/{self}/{A-B}/ | parameter collision case
|
||||
[**query_parameter_collection_format**](FakeApi.md#query_parameter_collection_format) | **PUT** /fake/test-query-paramters |
|
||||
[**ref_object_in_query**](FakeApi.md#ref_object_in_query) | **GET** /fake/refObjInQuery | user list
|
||||
[**string**](FakeApi.md#string) | **POST** /fake/refs/string |
|
||||
[**string_enum**](FakeApi.md#string_enum) | **POST** /fake/refs/enum |
|
||||
[**upload_download_file**](FakeApi.md#upload_download_file) | **POST** /fake/uploadDownloadFile | uploads a file and downloads a file using application/octet-stream
|
||||
@ -1786,6 +1788,89 @@ No authorization required
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||
|
||||
# **object_in_query**
|
||||
> object_in_query()
|
||||
|
||||
user list
|
||||
|
||||
### Example
|
||||
|
||||
```python
|
||||
import petstore_api
|
||||
from petstore_api.api import fake_api
|
||||
from petstore_api.model.map_bean import MapBean
|
||||
from pprint import pprint
|
||||
# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2
|
||||
# See configuration.py for a list of all supported configuration parameters.
|
||||
configuration = petstore_api.Configuration(
|
||||
host = "http://petstore.swagger.io:80/v2"
|
||||
)
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = fake_api.FakeApi(api_client)
|
||||
|
||||
# example passing only optional values
|
||||
query_params = {
|
||||
'mapBean': dict(
|
||||
keyword="keyword_example",
|
||||
),
|
||||
}
|
||||
try:
|
||||
# user list
|
||||
api_response = api_instance.object_in_query(
|
||||
query_params=query_params,
|
||||
)
|
||||
except petstore_api.ApiException as e:
|
||||
print("Exception when calling FakeApi->object_in_query: %s\n" % e)
|
||||
```
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
query_params | RequestQueryParams | |
|
||||
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
|
||||
timeout | typing.Optional[typing.Union[int, typing.Tuple]] | default is None | the timeout used by the rest client
|
||||
skip_deserialization | bool | default is False | when True, headers and body will be unset and an instance of api_client.ApiResponseWithoutDeserialization will be returned
|
||||
|
||||
### query_params
|
||||
#### RequestQueryParams
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
mapBean | MapBeanSchema | | optional
|
||||
|
||||
|
||||
#### MapBeanSchema
|
||||
Type | Description | Notes
|
||||
------------- | ------------- | -------------
|
||||
[**{str: (bool, date, datetime, dict, float, int, list, str, none_type)}**](MapBean.md) | |
|
||||
|
||||
|
||||
### Return Types, Responses
|
||||
|
||||
Code | Class | Description
|
||||
------------- | ------------- | -------------
|
||||
n/a | api_client.ApiResponseWithoutDeserialization | When skip_deserialization is True this response is returned
|
||||
200 | ApiResponseFor200 | ok
|
||||
|
||||
#### ApiResponseFor200
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
response | urllib3.HTTPResponse | Raw response |
|
||||
body | Unset | body was not defined |
|
||||
headers | Unset | headers were not defined |
|
||||
|
||||
|
||||
void (empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||
|
||||
# **object_model_with_ref_props**
|
||||
> ObjectModelWithRefProps object_model_with_ref_props()
|
||||
|
||||
@ -2297,6 +2382,89 @@ body | Unset | body was not defined |
|
||||
headers | Unset | headers were not defined |
|
||||
|
||||
|
||||
void (empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||
|
||||
# **ref_object_in_query**
|
||||
> ref_object_in_query()
|
||||
|
||||
user list
|
||||
|
||||
### Example
|
||||
|
||||
```python
|
||||
import petstore_api
|
||||
from petstore_api.api import fake_api
|
||||
from petstore_api.model.foo import Foo
|
||||
from pprint import pprint
|
||||
# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2
|
||||
# See configuration.py for a list of all supported configuration parameters.
|
||||
configuration = petstore_api.Configuration(
|
||||
host = "http://petstore.swagger.io:80/v2"
|
||||
)
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = fake_api.FakeApi(api_client)
|
||||
|
||||
# example passing only optional values
|
||||
query_params = {
|
||||
'mapBean': Foo(
|
||||
bar="bar",
|
||||
),
|
||||
}
|
||||
try:
|
||||
# user list
|
||||
api_response = api_instance.ref_object_in_query(
|
||||
query_params=query_params,
|
||||
)
|
||||
except petstore_api.ApiException as e:
|
||||
print("Exception when calling FakeApi->ref_object_in_query: %s\n" % e)
|
||||
```
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
query_params | RequestQueryParams | |
|
||||
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
|
||||
timeout | typing.Optional[typing.Union[int, typing.Tuple]] | default is None | the timeout used by the rest client
|
||||
skip_deserialization | bool | default is False | when True, headers and body will be unset and an instance of api_client.ApiResponseWithoutDeserialization will be returned
|
||||
|
||||
### query_params
|
||||
#### RequestQueryParams
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
mapBean | MapBeanSchema | | optional
|
||||
|
||||
|
||||
#### MapBeanSchema
|
||||
Type | Description | Notes
|
||||
------------- | ------------- | -------------
|
||||
[**Foo**](Foo.md) | |
|
||||
|
||||
|
||||
### Return Types, Responses
|
||||
|
||||
Code | Class | Description
|
||||
------------- | ------------- | -------------
|
||||
n/a | api_client.ApiResponseWithoutDeserialization | When skip_deserialization is True this response is returned
|
||||
200 | ApiResponseFor200 | ok
|
||||
|
||||
#### ApiResponseFor200
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
response | urllib3.HTTPResponse | Raw response |
|
||||
body | Unset | body was not defined |
|
||||
headers | Unset | headers were not defined |
|
||||
|
||||
|
||||
void (empty response body)
|
||||
|
||||
### Authorization
|
||||
|
@ -0,0 +1,10 @@
|
||||
# MapBean
|
||||
|
||||
#### Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**keyword** | **str** | | [optional]
|
||||
**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
@ -28,9 +28,11 @@ from petstore_api.api.fake_api_endpoints.inline_composition import InlineComposi
|
||||
from petstore_api.api.fake_api_endpoints.json_form_data import JsonFormData
|
||||
from petstore_api.api.fake_api_endpoints.mammal import Mammal
|
||||
from petstore_api.api.fake_api_endpoints.number_with_validations import NumberWithValidations
|
||||
from petstore_api.api.fake_api_endpoints.object_in_query import ObjectInQuery
|
||||
from petstore_api.api.fake_api_endpoints.object_model_with_ref_props import ObjectModelWithRefProps
|
||||
from petstore_api.api.fake_api_endpoints.parameter_collisions import ParameterCollisions
|
||||
from petstore_api.api.fake_api_endpoints.query_parameter_collection_format import QueryParameterCollectionFormat
|
||||
from petstore_api.api.fake_api_endpoints.ref_object_in_query import RefObjectInQuery
|
||||
from petstore_api.api.fake_api_endpoints.string import String
|
||||
from petstore_api.api.fake_api_endpoints.string_enum import StringEnum
|
||||
from petstore_api.api.fake_api_endpoints.upload_download_file import UploadDownloadFile
|
||||
@ -57,9 +59,11 @@ class FakeApi(
|
||||
JsonFormData,
|
||||
Mammal,
|
||||
NumberWithValidations,
|
||||
ObjectInQuery,
|
||||
ObjectModelWithRefProps,
|
||||
ParameterCollisions,
|
||||
QueryParameterCollectionFormat,
|
||||
RefObjectInQuery,
|
||||
String,
|
||||
StringEnum,
|
||||
UploadDownloadFile,
|
||||
|
@ -0,0 +1,182 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
|
||||
|
||||
Generated by: https://openapi-generator.tech
|
||||
"""
|
||||
|
||||
from dataclasses import dataclass
|
||||
import re # noqa: F401
|
||||
import sys # noqa: F401
|
||||
import typing
|
||||
import urllib3
|
||||
|
||||
from petstore_api import api_client, exceptions
|
||||
import decimal # noqa: F401
|
||||
from datetime import date, datetime # noqa: F401
|
||||
from frozendict import frozendict # noqa: F401
|
||||
|
||||
from petstore_api.schemas import ( # noqa: F401
|
||||
AnyTypeSchema,
|
||||
ComposedSchema,
|
||||
DictSchema,
|
||||
ListSchema,
|
||||
StrSchema,
|
||||
IntSchema,
|
||||
Int32Schema,
|
||||
Int64Schema,
|
||||
Float32Schema,
|
||||
Float64Schema,
|
||||
NumberSchema,
|
||||
DateSchema,
|
||||
DateTimeSchema,
|
||||
DecimalSchema,
|
||||
BoolSchema,
|
||||
BinarySchema,
|
||||
NoneSchema,
|
||||
none_type,
|
||||
Configuration,
|
||||
Unset,
|
||||
unset,
|
||||
ComposedBase,
|
||||
ListBase,
|
||||
DictBase,
|
||||
NoneBase,
|
||||
StrBase,
|
||||
IntBase,
|
||||
Int32Base,
|
||||
Int64Base,
|
||||
Float32Base,
|
||||
Float64Base,
|
||||
NumberBase,
|
||||
DateBase,
|
||||
DateTimeBase,
|
||||
BoolBase,
|
||||
BinaryBase,
|
||||
Schema,
|
||||
_SchemaValidator,
|
||||
_SchemaTypeChecker,
|
||||
_SchemaEnumMaker
|
||||
)
|
||||
|
||||
from petstore_api.model.map_bean import MapBean
|
||||
|
||||
# query params
|
||||
|
||||
|
||||
class MapBeanSchema(
|
||||
DictSchema
|
||||
):
|
||||
keyword = StrSchema
|
||||
|
||||
|
||||
def __new__(
|
||||
cls,
|
||||
*args: typing.Union[dict, frozendict, ],
|
||||
keyword: typing.Union[keyword, Unset] = unset,
|
||||
_configuration: typing.Optional[Configuration] = None,
|
||||
**kwargs: typing.Type[Schema],
|
||||
) -> 'MapBeanSchema':
|
||||
return super().__new__(
|
||||
cls,
|
||||
*args,
|
||||
keyword=keyword,
|
||||
_configuration=_configuration,
|
||||
**kwargs,
|
||||
)
|
||||
RequestRequiredQueryParams = typing.TypedDict(
|
||||
'RequestRequiredQueryParams',
|
||||
{
|
||||
}
|
||||
)
|
||||
RequestOptionalQueryParams = typing.TypedDict(
|
||||
'RequestOptionalQueryParams',
|
||||
{
|
||||
'mapBean': MapBeanSchema,
|
||||
},
|
||||
total=False
|
||||
)
|
||||
|
||||
|
||||
class RequestQueryParams(RequestRequiredQueryParams, RequestOptionalQueryParams):
|
||||
pass
|
||||
|
||||
|
||||
request_query_map_bean = api_client.QueryParameter(
|
||||
name="mapBean",
|
||||
style=api_client.ParameterStyle.DEEP_OBJECT,
|
||||
schema=MapBeanSchema,
|
||||
explode=True,
|
||||
)
|
||||
_path = '/fake/objInQuery'
|
||||
_method = 'GET'
|
||||
|
||||
|
||||
@dataclass
|
||||
class ApiResponseFor200(api_client.ApiResponse):
|
||||
response: urllib3.HTTPResponse
|
||||
body: Unset = unset
|
||||
headers: Unset = unset
|
||||
|
||||
|
||||
_response_for_200 = api_client.OpenApiResponse(
|
||||
response_cls=ApiResponseFor200,
|
||||
)
|
||||
_status_code_to_response = {
|
||||
'200': _response_for_200,
|
||||
}
|
||||
|
||||
|
||||
class ObjectInQuery(api_client.Api):
|
||||
|
||||
def object_in_query(
|
||||
self: api_client.Api,
|
||||
query_params: RequestQueryParams = frozendict(),
|
||||
stream: bool = False,
|
||||
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
|
||||
skip_deserialization: bool = False,
|
||||
) -> typing.Union[
|
||||
ApiResponseFor200,
|
||||
api_client.ApiResponseWithoutDeserialization
|
||||
]:
|
||||
"""
|
||||
user list
|
||||
:param skip_deserialization: If true then api_response.response will be set but
|
||||
api_response.body and api_response.headers will not be deserialized into schema
|
||||
class instances
|
||||
"""
|
||||
self._verify_typed_dict_inputs(RequestQueryParams, query_params)
|
||||
|
||||
_query_params = []
|
||||
for parameter in (
|
||||
request_query_map_bean,
|
||||
):
|
||||
parameter_data = query_params.get(parameter.name, unset)
|
||||
if parameter_data is unset:
|
||||
continue
|
||||
serialized_data = parameter.serialize(parameter_data)
|
||||
_query_params.extend(serialized_data)
|
||||
# TODO add cookie handling
|
||||
|
||||
response = self.api_client.call_api(
|
||||
resource_path=_path,
|
||||
method=_method,
|
||||
query_params=tuple(_query_params),
|
||||
stream=stream,
|
||||
timeout=timeout,
|
||||
)
|
||||
|
||||
if skip_deserialization:
|
||||
api_response = api_client.ApiResponseWithoutDeserialization(response=response)
|
||||
else:
|
||||
response_for_status = _status_code_to_response.get(str(response.status))
|
||||
if response_for_status:
|
||||
api_response = response_for_status.deserialize(response, self.api_client.configuration)
|
||||
else:
|
||||
api_response = api_client.ApiResponseWithoutDeserialization(response=response)
|
||||
|
||||
if not 200 <= response.status <= 299:
|
||||
raise exceptions.ApiException(api_response=api_response)
|
||||
|
||||
return api_response
|
@ -0,0 +1,161 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
|
||||
|
||||
Generated by: https://openapi-generator.tech
|
||||
"""
|
||||
|
||||
from dataclasses import dataclass
|
||||
import re # noqa: F401
|
||||
import sys # noqa: F401
|
||||
import typing
|
||||
import urllib3
|
||||
|
||||
from petstore_api import api_client, exceptions
|
||||
import decimal # noqa: F401
|
||||
from datetime import date, datetime # noqa: F401
|
||||
from frozendict import frozendict # noqa: F401
|
||||
|
||||
from petstore_api.schemas import ( # noqa: F401
|
||||
AnyTypeSchema,
|
||||
ComposedSchema,
|
||||
DictSchema,
|
||||
ListSchema,
|
||||
StrSchema,
|
||||
IntSchema,
|
||||
Int32Schema,
|
||||
Int64Schema,
|
||||
Float32Schema,
|
||||
Float64Schema,
|
||||
NumberSchema,
|
||||
DateSchema,
|
||||
DateTimeSchema,
|
||||
DecimalSchema,
|
||||
BoolSchema,
|
||||
BinarySchema,
|
||||
NoneSchema,
|
||||
none_type,
|
||||
Configuration,
|
||||
Unset,
|
||||
unset,
|
||||
ComposedBase,
|
||||
ListBase,
|
||||
DictBase,
|
||||
NoneBase,
|
||||
StrBase,
|
||||
IntBase,
|
||||
Int32Base,
|
||||
Int64Base,
|
||||
Float32Base,
|
||||
Float64Base,
|
||||
NumberBase,
|
||||
DateBase,
|
||||
DateTimeBase,
|
||||
BoolBase,
|
||||
BinaryBase,
|
||||
Schema,
|
||||
_SchemaValidator,
|
||||
_SchemaTypeChecker,
|
||||
_SchemaEnumMaker
|
||||
)
|
||||
|
||||
from petstore_api.model.foo import Foo
|
||||
|
||||
# query params
|
||||
MapBeanSchema = Foo
|
||||
RequestRequiredQueryParams = typing.TypedDict(
|
||||
'RequestRequiredQueryParams',
|
||||
{
|
||||
}
|
||||
)
|
||||
RequestOptionalQueryParams = typing.TypedDict(
|
||||
'RequestOptionalQueryParams',
|
||||
{
|
||||
'mapBean': MapBeanSchema,
|
||||
},
|
||||
total=False
|
||||
)
|
||||
|
||||
|
||||
class RequestQueryParams(RequestRequiredQueryParams, RequestOptionalQueryParams):
|
||||
pass
|
||||
|
||||
|
||||
request_query_map_bean = api_client.QueryParameter(
|
||||
name="mapBean",
|
||||
style=api_client.ParameterStyle.DEEP_OBJECT,
|
||||
schema=MapBeanSchema,
|
||||
explode=True,
|
||||
)
|
||||
_path = '/fake/refObjInQuery'
|
||||
_method = 'GET'
|
||||
|
||||
|
||||
@dataclass
|
||||
class ApiResponseFor200(api_client.ApiResponse):
|
||||
response: urllib3.HTTPResponse
|
||||
body: Unset = unset
|
||||
headers: Unset = unset
|
||||
|
||||
|
||||
_response_for_200 = api_client.OpenApiResponse(
|
||||
response_cls=ApiResponseFor200,
|
||||
)
|
||||
_status_code_to_response = {
|
||||
'200': _response_for_200,
|
||||
}
|
||||
|
||||
|
||||
class RefObjectInQuery(api_client.Api):
|
||||
|
||||
def ref_object_in_query(
|
||||
self: api_client.Api,
|
||||
query_params: RequestQueryParams = frozendict(),
|
||||
stream: bool = False,
|
||||
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
|
||||
skip_deserialization: bool = False,
|
||||
) -> typing.Union[
|
||||
ApiResponseFor200,
|
||||
api_client.ApiResponseWithoutDeserialization
|
||||
]:
|
||||
"""
|
||||
user list
|
||||
:param skip_deserialization: If true then api_response.response will be set but
|
||||
api_response.body and api_response.headers will not be deserialized into schema
|
||||
class instances
|
||||
"""
|
||||
self._verify_typed_dict_inputs(RequestQueryParams, query_params)
|
||||
|
||||
_query_params = []
|
||||
for parameter in (
|
||||
request_query_map_bean,
|
||||
):
|
||||
parameter_data = query_params.get(parameter.name, unset)
|
||||
if parameter_data is unset:
|
||||
continue
|
||||
serialized_data = parameter.serialize(parameter_data)
|
||||
_query_params.extend(serialized_data)
|
||||
# TODO add cookie handling
|
||||
|
||||
response = self.api_client.call_api(
|
||||
resource_path=_path,
|
||||
method=_method,
|
||||
query_params=tuple(_query_params),
|
||||
stream=stream,
|
||||
timeout=timeout,
|
||||
)
|
||||
|
||||
if skip_deserialization:
|
||||
api_response = api_client.ApiResponseWithoutDeserialization(response=response)
|
||||
else:
|
||||
response_for_status = _status_code_to_response.get(str(response.status))
|
||||
if response_for_status:
|
||||
api_response = response_for_status.deserialize(response, self.api_client.configuration)
|
||||
else:
|
||||
api_response = api_client.ApiResponseWithoutDeserialization(response=response)
|
||||
|
||||
if not 200 <= response.status <= 299:
|
||||
raise exceptions.ApiException(api_response=api_response)
|
||||
|
||||
return api_response
|
@ -0,0 +1,90 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAPI Petstore
|
||||
|
||||
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Generated by: https://openapi-generator.tech
|
||||
"""
|
||||
|
||||
import re # noqa: F401
|
||||
import sys # noqa: F401
|
||||
import typing # noqa: F401
|
||||
|
||||
from frozendict import frozendict # noqa: F401
|
||||
|
||||
import decimal # noqa: F401
|
||||
from datetime import date, datetime # noqa: F401
|
||||
from frozendict import frozendict # noqa: F401
|
||||
|
||||
from petstore_api.schemas import ( # noqa: F401
|
||||
AnyTypeSchema,
|
||||
ComposedSchema,
|
||||
DictSchema,
|
||||
ListSchema,
|
||||
StrSchema,
|
||||
IntSchema,
|
||||
Int32Schema,
|
||||
Int64Schema,
|
||||
Float32Schema,
|
||||
Float64Schema,
|
||||
NumberSchema,
|
||||
DateSchema,
|
||||
DateTimeSchema,
|
||||
DecimalSchema,
|
||||
BoolSchema,
|
||||
BinarySchema,
|
||||
NoneSchema,
|
||||
none_type,
|
||||
Configuration,
|
||||
Unset,
|
||||
unset,
|
||||
ComposedBase,
|
||||
ListBase,
|
||||
DictBase,
|
||||
NoneBase,
|
||||
StrBase,
|
||||
IntBase,
|
||||
Int32Base,
|
||||
Int64Base,
|
||||
Float32Base,
|
||||
Float64Base,
|
||||
NumberBase,
|
||||
DateBase,
|
||||
DateTimeBase,
|
||||
BoolBase,
|
||||
BinaryBase,
|
||||
Schema,
|
||||
_SchemaValidator,
|
||||
_SchemaTypeChecker,
|
||||
_SchemaEnumMaker
|
||||
)
|
||||
|
||||
|
||||
class MapBean(
|
||||
DictSchema
|
||||
):
|
||||
"""NOTE: This class is auto generated by OpenAPI Generator.
|
||||
Ref: https://openapi-generator.tech
|
||||
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
keyword = StrSchema
|
||||
|
||||
|
||||
def __new__(
|
||||
cls,
|
||||
*args: typing.Union[dict, frozendict, ],
|
||||
keyword: typing.Union[keyword, Unset] = unset,
|
||||
_configuration: typing.Optional[Configuration] = None,
|
||||
**kwargs: typing.Type[Schema],
|
||||
) -> 'MapBean':
|
||||
return super().__new__(
|
||||
cls,
|
||||
*args,
|
||||
keyword=keyword,
|
||||
_configuration=_configuration,
|
||||
**kwargs,
|
||||
)
|
@ -84,6 +84,7 @@ from petstore_api.model.integer_min15 import IntegerMin15
|
||||
from petstore_api.model.isosceles_triangle import IsoscelesTriangle
|
||||
from petstore_api.model.isosceles_triangle_all_of import IsoscelesTriangleAllOf
|
||||
from petstore_api.model.mammal import Mammal
|
||||
from petstore_api.model.map_bean import MapBean
|
||||
from petstore_api.model.map_test import MapTest
|
||||
from petstore_api.model.mixed_properties_and_additional_properties_class import MixedPropertiesAndAdditionalPropertiesClass
|
||||
from petstore_api.model.model200_response import Model200Response
|
||||
|
@ -0,0 +1,35 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAPI Petstore
|
||||
|
||||
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Generated by: https://openapi-generator.tech
|
||||
"""
|
||||
|
||||
import unittest
|
||||
|
||||
import petstore_api
|
||||
from petstore_api.model.map_bean import MapBean
|
||||
|
||||
|
||||
class TestMapBean(unittest.TestCase):
|
||||
"""MapBean unit test stubs"""
|
||||
|
||||
def setUp(self):
|
||||
pass
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
|
||||
def test_MapBean(self):
|
||||
"""Test MapBean"""
|
||||
# FIXME: construct object with mandatory attributes with example values
|
||||
# model = MapBean() # noqa: E501
|
||||
pass
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
Loading…
x
Reference in New Issue
Block a user