diff --git a/modules/openapi-generator/src/test/resources/3_0/python/petstore-with-fake-endpoints-models-for-testing.yaml b/modules/openapi-generator/src/test/resources/3_0/python/petstore-with-fake-endpoints-models-for-testing.yaml index 427b2b70d7c4..6663907fa17d 100644 --- a/modules/openapi-generator/src/test/resources/3_0/python/petstore-with-fake-endpoints-models-for-testing.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/python/petstore-with-fake-endpoints-models-for-testing.yaml @@ -1588,6 +1588,28 @@ paths: type: integer required: - file + /test/json-header-content: + post: + tags: + - fake + operationId: test-json-header-content + parameters: + - name: X-Json-Arg + in: header + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/HeaderArg' + - name: X-Plain-Arg + in: header + required: false + schema: + type: string + responses: + '204': + description: No content + /import_test/return_datetime: get: tags: @@ -2946,3 +2968,10 @@ components: type: string format: uuid pattern: "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$" + HeaderArg: + type: object + properties: + path: + type: string + recursive: + type: boolean diff --git a/samples/client/petstore/java/rest-assured-jackson3/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java b/samples/client/petstore/java/rest-assured-jackson3/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java new file mode 100644 index 000000000000..760b0cfb28d2 --- /dev/null +++ b/samples/client/petstore/java/rest-assured-jackson3/src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java @@ -0,0 +1,100 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.io.IOException; +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZoneId; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.time.temporal.Temporal; +import java.time.temporal.TemporalAccessor; +import java.util.function.BiFunction; +import java.util.function.Function; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeFeature; +import com.fasterxml.jackson.datatype.jsr310.deser.InstantDeserializer; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.26.0-SNAPSHOT") +public class RFC3339InstantDeserializer extends InstantDeserializer { + private static final long serialVersionUID = 1L; + private final static boolean DEFAULT_NORMALIZE_ZONE_ID = JavaTimeFeature.NORMALIZE_DESERIALIZED_ZONE_ID.enabledByDefault(); + private final static boolean DEFAULT_ALWAYS_ALLOW_STRINGIFIED_DATE_TIMESTAMPS + = JavaTimeFeature.ALWAYS_ALLOW_STRINGIFIED_DATE_TIMESTAMPS.enabledByDefault(); + + public static final RFC3339InstantDeserializer INSTANT = new RFC3339InstantDeserializer<>( + Instant.class, DateTimeFormatter.ISO_INSTANT, + Instant::from, + a -> Instant.ofEpochMilli( a.value ), + a -> Instant.ofEpochSecond( a.integer, a.fraction ), + null, + true, // yes, replace zero offset with Z + DEFAULT_NORMALIZE_ZONE_ID, + DEFAULT_ALWAYS_ALLOW_STRINGIFIED_DATE_TIMESTAMPS + ); + + public static final RFC3339InstantDeserializer OFFSET_DATE_TIME = new RFC3339InstantDeserializer<>( + OffsetDateTime.class, DateTimeFormatter.ISO_OFFSET_DATE_TIME, + OffsetDateTime::from, + a -> OffsetDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> OffsetDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + (d, z) -> ( d.isEqual( OffsetDateTime.MIN ) || d.isEqual( OffsetDateTime.MAX ) ? + d : + d.withOffsetSameInstant( z.getRules().getOffset( d.toLocalDateTime() ) ) ), + true, // yes, replace zero offset with Z + DEFAULT_NORMALIZE_ZONE_ID, + DEFAULT_ALWAYS_ALLOW_STRINGIFIED_DATE_TIMESTAMPS + ); + + public static final RFC3339InstantDeserializer ZONED_DATE_TIME = new RFC3339InstantDeserializer<>( + ZonedDateTime.class, DateTimeFormatter.ISO_ZONED_DATE_TIME, + ZonedDateTime::from, + a -> ZonedDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ), + a -> ZonedDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ), + ZonedDateTime::withZoneSameInstant, + false, // keep zero offset and Z separate since zones explicitly supported + DEFAULT_NORMALIZE_ZONE_ID, + DEFAULT_ALWAYS_ALLOW_STRINGIFIED_DATE_TIMESTAMPS + ); + + protected RFC3339InstantDeserializer( + Class supportedType, + DateTimeFormatter formatter, + Function parsedToValue, + Function fromMilliseconds, + Function fromNanoseconds, + BiFunction adjust, + boolean replaceZeroOffsetAsZ, + boolean normalizeZoneId, + boolean readNumericStringsAsTimestamp) { + super( + supportedType, + formatter, + parsedToValue, + fromMilliseconds, + fromNanoseconds, + adjust, + replaceZeroOffsetAsZ, + normalizeZoneId, + readNumericStringsAsTimestamp + ); + } + + @Override + protected T _fromString(JsonParser p, DeserializationContext ctxt, String string0) throws IOException { + return super._fromString(p, ctxt, string0.replace( ' ', 'T' )); + } +} \ No newline at end of file diff --git a/samples/client/petstore/java/rest-assured-jackson3/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java b/samples/client/petstore/java/rest-assured-jackson3/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java new file mode 100644 index 000000000000..d3a0e3052a2b --- /dev/null +++ b/samples/client/petstore/java/rest-assured-jackson3/src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java @@ -0,0 +1,39 @@ +/* + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.openapitools.client; + +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZonedDateTime; + +import com.fasterxml.jackson.databind.module.SimpleModule; +import com.fasterxml.jackson.databind.Module.SetupContext; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.26.0-SNAPSHOT") +public class RFC3339JavaTimeModule extends SimpleModule { + private static final long serialVersionUID = 1L; + + public RFC3339JavaTimeModule() { + super("RFC3339JavaTimeModule"); + } + + @Override + public void setupModule(SetupContext context) { + super.setupModule(context); + + addDeserializer(Instant.class, RFC3339InstantDeserializer.INSTANT); + addDeserializer(OffsetDateTime.class, RFC3339InstantDeserializer.OFFSET_DATE_TIME); + addDeserializer(ZonedDateTime.class, RFC3339InstantDeserializer.ZONED_DATE_TIME); + } + +} diff --git a/samples/openapi3/client/petstore/python-aiohttp/.openapi-generator/FILES b/samples/openapi3/client/petstore/python-aiohttp/.openapi-generator/FILES index 1eb565d74f11..d808742215cb 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/.openapi-generator/FILES +++ b/samples/openapi3/client/petstore/python-aiohttp/.openapi-generator/FILES @@ -57,6 +57,7 @@ docs/Foo.md docs/FooGetDefaultResponse.md docs/FormatTest.md docs/HasOnlyReadOnly.md +docs/HeaderArg.md docs/HealthCheckResult.md docs/HuntingDog.md docs/ImportTestDatetimeApi.md @@ -191,6 +192,7 @@ petstore_api/models/foo.py petstore_api/models/foo_get_default_response.py petstore_api/models/format_test.py petstore_api/models/has_only_read_only.py +petstore_api/models/header_arg.py petstore_api/models/health_check_result.py petstore_api/models/hunting_dog.py petstore_api/models/info.py diff --git a/samples/openapi3/client/petstore/python-aiohttp/README.md b/samples/openapi3/client/petstore/python-aiohttp/README.md index 17a693587c53..1fa59cd7e51b 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/README.md +++ b/samples/openapi3/client/petstore/python-aiohttp/README.md @@ -147,6 +147,7 @@ Class | Method | HTTP request | Description *FakeApi* | [**test_inline_additional_properties**](docs/FakeApi.md#test_inline_additional_properties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties *FakeApi* | [**test_inline_freeform_additional_properties**](docs/FakeApi.md#test_inline_freeform_additional_properties) | **POST** /fake/inline-freeform-additionalProperties | test inline free-form additionalProperties *FakeApi* | [**test_json_form_data**](docs/FakeApi.md#test_json_form_data) | **GET** /fake/jsonFormData | test json serialization of form data +*FakeApi* | [**test_json_header_content**](docs/FakeApi.md#test_json_header_content) | **POST** /test/json-header-content | *FakeApi* | [**test_object_for_multipart_requests**](docs/FakeApi.md#test_object_for_multipart_requests) | **POST** /fake/object_for_multipart_requests | *FakeApi* | [**test_query_parameter_collection_format**](docs/FakeApi.md#test_query_parameter_collection_format) | **PUT** /fake/test-query-parameters | *FakeApi* | [**test_string_map_reference**](docs/FakeApi.md#test_string_map_reference) | **POST** /fake/stringMap-reference | test referenced string map @@ -228,6 +229,7 @@ Class | Method | HTTP request | Description - [FooGetDefaultResponse](docs/FooGetDefaultResponse.md) - [FormatTest](docs/FormatTest.md) - [HasOnlyReadOnly](docs/HasOnlyReadOnly.md) + - [HeaderArg](docs/HeaderArg.md) - [HealthCheckResult](docs/HealthCheckResult.md) - [HuntingDog](docs/HuntingDog.md) - [Info](docs/Info.md) diff --git a/samples/openapi3/client/petstore/python-aiohttp/docs/FakeApi.md b/samples/openapi3/client/petstore/python-aiohttp/docs/FakeApi.md index 2c434569b655..7777f511be90 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/FakeApi.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/FakeApi.md @@ -37,6 +37,7 @@ Method | HTTP request | Description [**test_inline_additional_properties**](FakeApi.md#test_inline_additional_properties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties [**test_inline_freeform_additional_properties**](FakeApi.md#test_inline_freeform_additional_properties) | **POST** /fake/inline-freeform-additionalProperties | test inline free-form additionalProperties [**test_json_form_data**](FakeApi.md#test_json_form_data) | **GET** /fake/jsonFormData | test json serialization of form data +[**test_json_header_content**](FakeApi.md#test_json_header_content) | **POST** /test/json-header-content | [**test_object_for_multipart_requests**](FakeApi.md#test_object_for_multipart_requests) | **POST** /fake/object_for_multipart_requests | [**test_query_parameter_collection_format**](FakeApi.md#test_query_parameter_collection_format) | **PUT** /fake/test-query-parameters | [**test_string_map_reference**](FakeApi.md#test_string_map_reference) | **POST** /fake/stringMap-reference | test referenced string map @@ -2265,6 +2266,69 @@ 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) +# **test_json_header_content** +> test_json_header_content(x_json_arg, x_plain_arg=x_plain_arg) + +### Example + + +```python +import petstore_api +from petstore_api.models.header_arg import HeaderArg +from petstore_api.rest import ApiException +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 +async with petstore_api.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = petstore_api.FakeApi(api_client) + x_json_arg = petstore_api.HeaderArg() # HeaderArg | + x_plain_arg = 'x_plain_arg_example' # str | (optional) + + try: + await api_instance.test_json_header_content(x_json_arg, x_plain_arg=x_plain_arg) + except Exception as e: + print("Exception when calling FakeApi->test_json_header_content: %s\n" % e) +``` + + + +### Parameters + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **x_json_arg** | [**HeaderArg**](.md)| | + **x_plain_arg** | **str**| | [optional] + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + +### HTTP response details + +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**204** | No content | - | + +[[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) + # **test_object_for_multipart_requests** > test_object_for_multipart_requests(marker) diff --git a/samples/openapi3/client/petstore/python-aiohttp/docs/HeaderArg.md b/samples/openapi3/client/petstore/python-aiohttp/docs/HeaderArg.md new file mode 100644 index 000000000000..e38f4d753d6d --- /dev/null +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/HeaderArg.md @@ -0,0 +1,30 @@ +# HeaderArg + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**path** | **str** | | [optional] +**recursive** | **bool** | | [optional] + +## Example + +```python +from petstore_api.models.header_arg import HeaderArg + +# TODO update the JSON string below +json = "{}" +# create an instance of HeaderArg from a JSON string +header_arg_instance = HeaderArg.from_json(json) +# print the JSON string representation of the object +print(HeaderArg.to_json()) + +# convert the object into a dict +header_arg_dict = header_arg_instance.to_dict() +# create an instance of HeaderArg from a dict +header_arg_from_dict = HeaderArg.from_dict(header_arg_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/__init__.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/__init__.py index c7f461775f59..55be0097b9d0 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/__init__.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/__init__.py @@ -86,6 +86,7 @@ "FooGetDefaultResponse", "FormatTest", "HasOnlyReadOnly", + "HeaderArg", "HealthCheckResult", "HuntingDog", "Info", @@ -225,6 +226,7 @@ from petstore_api.models.foo_get_default_response import FooGetDefaultResponse as FooGetDefaultResponse from petstore_api.models.format_test import FormatTest as FormatTest from petstore_api.models.has_only_read_only import HasOnlyReadOnly as HasOnlyReadOnly +from petstore_api.models.header_arg import HeaderArg as HeaderArg from petstore_api.models.health_check_result import HealthCheckResult as HealthCheckResult from petstore_api.models.hunting_dog import HuntingDog as HuntingDog from petstore_api.models.info import Info as Info diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/fake_api.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/fake_api.py index f5034ea9753a..37debd4fa721 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/fake_api.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/fake_api.py @@ -10,6 +10,7 @@ """ # noqa: E501 +import json import warnings from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt from typing import Any, Dict, List, Optional, Tuple, Union @@ -23,6 +24,7 @@ from petstore_api.models.client import Client from petstore_api.models.enum_class import EnumClass from petstore_api.models.file_schema_test_class import FileSchemaTestClass +from petstore_api.models.header_arg import HeaderArg from petstore_api.models.health_check_result import HealthCheckResult from petstore_api.models.model_api_response import ModelApiResponse from petstore_api.models.outer_composite import OuterComposite @@ -8944,6 +8946,273 @@ def _test_json_form_data_serialize( + @validate_call + async def test_json_header_content( + self, + x_json_arg: HeaderArg, + x_plain_arg: Optional[StrictStr] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> None: + """test_json_header_content + + + :param x_json_arg: (required) + :type x_json_arg: HeaderArg + :param x_plain_arg: + :type x_plain_arg: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._test_json_header_content_serialize( + x_json_arg=x_json_arg, + x_plain_arg=x_plain_arg, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '204': None, + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + async def test_json_header_content_with_http_info( + self, + x_json_arg: HeaderArg, + x_plain_arg: Optional[StrictStr] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[None]: + """test_json_header_content + + + :param x_json_arg: (required) + :type x_json_arg: HeaderArg + :param x_plain_arg: + :type x_plain_arg: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._test_json_header_content_serialize( + x_json_arg=x_json_arg, + x_plain_arg=x_plain_arg, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '204': None, + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + async def test_json_header_content_without_preload_content( + self, + x_json_arg: HeaderArg, + x_plain_arg: Optional[StrictStr] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """test_json_header_content + + + :param x_json_arg: (required) + :type x_json_arg: HeaderArg + :param x_plain_arg: + :type x_plain_arg: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._test_json_header_content_serialize( + x_json_arg=x_json_arg, + x_plain_arg=x_plain_arg, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '204': None, + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _test_json_header_content_serialize( + self, + x_json_arg, + x_plain_arg, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + if x_json_arg is not None: + _header_params['X-Json-Arg'] = json.dumps( + self.api_client.sanitize_for_serialization(x_json_arg) + ) + if x_plain_arg is not None: + _header_params['X-Plain-Arg'] = x_plain_arg + # process the form parameters + # process the body parameter + + + + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='POST', + resource_path='/test/json-header-content', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + @validate_call async def test_object_for_multipart_requests( self, diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/__init__.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/__init__.py index 308e6dfc3ebb..488a82150d32 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/__init__.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/__init__.py @@ -63,6 +63,7 @@ from petstore_api.models.foo_get_default_response import FooGetDefaultResponse from petstore_api.models.format_test import FormatTest from petstore_api.models.has_only_read_only import HasOnlyReadOnly +from petstore_api.models.header_arg import HeaderArg from petstore_api.models.health_check_result import HealthCheckResult from petstore_api.models.hunting_dog import HuntingDog from petstore_api.models.info import Info diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/header_arg.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/header_arg.py new file mode 100644 index 000000000000..bd8d1b0090ed --- /dev/null +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/header_arg.py @@ -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: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictBool, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from typing import Optional, Set +from typing_extensions import Self +from pydantic_core import to_jsonable_python + +class HeaderArg(BaseModel): + """ + HeaderArg + """ # noqa: E501 + path: Optional[StrictStr] = None + recursive: Optional[StrictBool] = None + __properties: ClassVar[List[str]] = ["path", "recursive"] + + model_config = ConfigDict( + validate_by_name=True, + validate_by_alias=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(to_jsonable_python(self.to_dict())) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of HeaderArg from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of HeaderArg from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "path": obj.get("path"), + "recursive": obj.get("recursive") + }) + return _obj + + diff --git a/samples/openapi3/client/petstore/python-aiohttp/test/test_header_arg.py b/samples/openapi3/client/petstore/python-aiohttp/test/test_header_arg.py new file mode 100644 index 000000000000..f4577965fcce --- /dev/null +++ b/samples/openapi3/client/petstore/python-aiohttp/test/test_header_arg.py @@ -0,0 +1,52 @@ +# 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: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from petstore_api.models.header_arg import HeaderArg + +class TestHeaderArg(unittest.TestCase): + """HeaderArg unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> HeaderArg: + """Test HeaderArg + include_optional is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `HeaderArg` + """ + model = HeaderArg() + if include_optional: + return HeaderArg( + path = '', + recursive = True + ) + else: + return HeaderArg( + ) + """ + + def testHeaderArg(self): + """Test HeaderArg""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-httpx-sync/.openapi-generator/FILES b/samples/openapi3/client/petstore/python-httpx-sync/.openapi-generator/FILES index 463307488f33..4ced57aeb32e 100644 --- a/samples/openapi3/client/petstore/python-httpx-sync/.openapi-generator/FILES +++ b/samples/openapi3/client/petstore/python-httpx-sync/.openapi-generator/FILES @@ -57,6 +57,7 @@ docs/Foo.md docs/FooGetDefaultResponse.md docs/FormatTest.md docs/HasOnlyReadOnly.md +docs/HeaderArg.md docs/HealthCheckResult.md docs/HuntingDog.md docs/ImportTestDatetimeApi.md @@ -191,6 +192,7 @@ petstore_api/models/foo.py petstore_api/models/foo_get_default_response.py petstore_api/models/format_test.py petstore_api/models/has_only_read_only.py +petstore_api/models/header_arg.py petstore_api/models/health_check_result.py petstore_api/models/hunting_dog.py petstore_api/models/info.py diff --git a/samples/openapi3/client/petstore/python-httpx-sync/README.md b/samples/openapi3/client/petstore/python-httpx-sync/README.md index 2b24af59b591..5ac850a385de 100644 --- a/samples/openapi3/client/petstore/python-httpx-sync/README.md +++ b/samples/openapi3/client/petstore/python-httpx-sync/README.md @@ -125,6 +125,7 @@ Class | Method | HTTP request | Description *FakeApi* | [**test_inline_additional_properties**](docs/FakeApi.md#test_inline_additional_properties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties *FakeApi* | [**test_inline_freeform_additional_properties**](docs/FakeApi.md#test_inline_freeform_additional_properties) | **POST** /fake/inline-freeform-additionalProperties | test inline free-form additionalProperties *FakeApi* | [**test_json_form_data**](docs/FakeApi.md#test_json_form_data) | **GET** /fake/jsonFormData | test json serialization of form data +*FakeApi* | [**test_json_header_content**](docs/FakeApi.md#test_json_header_content) | **POST** /test/json-header-content | *FakeApi* | [**test_object_for_multipart_requests**](docs/FakeApi.md#test_object_for_multipart_requests) | **POST** /fake/object_for_multipart_requests | *FakeApi* | [**test_query_parameter_collection_format**](docs/FakeApi.md#test_query_parameter_collection_format) | **PUT** /fake/test-query-parameters | *FakeApi* | [**test_string_map_reference**](docs/FakeApi.md#test_string_map_reference) | **POST** /fake/stringMap-reference | test referenced string map @@ -206,6 +207,7 @@ Class | Method | HTTP request | Description - [FooGetDefaultResponse](docs/FooGetDefaultResponse.md) - [FormatTest](docs/FormatTest.md) - [HasOnlyReadOnly](docs/HasOnlyReadOnly.md) + - [HeaderArg](docs/HeaderArg.md) - [HealthCheckResult](docs/HealthCheckResult.md) - [HuntingDog](docs/HuntingDog.md) - [Info](docs/Info.md) diff --git a/samples/openapi3/client/petstore/python-httpx-sync/docs/FakeApi.md b/samples/openapi3/client/petstore/python-httpx-sync/docs/FakeApi.md index 4ef59dc7aa36..7e0bcc172701 100644 --- a/samples/openapi3/client/petstore/python-httpx-sync/docs/FakeApi.md +++ b/samples/openapi3/client/petstore/python-httpx-sync/docs/FakeApi.md @@ -37,6 +37,7 @@ Method | HTTP request | Description [**test_inline_additional_properties**](FakeApi.md#test_inline_additional_properties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties [**test_inline_freeform_additional_properties**](FakeApi.md#test_inline_freeform_additional_properties) | **POST** /fake/inline-freeform-additionalProperties | test inline free-form additionalProperties [**test_json_form_data**](FakeApi.md#test_json_form_data) | **GET** /fake/jsonFormData | test json serialization of form data +[**test_json_header_content**](FakeApi.md#test_json_header_content) | **POST** /test/json-header-content | [**test_object_for_multipart_requests**](FakeApi.md#test_object_for_multipart_requests) | **POST** /fake/object_for_multipart_requests | [**test_query_parameter_collection_format**](FakeApi.md#test_query_parameter_collection_format) | **PUT** /fake/test-query-parameters | [**test_string_map_reference**](FakeApi.md#test_string_map_reference) | **POST** /fake/stringMap-reference | test referenced string map @@ -2331,6 +2332,71 @@ 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) +# **test_json_header_content** +> test_json_header_content(x_json_arg, x_plain_arg=x_plain_arg) + +**Synchronous variant:** `test_json_header_content_sync(...)` — same parameters and return type, but blocks until completion instead of requiring `await`. + +### Example + + +```python +import petstore_api +from petstore_api.models.header_arg import HeaderArg +from petstore_api.rest import ApiException +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 +async with petstore_api.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = petstore_api.FakeApi(api_client) + x_json_arg = petstore_api.HeaderArg() # HeaderArg | + x_plain_arg = 'x_plain_arg_example' # str | (optional) + + try: + await api_instance.test_json_header_content(x_json_arg, x_plain_arg=x_plain_arg) + except Exception as e: + print("Exception when calling FakeApi->test_json_header_content: %s\n" % e) +``` + + + +### Parameters + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **x_json_arg** | [**HeaderArg**](.md)| | + **x_plain_arg** | **str**| | [optional] + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + +### HTTP response details + +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**204** | No content | - | + +[[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) + # **test_object_for_multipart_requests** > test_object_for_multipart_requests(marker) diff --git a/samples/openapi3/client/petstore/python-httpx-sync/docs/HeaderArg.md b/samples/openapi3/client/petstore/python-httpx-sync/docs/HeaderArg.md new file mode 100644 index 000000000000..e38f4d753d6d --- /dev/null +++ b/samples/openapi3/client/petstore/python-httpx-sync/docs/HeaderArg.md @@ -0,0 +1,30 @@ +# HeaderArg + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**path** | **str** | | [optional] +**recursive** | **bool** | | [optional] + +## Example + +```python +from petstore_api.models.header_arg import HeaderArg + +# TODO update the JSON string below +json = "{}" +# create an instance of HeaderArg from a JSON string +header_arg_instance = HeaderArg.from_json(json) +# print the JSON string representation of the object +print(HeaderArg.to_json()) + +# convert the object into a dict +header_arg_dict = header_arg_instance.to_dict() +# create an instance of HeaderArg from a dict +header_arg_from_dict = HeaderArg.from_dict(header_arg_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/__init__.py b/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/__init__.py index c7f461775f59..55be0097b9d0 100644 --- a/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/__init__.py +++ b/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/__init__.py @@ -86,6 +86,7 @@ "FooGetDefaultResponse", "FormatTest", "HasOnlyReadOnly", + "HeaderArg", "HealthCheckResult", "HuntingDog", "Info", @@ -225,6 +226,7 @@ from petstore_api.models.foo_get_default_response import FooGetDefaultResponse as FooGetDefaultResponse from petstore_api.models.format_test import FormatTest as FormatTest from petstore_api.models.has_only_read_only import HasOnlyReadOnly as HasOnlyReadOnly +from petstore_api.models.header_arg import HeaderArg as HeaderArg from petstore_api.models.health_check_result import HealthCheckResult as HealthCheckResult from petstore_api.models.hunting_dog import HuntingDog as HuntingDog from petstore_api.models.info import Info as Info diff --git a/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/api/fake_api.py b/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/api/fake_api.py index c22c0ab04bda..05c6c53603af 100644 --- a/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/api/fake_api.py +++ b/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/api/fake_api.py @@ -10,6 +10,7 @@ """ # noqa: E501 +import json import warnings from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt from typing import Any, Dict, List, Optional, Tuple, Union @@ -23,6 +24,7 @@ from petstore_api.models.client import Client from petstore_api.models.enum_class import EnumClass from petstore_api.models.file_schema_test_class import FileSchemaTestClass +from petstore_api.models.header_arg import HeaderArg from petstore_api.models.health_check_result import HealthCheckResult from petstore_api.models.model_api_response import ModelApiResponse from petstore_api.models.outer_composite import OuterComposite @@ -12364,6 +12366,381 @@ def _test_json_form_data_serialize( + @validate_call + async def test_json_header_content( + self, + x_json_arg: HeaderArg, + x_plain_arg: Optional[StrictStr] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> None: + """test_json_header_content + + + :param x_json_arg: (required) + :type x_json_arg: HeaderArg + :param x_plain_arg: + :type x_plain_arg: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._test_json_header_content_serialize( + x_json_arg=x_json_arg, + x_plain_arg=x_plain_arg, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '204': None, + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + async def test_json_header_content_with_http_info( + self, + x_json_arg: HeaderArg, + x_plain_arg: Optional[StrictStr] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[None]: + """test_json_header_content + + + :param x_json_arg: (required) + :type x_json_arg: HeaderArg + :param x_plain_arg: + :type x_plain_arg: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._test_json_header_content_serialize( + x_json_arg=x_json_arg, + x_plain_arg=x_plain_arg, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '204': None, + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + async def test_json_header_content_without_preload_content( + self, + x_json_arg: HeaderArg, + x_plain_arg: Optional[StrictStr] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """test_json_header_content + + + :param x_json_arg: (required) + :type x_json_arg: HeaderArg + :param x_plain_arg: + :type x_plain_arg: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._test_json_header_content_serialize( + x_json_arg=x_json_arg, + x_plain_arg=x_plain_arg, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '204': None, + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + @validate_call + def test_json_header_content_sync( + self, + x_json_arg: HeaderArg, + x_plain_arg: Optional[StrictStr] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> None: + """test_json_header_content (synchronous) + + Synchronous variant of :meth:`test_json_header_content`. It calls the asynchronous + method and blocks until it completes. + """ # noqa: E501 + return run_sync( + self.test_json_header_content( + x_json_arg=x_json_arg, + x_plain_arg=x_plain_arg, + _request_timeout=_request_timeout, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + ) + + + @validate_call + def test_json_header_content_sync_with_http_info( + self, + x_json_arg: HeaderArg, + x_plain_arg: Optional[StrictStr] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[None]: + """test_json_header_content (synchronous) + + Synchronous variant of :meth:`test_json_header_content_with_http_info`. It calls the + asynchronous method and blocks until it completes. + """ # noqa: E501 + return run_sync( + self.test_json_header_content_with_http_info( + x_json_arg=x_json_arg, + x_plain_arg=x_plain_arg, + _request_timeout=_request_timeout, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + ) + + + @validate_call + def test_json_header_content_sync_without_preload_content( + self, + x_json_arg: HeaderArg, + x_plain_arg: Optional[StrictStr] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """test_json_header_content (synchronous) + + Synchronous variant of :meth:`test_json_header_content_without_preload_content`. It calls + the asynchronous method and blocks until it completes. + """ # noqa: E501 + return run_sync( + self.test_json_header_content_without_preload_content( + x_json_arg=x_json_arg, + x_plain_arg=x_plain_arg, + _request_timeout=_request_timeout, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + ) + + + def _test_json_header_content_serialize( + self, + x_json_arg, + x_plain_arg, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + if x_json_arg is not None: + _header_params['X-Json-Arg'] = json.dumps( + self.api_client.sanitize_for_serialization(x_json_arg) + ) + if x_plain_arg is not None: + _header_params['X-Plain-Arg'] = x_plain_arg + # process the form parameters + # process the body parameter + + + + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='POST', + resource_path='/test/json-header-content', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + @validate_call async def test_object_for_multipart_requests( self, diff --git a/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/__init__.py b/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/__init__.py index 308e6dfc3ebb..488a82150d32 100644 --- a/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/__init__.py +++ b/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/__init__.py @@ -63,6 +63,7 @@ from petstore_api.models.foo_get_default_response import FooGetDefaultResponse from petstore_api.models.format_test import FormatTest from petstore_api.models.has_only_read_only import HasOnlyReadOnly +from petstore_api.models.header_arg import HeaderArg from petstore_api.models.health_check_result import HealthCheckResult from petstore_api.models.hunting_dog import HuntingDog from petstore_api.models.info import Info diff --git a/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/header_arg.py b/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/header_arg.py new file mode 100644 index 000000000000..bd8d1b0090ed --- /dev/null +++ b/samples/openapi3/client/petstore/python-httpx-sync/petstore_api/models/header_arg.py @@ -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: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictBool, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from typing import Optional, Set +from typing_extensions import Self +from pydantic_core import to_jsonable_python + +class HeaderArg(BaseModel): + """ + HeaderArg + """ # noqa: E501 + path: Optional[StrictStr] = None + recursive: Optional[StrictBool] = None + __properties: ClassVar[List[str]] = ["path", "recursive"] + + model_config = ConfigDict( + validate_by_name=True, + validate_by_alias=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(to_jsonable_python(self.to_dict())) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of HeaderArg from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of HeaderArg from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "path": obj.get("path"), + "recursive": obj.get("recursive") + }) + return _obj + + diff --git a/samples/openapi3/client/petstore/python-httpx-sync/test/test_header_arg.py b/samples/openapi3/client/petstore/python-httpx-sync/test/test_header_arg.py new file mode 100644 index 000000000000..f4577965fcce --- /dev/null +++ b/samples/openapi3/client/petstore/python-httpx-sync/test/test_header_arg.py @@ -0,0 +1,52 @@ +# 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: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from petstore_api.models.header_arg import HeaderArg + +class TestHeaderArg(unittest.TestCase): + """HeaderArg unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> HeaderArg: + """Test HeaderArg + include_optional is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `HeaderArg` + """ + model = HeaderArg() + if include_optional: + return HeaderArg( + path = '', + recursive = True + ) + else: + return HeaderArg( + ) + """ + + def testHeaderArg(self): + """Test HeaderArg""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-httpx/.openapi-generator/FILES b/samples/openapi3/client/petstore/python-httpx/.openapi-generator/FILES index 1eb565d74f11..d808742215cb 100644 --- a/samples/openapi3/client/petstore/python-httpx/.openapi-generator/FILES +++ b/samples/openapi3/client/petstore/python-httpx/.openapi-generator/FILES @@ -57,6 +57,7 @@ docs/Foo.md docs/FooGetDefaultResponse.md docs/FormatTest.md docs/HasOnlyReadOnly.md +docs/HeaderArg.md docs/HealthCheckResult.md docs/HuntingDog.md docs/ImportTestDatetimeApi.md @@ -191,6 +192,7 @@ petstore_api/models/foo.py petstore_api/models/foo_get_default_response.py petstore_api/models/format_test.py petstore_api/models/has_only_read_only.py +petstore_api/models/header_arg.py petstore_api/models/health_check_result.py petstore_api/models/hunting_dog.py petstore_api/models/info.py diff --git a/samples/openapi3/client/petstore/python-httpx/README.md b/samples/openapi3/client/petstore/python-httpx/README.md index 2b24af59b591..5ac850a385de 100644 --- a/samples/openapi3/client/petstore/python-httpx/README.md +++ b/samples/openapi3/client/petstore/python-httpx/README.md @@ -125,6 +125,7 @@ Class | Method | HTTP request | Description *FakeApi* | [**test_inline_additional_properties**](docs/FakeApi.md#test_inline_additional_properties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties *FakeApi* | [**test_inline_freeform_additional_properties**](docs/FakeApi.md#test_inline_freeform_additional_properties) | **POST** /fake/inline-freeform-additionalProperties | test inline free-form additionalProperties *FakeApi* | [**test_json_form_data**](docs/FakeApi.md#test_json_form_data) | **GET** /fake/jsonFormData | test json serialization of form data +*FakeApi* | [**test_json_header_content**](docs/FakeApi.md#test_json_header_content) | **POST** /test/json-header-content | *FakeApi* | [**test_object_for_multipart_requests**](docs/FakeApi.md#test_object_for_multipart_requests) | **POST** /fake/object_for_multipart_requests | *FakeApi* | [**test_query_parameter_collection_format**](docs/FakeApi.md#test_query_parameter_collection_format) | **PUT** /fake/test-query-parameters | *FakeApi* | [**test_string_map_reference**](docs/FakeApi.md#test_string_map_reference) | **POST** /fake/stringMap-reference | test referenced string map @@ -206,6 +207,7 @@ Class | Method | HTTP request | Description - [FooGetDefaultResponse](docs/FooGetDefaultResponse.md) - [FormatTest](docs/FormatTest.md) - [HasOnlyReadOnly](docs/HasOnlyReadOnly.md) + - [HeaderArg](docs/HeaderArg.md) - [HealthCheckResult](docs/HealthCheckResult.md) - [HuntingDog](docs/HuntingDog.md) - [Info](docs/Info.md) diff --git a/samples/openapi3/client/petstore/python-httpx/docs/FakeApi.md b/samples/openapi3/client/petstore/python-httpx/docs/FakeApi.md index 2c434569b655..7777f511be90 100644 --- a/samples/openapi3/client/petstore/python-httpx/docs/FakeApi.md +++ b/samples/openapi3/client/petstore/python-httpx/docs/FakeApi.md @@ -37,6 +37,7 @@ Method | HTTP request | Description [**test_inline_additional_properties**](FakeApi.md#test_inline_additional_properties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties [**test_inline_freeform_additional_properties**](FakeApi.md#test_inline_freeform_additional_properties) | **POST** /fake/inline-freeform-additionalProperties | test inline free-form additionalProperties [**test_json_form_data**](FakeApi.md#test_json_form_data) | **GET** /fake/jsonFormData | test json serialization of form data +[**test_json_header_content**](FakeApi.md#test_json_header_content) | **POST** /test/json-header-content | [**test_object_for_multipart_requests**](FakeApi.md#test_object_for_multipart_requests) | **POST** /fake/object_for_multipart_requests | [**test_query_parameter_collection_format**](FakeApi.md#test_query_parameter_collection_format) | **PUT** /fake/test-query-parameters | [**test_string_map_reference**](FakeApi.md#test_string_map_reference) | **POST** /fake/stringMap-reference | test referenced string map @@ -2265,6 +2266,69 @@ 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) +# **test_json_header_content** +> test_json_header_content(x_json_arg, x_plain_arg=x_plain_arg) + +### Example + + +```python +import petstore_api +from petstore_api.models.header_arg import HeaderArg +from petstore_api.rest import ApiException +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 +async with petstore_api.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = petstore_api.FakeApi(api_client) + x_json_arg = petstore_api.HeaderArg() # HeaderArg | + x_plain_arg = 'x_plain_arg_example' # str | (optional) + + try: + await api_instance.test_json_header_content(x_json_arg, x_plain_arg=x_plain_arg) + except Exception as e: + print("Exception when calling FakeApi->test_json_header_content: %s\n" % e) +``` + + + +### Parameters + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **x_json_arg** | [**HeaderArg**](.md)| | + **x_plain_arg** | **str**| | [optional] + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + +### HTTP response details + +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**204** | No content | - | + +[[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) + # **test_object_for_multipart_requests** > test_object_for_multipart_requests(marker) diff --git a/samples/openapi3/client/petstore/python-httpx/docs/HeaderArg.md b/samples/openapi3/client/petstore/python-httpx/docs/HeaderArg.md new file mode 100644 index 000000000000..e38f4d753d6d --- /dev/null +++ b/samples/openapi3/client/petstore/python-httpx/docs/HeaderArg.md @@ -0,0 +1,30 @@ +# HeaderArg + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**path** | **str** | | [optional] +**recursive** | **bool** | | [optional] + +## Example + +```python +from petstore_api.models.header_arg import HeaderArg + +# TODO update the JSON string below +json = "{}" +# create an instance of HeaderArg from a JSON string +header_arg_instance = HeaderArg.from_json(json) +# print the JSON string representation of the object +print(HeaderArg.to_json()) + +# convert the object into a dict +header_arg_dict = header_arg_instance.to_dict() +# create an instance of HeaderArg from a dict +header_arg_from_dict = HeaderArg.from_dict(header_arg_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/__init__.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/__init__.py index c7f461775f59..55be0097b9d0 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/__init__.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/__init__.py @@ -86,6 +86,7 @@ "FooGetDefaultResponse", "FormatTest", "HasOnlyReadOnly", + "HeaderArg", "HealthCheckResult", "HuntingDog", "Info", @@ -225,6 +226,7 @@ from petstore_api.models.foo_get_default_response import FooGetDefaultResponse as FooGetDefaultResponse from petstore_api.models.format_test import FormatTest as FormatTest from petstore_api.models.has_only_read_only import HasOnlyReadOnly as HasOnlyReadOnly +from petstore_api.models.header_arg import HeaderArg as HeaderArg from petstore_api.models.health_check_result import HealthCheckResult as HealthCheckResult from petstore_api.models.hunting_dog import HuntingDog as HuntingDog from petstore_api.models.info import Info as Info diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/api/fake_api.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/api/fake_api.py index 6adfebde84fb..7fb0a185a264 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/api/fake_api.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/api/fake_api.py @@ -10,6 +10,7 @@ """ # noqa: E501 +import json import warnings from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt from typing import Any, Dict, List, Optional, Tuple, Union @@ -23,6 +24,7 @@ from petstore_api.models.client import Client from petstore_api.models.enum_class import EnumClass from petstore_api.models.file_schema_test_class import FileSchemaTestClass +from petstore_api.models.header_arg import HeaderArg from petstore_api.models.health_check_result import HealthCheckResult from petstore_api.models.model_api_response import ModelApiResponse from petstore_api.models.outer_composite import OuterComposite @@ -8925,6 +8927,273 @@ def _test_json_form_data_serialize( + @validate_call + async def test_json_header_content( + self, + x_json_arg: HeaderArg, + x_plain_arg: Optional[StrictStr] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> None: + """test_json_header_content + + + :param x_json_arg: (required) + :type x_json_arg: HeaderArg + :param x_plain_arg: + :type x_plain_arg: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._test_json_header_content_serialize( + x_json_arg=x_json_arg, + x_plain_arg=x_plain_arg, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '204': None, + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + async def test_json_header_content_with_http_info( + self, + x_json_arg: HeaderArg, + x_plain_arg: Optional[StrictStr] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[None]: + """test_json_header_content + + + :param x_json_arg: (required) + :type x_json_arg: HeaderArg + :param x_plain_arg: + :type x_plain_arg: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._test_json_header_content_serialize( + x_json_arg=x_json_arg, + x_plain_arg=x_plain_arg, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '204': None, + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + async def test_json_header_content_without_preload_content( + self, + x_json_arg: HeaderArg, + x_plain_arg: Optional[StrictStr] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """test_json_header_content + + + :param x_json_arg: (required) + :type x_json_arg: HeaderArg + :param x_plain_arg: + :type x_plain_arg: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._test_json_header_content_serialize( + x_json_arg=x_json_arg, + x_plain_arg=x_plain_arg, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '204': None, + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _test_json_header_content_serialize( + self, + x_json_arg, + x_plain_arg, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + if x_json_arg is not None: + _header_params['X-Json-Arg'] = json.dumps( + self.api_client.sanitize_for_serialization(x_json_arg) + ) + if x_plain_arg is not None: + _header_params['X-Plain-Arg'] = x_plain_arg + # process the form parameters + # process the body parameter + + + + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='POST', + resource_path='/test/json-header-content', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + @validate_call async def test_object_for_multipart_requests( self, diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/__init__.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/__init__.py index 308e6dfc3ebb..488a82150d32 100644 --- a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/__init__.py +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/__init__.py @@ -63,6 +63,7 @@ from petstore_api.models.foo_get_default_response import FooGetDefaultResponse from petstore_api.models.format_test import FormatTest from petstore_api.models.has_only_read_only import HasOnlyReadOnly +from petstore_api.models.header_arg import HeaderArg from petstore_api.models.health_check_result import HealthCheckResult from petstore_api.models.hunting_dog import HuntingDog from petstore_api.models.info import Info diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/models/header_arg.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/header_arg.py new file mode 100644 index 000000000000..bd8d1b0090ed --- /dev/null +++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/models/header_arg.py @@ -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: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictBool, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from typing import Optional, Set +from typing_extensions import Self +from pydantic_core import to_jsonable_python + +class HeaderArg(BaseModel): + """ + HeaderArg + """ # noqa: E501 + path: Optional[StrictStr] = None + recursive: Optional[StrictBool] = None + __properties: ClassVar[List[str]] = ["path", "recursive"] + + model_config = ConfigDict( + validate_by_name=True, + validate_by_alias=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(to_jsonable_python(self.to_dict())) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of HeaderArg from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of HeaderArg from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "path": obj.get("path"), + "recursive": obj.get("recursive") + }) + return _obj + + diff --git a/samples/openapi3/client/petstore/python-httpx/test/test_header_arg.py b/samples/openapi3/client/petstore/python-httpx/test/test_header_arg.py new file mode 100644 index 000000000000..f4577965fcce --- /dev/null +++ b/samples/openapi3/client/petstore/python-httpx/test/test_header_arg.py @@ -0,0 +1,52 @@ +# 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: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from petstore_api.models.header_arg import HeaderArg + +class TestHeaderArg(unittest.TestCase): + """HeaderArg unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> HeaderArg: + """Test HeaderArg + include_optional is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `HeaderArg` + """ + model = HeaderArg() + if include_optional: + return HeaderArg( + path = '', + recursive = True + ) + else: + return HeaderArg( + ) + """ + + def testHeaderArg(self): + """Test HeaderArg""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-httpx2-sync/.openapi-generator/FILES b/samples/openapi3/client/petstore/python-httpx2-sync/.openapi-generator/FILES index 463307488f33..4ced57aeb32e 100644 --- a/samples/openapi3/client/petstore/python-httpx2-sync/.openapi-generator/FILES +++ b/samples/openapi3/client/petstore/python-httpx2-sync/.openapi-generator/FILES @@ -57,6 +57,7 @@ docs/Foo.md docs/FooGetDefaultResponse.md docs/FormatTest.md docs/HasOnlyReadOnly.md +docs/HeaderArg.md docs/HealthCheckResult.md docs/HuntingDog.md docs/ImportTestDatetimeApi.md @@ -191,6 +192,7 @@ petstore_api/models/foo.py petstore_api/models/foo_get_default_response.py petstore_api/models/format_test.py petstore_api/models/has_only_read_only.py +petstore_api/models/header_arg.py petstore_api/models/health_check_result.py petstore_api/models/hunting_dog.py petstore_api/models/info.py diff --git a/samples/openapi3/client/petstore/python-httpx2-sync/README.md b/samples/openapi3/client/petstore/python-httpx2-sync/README.md index 8a168eafa795..b288de0bcfec 100644 --- a/samples/openapi3/client/petstore/python-httpx2-sync/README.md +++ b/samples/openapi3/client/petstore/python-httpx2-sync/README.md @@ -128,6 +128,7 @@ Class | Method | HTTP request | Description *FakeApi* | [**test_inline_additional_properties**](docs/FakeApi.md#test_inline_additional_properties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties *FakeApi* | [**test_inline_freeform_additional_properties**](docs/FakeApi.md#test_inline_freeform_additional_properties) | **POST** /fake/inline-freeform-additionalProperties | test inline free-form additionalProperties *FakeApi* | [**test_json_form_data**](docs/FakeApi.md#test_json_form_data) | **GET** /fake/jsonFormData | test json serialization of form data +*FakeApi* | [**test_json_header_content**](docs/FakeApi.md#test_json_header_content) | **POST** /test/json-header-content | *FakeApi* | [**test_object_for_multipart_requests**](docs/FakeApi.md#test_object_for_multipart_requests) | **POST** /fake/object_for_multipart_requests | *FakeApi* | [**test_query_parameter_collection_format**](docs/FakeApi.md#test_query_parameter_collection_format) | **PUT** /fake/test-query-parameters | *FakeApi* | [**test_string_map_reference**](docs/FakeApi.md#test_string_map_reference) | **POST** /fake/stringMap-reference | test referenced string map @@ -209,6 +210,7 @@ Class | Method | HTTP request | Description - [FooGetDefaultResponse](docs/FooGetDefaultResponse.md) - [FormatTest](docs/FormatTest.md) - [HasOnlyReadOnly](docs/HasOnlyReadOnly.md) + - [HeaderArg](docs/HeaderArg.md) - [HealthCheckResult](docs/HealthCheckResult.md) - [HuntingDog](docs/HuntingDog.md) - [Info](docs/Info.md) diff --git a/samples/openapi3/client/petstore/python-httpx2-sync/docs/FakeApi.md b/samples/openapi3/client/petstore/python-httpx2-sync/docs/FakeApi.md index 4ef59dc7aa36..7e0bcc172701 100644 --- a/samples/openapi3/client/petstore/python-httpx2-sync/docs/FakeApi.md +++ b/samples/openapi3/client/petstore/python-httpx2-sync/docs/FakeApi.md @@ -37,6 +37,7 @@ Method | HTTP request | Description [**test_inline_additional_properties**](FakeApi.md#test_inline_additional_properties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties [**test_inline_freeform_additional_properties**](FakeApi.md#test_inline_freeform_additional_properties) | **POST** /fake/inline-freeform-additionalProperties | test inline free-form additionalProperties [**test_json_form_data**](FakeApi.md#test_json_form_data) | **GET** /fake/jsonFormData | test json serialization of form data +[**test_json_header_content**](FakeApi.md#test_json_header_content) | **POST** /test/json-header-content | [**test_object_for_multipart_requests**](FakeApi.md#test_object_for_multipart_requests) | **POST** /fake/object_for_multipart_requests | [**test_query_parameter_collection_format**](FakeApi.md#test_query_parameter_collection_format) | **PUT** /fake/test-query-parameters | [**test_string_map_reference**](FakeApi.md#test_string_map_reference) | **POST** /fake/stringMap-reference | test referenced string map @@ -2331,6 +2332,71 @@ 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) +# **test_json_header_content** +> test_json_header_content(x_json_arg, x_plain_arg=x_plain_arg) + +**Synchronous variant:** `test_json_header_content_sync(...)` — same parameters and return type, but blocks until completion instead of requiring `await`. + +### Example + + +```python +import petstore_api +from petstore_api.models.header_arg import HeaderArg +from petstore_api.rest import ApiException +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 +async with petstore_api.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = petstore_api.FakeApi(api_client) + x_json_arg = petstore_api.HeaderArg() # HeaderArg | + x_plain_arg = 'x_plain_arg_example' # str | (optional) + + try: + await api_instance.test_json_header_content(x_json_arg, x_plain_arg=x_plain_arg) + except Exception as e: + print("Exception when calling FakeApi->test_json_header_content: %s\n" % e) +``` + + + +### Parameters + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **x_json_arg** | [**HeaderArg**](.md)| | + **x_plain_arg** | **str**| | [optional] + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + +### HTTP response details + +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**204** | No content | - | + +[[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) + # **test_object_for_multipart_requests** > test_object_for_multipart_requests(marker) diff --git a/samples/openapi3/client/petstore/python-httpx2-sync/docs/HeaderArg.md b/samples/openapi3/client/petstore/python-httpx2-sync/docs/HeaderArg.md new file mode 100644 index 000000000000..e38f4d753d6d --- /dev/null +++ b/samples/openapi3/client/petstore/python-httpx2-sync/docs/HeaderArg.md @@ -0,0 +1,30 @@ +# HeaderArg + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**path** | **str** | | [optional] +**recursive** | **bool** | | [optional] + +## Example + +```python +from petstore_api.models.header_arg import HeaderArg + +# TODO update the JSON string below +json = "{}" +# create an instance of HeaderArg from a JSON string +header_arg_instance = HeaderArg.from_json(json) +# print the JSON string representation of the object +print(HeaderArg.to_json()) + +# convert the object into a dict +header_arg_dict = header_arg_instance.to_dict() +# create an instance of HeaderArg from a dict +header_arg_from_dict = HeaderArg.from_dict(header_arg_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/python-httpx2-sync/petstore_api/__init__.py b/samples/openapi3/client/petstore/python-httpx2-sync/petstore_api/__init__.py index c7f461775f59..55be0097b9d0 100644 --- a/samples/openapi3/client/petstore/python-httpx2-sync/petstore_api/__init__.py +++ b/samples/openapi3/client/petstore/python-httpx2-sync/petstore_api/__init__.py @@ -86,6 +86,7 @@ "FooGetDefaultResponse", "FormatTest", "HasOnlyReadOnly", + "HeaderArg", "HealthCheckResult", "HuntingDog", "Info", @@ -225,6 +226,7 @@ from petstore_api.models.foo_get_default_response import FooGetDefaultResponse as FooGetDefaultResponse from petstore_api.models.format_test import FormatTest as FormatTest from petstore_api.models.has_only_read_only import HasOnlyReadOnly as HasOnlyReadOnly +from petstore_api.models.header_arg import HeaderArg as HeaderArg from petstore_api.models.health_check_result import HealthCheckResult as HealthCheckResult from petstore_api.models.hunting_dog import HuntingDog as HuntingDog from petstore_api.models.info import Info as Info diff --git a/samples/openapi3/client/petstore/python-httpx2-sync/petstore_api/api/fake_api.py b/samples/openapi3/client/petstore/python-httpx2-sync/petstore_api/api/fake_api.py index c22c0ab04bda..05c6c53603af 100644 --- a/samples/openapi3/client/petstore/python-httpx2-sync/petstore_api/api/fake_api.py +++ b/samples/openapi3/client/petstore/python-httpx2-sync/petstore_api/api/fake_api.py @@ -10,6 +10,7 @@ """ # noqa: E501 +import json import warnings from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt from typing import Any, Dict, List, Optional, Tuple, Union @@ -23,6 +24,7 @@ from petstore_api.models.client import Client from petstore_api.models.enum_class import EnumClass from petstore_api.models.file_schema_test_class import FileSchemaTestClass +from petstore_api.models.header_arg import HeaderArg from petstore_api.models.health_check_result import HealthCheckResult from petstore_api.models.model_api_response import ModelApiResponse from petstore_api.models.outer_composite import OuterComposite @@ -12364,6 +12366,381 @@ def _test_json_form_data_serialize( + @validate_call + async def test_json_header_content( + self, + x_json_arg: HeaderArg, + x_plain_arg: Optional[StrictStr] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> None: + """test_json_header_content + + + :param x_json_arg: (required) + :type x_json_arg: HeaderArg + :param x_plain_arg: + :type x_plain_arg: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._test_json_header_content_serialize( + x_json_arg=x_json_arg, + x_plain_arg=x_plain_arg, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '204': None, + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + async def test_json_header_content_with_http_info( + self, + x_json_arg: HeaderArg, + x_plain_arg: Optional[StrictStr] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[None]: + """test_json_header_content + + + :param x_json_arg: (required) + :type x_json_arg: HeaderArg + :param x_plain_arg: + :type x_plain_arg: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._test_json_header_content_serialize( + x_json_arg=x_json_arg, + x_plain_arg=x_plain_arg, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '204': None, + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + async def test_json_header_content_without_preload_content( + self, + x_json_arg: HeaderArg, + x_plain_arg: Optional[StrictStr] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """test_json_header_content + + + :param x_json_arg: (required) + :type x_json_arg: HeaderArg + :param x_plain_arg: + :type x_plain_arg: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._test_json_header_content_serialize( + x_json_arg=x_json_arg, + x_plain_arg=x_plain_arg, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '204': None, + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + @validate_call + def test_json_header_content_sync( + self, + x_json_arg: HeaderArg, + x_plain_arg: Optional[StrictStr] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> None: + """test_json_header_content (synchronous) + + Synchronous variant of :meth:`test_json_header_content`. It calls the asynchronous + method and blocks until it completes. + """ # noqa: E501 + return run_sync( + self.test_json_header_content( + x_json_arg=x_json_arg, + x_plain_arg=x_plain_arg, + _request_timeout=_request_timeout, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + ) + + + @validate_call + def test_json_header_content_sync_with_http_info( + self, + x_json_arg: HeaderArg, + x_plain_arg: Optional[StrictStr] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[None]: + """test_json_header_content (synchronous) + + Synchronous variant of :meth:`test_json_header_content_with_http_info`. It calls the + asynchronous method and blocks until it completes. + """ # noqa: E501 + return run_sync( + self.test_json_header_content_with_http_info( + x_json_arg=x_json_arg, + x_plain_arg=x_plain_arg, + _request_timeout=_request_timeout, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + ) + + + @validate_call + def test_json_header_content_sync_without_preload_content( + self, + x_json_arg: HeaderArg, + x_plain_arg: Optional[StrictStr] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """test_json_header_content (synchronous) + + Synchronous variant of :meth:`test_json_header_content_without_preload_content`. It calls + the asynchronous method and blocks until it completes. + """ # noqa: E501 + return run_sync( + self.test_json_header_content_without_preload_content( + x_json_arg=x_json_arg, + x_plain_arg=x_plain_arg, + _request_timeout=_request_timeout, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index, + ) + ) + + + def _test_json_header_content_serialize( + self, + x_json_arg, + x_plain_arg, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + if x_json_arg is not None: + _header_params['X-Json-Arg'] = json.dumps( + self.api_client.sanitize_for_serialization(x_json_arg) + ) + if x_plain_arg is not None: + _header_params['X-Plain-Arg'] = x_plain_arg + # process the form parameters + # process the body parameter + + + + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='POST', + resource_path='/test/json-header-content', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + @validate_call async def test_object_for_multipart_requests( self, diff --git a/samples/openapi3/client/petstore/python-httpx2-sync/petstore_api/models/__init__.py b/samples/openapi3/client/petstore/python-httpx2-sync/petstore_api/models/__init__.py index 308e6dfc3ebb..488a82150d32 100644 --- a/samples/openapi3/client/petstore/python-httpx2-sync/petstore_api/models/__init__.py +++ b/samples/openapi3/client/petstore/python-httpx2-sync/petstore_api/models/__init__.py @@ -63,6 +63,7 @@ from petstore_api.models.foo_get_default_response import FooGetDefaultResponse from petstore_api.models.format_test import FormatTest from petstore_api.models.has_only_read_only import HasOnlyReadOnly +from petstore_api.models.header_arg import HeaderArg from petstore_api.models.health_check_result import HealthCheckResult from petstore_api.models.hunting_dog import HuntingDog from petstore_api.models.info import Info diff --git a/samples/openapi3/client/petstore/python-httpx2-sync/petstore_api/models/header_arg.py b/samples/openapi3/client/petstore/python-httpx2-sync/petstore_api/models/header_arg.py new file mode 100644 index 000000000000..bd8d1b0090ed --- /dev/null +++ b/samples/openapi3/client/petstore/python-httpx2-sync/petstore_api/models/header_arg.py @@ -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: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictBool, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from typing import Optional, Set +from typing_extensions import Self +from pydantic_core import to_jsonable_python + +class HeaderArg(BaseModel): + """ + HeaderArg + """ # noqa: E501 + path: Optional[StrictStr] = None + recursive: Optional[StrictBool] = None + __properties: ClassVar[List[str]] = ["path", "recursive"] + + model_config = ConfigDict( + validate_by_name=True, + validate_by_alias=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(to_jsonable_python(self.to_dict())) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of HeaderArg from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of HeaderArg from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "path": obj.get("path"), + "recursive": obj.get("recursive") + }) + return _obj + + diff --git a/samples/openapi3/client/petstore/python-httpx2-sync/test/test_header_arg.py b/samples/openapi3/client/petstore/python-httpx2-sync/test/test_header_arg.py new file mode 100644 index 000000000000..f4577965fcce --- /dev/null +++ b/samples/openapi3/client/petstore/python-httpx2-sync/test/test_header_arg.py @@ -0,0 +1,52 @@ +# 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: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from petstore_api.models.header_arg import HeaderArg + +class TestHeaderArg(unittest.TestCase): + """HeaderArg unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> HeaderArg: + """Test HeaderArg + include_optional is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `HeaderArg` + """ + model = HeaderArg() + if include_optional: + return HeaderArg( + path = '', + recursive = True + ) + else: + return HeaderArg( + ) + """ + + def testHeaderArg(self): + """Test HeaderArg""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-httpx2/.openapi-generator/FILES b/samples/openapi3/client/petstore/python-httpx2/.openapi-generator/FILES index 1eb565d74f11..d808742215cb 100644 --- a/samples/openapi3/client/petstore/python-httpx2/.openapi-generator/FILES +++ b/samples/openapi3/client/petstore/python-httpx2/.openapi-generator/FILES @@ -57,6 +57,7 @@ docs/Foo.md docs/FooGetDefaultResponse.md docs/FormatTest.md docs/HasOnlyReadOnly.md +docs/HeaderArg.md docs/HealthCheckResult.md docs/HuntingDog.md docs/ImportTestDatetimeApi.md @@ -191,6 +192,7 @@ petstore_api/models/foo.py petstore_api/models/foo_get_default_response.py petstore_api/models/format_test.py petstore_api/models/has_only_read_only.py +petstore_api/models/header_arg.py petstore_api/models/health_check_result.py petstore_api/models/hunting_dog.py petstore_api/models/info.py diff --git a/samples/openapi3/client/petstore/python-httpx2/README.md b/samples/openapi3/client/petstore/python-httpx2/README.md index 01215bdf5f9a..9652b103ca11 100644 --- a/samples/openapi3/client/petstore/python-httpx2/README.md +++ b/samples/openapi3/client/petstore/python-httpx2/README.md @@ -127,6 +127,7 @@ Class | Method | HTTP request | Description *FakeApi* | [**test_inline_additional_properties**](docs/FakeApi.md#test_inline_additional_properties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties *FakeApi* | [**test_inline_freeform_additional_properties**](docs/FakeApi.md#test_inline_freeform_additional_properties) | **POST** /fake/inline-freeform-additionalProperties | test inline free-form additionalProperties *FakeApi* | [**test_json_form_data**](docs/FakeApi.md#test_json_form_data) | **GET** /fake/jsonFormData | test json serialization of form data +*FakeApi* | [**test_json_header_content**](docs/FakeApi.md#test_json_header_content) | **POST** /test/json-header-content | *FakeApi* | [**test_object_for_multipart_requests**](docs/FakeApi.md#test_object_for_multipart_requests) | **POST** /fake/object_for_multipart_requests | *FakeApi* | [**test_query_parameter_collection_format**](docs/FakeApi.md#test_query_parameter_collection_format) | **PUT** /fake/test-query-parameters | *FakeApi* | [**test_string_map_reference**](docs/FakeApi.md#test_string_map_reference) | **POST** /fake/stringMap-reference | test referenced string map @@ -208,6 +209,7 @@ Class | Method | HTTP request | Description - [FooGetDefaultResponse](docs/FooGetDefaultResponse.md) - [FormatTest](docs/FormatTest.md) - [HasOnlyReadOnly](docs/HasOnlyReadOnly.md) + - [HeaderArg](docs/HeaderArg.md) - [HealthCheckResult](docs/HealthCheckResult.md) - [HuntingDog](docs/HuntingDog.md) - [Info](docs/Info.md) diff --git a/samples/openapi3/client/petstore/python-httpx2/docs/FakeApi.md b/samples/openapi3/client/petstore/python-httpx2/docs/FakeApi.md index 2c434569b655..7777f511be90 100644 --- a/samples/openapi3/client/petstore/python-httpx2/docs/FakeApi.md +++ b/samples/openapi3/client/petstore/python-httpx2/docs/FakeApi.md @@ -37,6 +37,7 @@ Method | HTTP request | Description [**test_inline_additional_properties**](FakeApi.md#test_inline_additional_properties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties [**test_inline_freeform_additional_properties**](FakeApi.md#test_inline_freeform_additional_properties) | **POST** /fake/inline-freeform-additionalProperties | test inline free-form additionalProperties [**test_json_form_data**](FakeApi.md#test_json_form_data) | **GET** /fake/jsonFormData | test json serialization of form data +[**test_json_header_content**](FakeApi.md#test_json_header_content) | **POST** /test/json-header-content | [**test_object_for_multipart_requests**](FakeApi.md#test_object_for_multipart_requests) | **POST** /fake/object_for_multipart_requests | [**test_query_parameter_collection_format**](FakeApi.md#test_query_parameter_collection_format) | **PUT** /fake/test-query-parameters | [**test_string_map_reference**](FakeApi.md#test_string_map_reference) | **POST** /fake/stringMap-reference | test referenced string map @@ -2265,6 +2266,69 @@ 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) +# **test_json_header_content** +> test_json_header_content(x_json_arg, x_plain_arg=x_plain_arg) + +### Example + + +```python +import petstore_api +from petstore_api.models.header_arg import HeaderArg +from petstore_api.rest import ApiException +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 +async with petstore_api.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = petstore_api.FakeApi(api_client) + x_json_arg = petstore_api.HeaderArg() # HeaderArg | + x_plain_arg = 'x_plain_arg_example' # str | (optional) + + try: + await api_instance.test_json_header_content(x_json_arg, x_plain_arg=x_plain_arg) + except Exception as e: + print("Exception when calling FakeApi->test_json_header_content: %s\n" % e) +``` + + + +### Parameters + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **x_json_arg** | [**HeaderArg**](.md)| | + **x_plain_arg** | **str**| | [optional] + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + +### HTTP response details + +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**204** | No content | - | + +[[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) + # **test_object_for_multipart_requests** > test_object_for_multipart_requests(marker) diff --git a/samples/openapi3/client/petstore/python-httpx2/docs/HeaderArg.md b/samples/openapi3/client/petstore/python-httpx2/docs/HeaderArg.md new file mode 100644 index 000000000000..e38f4d753d6d --- /dev/null +++ b/samples/openapi3/client/petstore/python-httpx2/docs/HeaderArg.md @@ -0,0 +1,30 @@ +# HeaderArg + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**path** | **str** | | [optional] +**recursive** | **bool** | | [optional] + +## Example + +```python +from petstore_api.models.header_arg import HeaderArg + +# TODO update the JSON string below +json = "{}" +# create an instance of HeaderArg from a JSON string +header_arg_instance = HeaderArg.from_json(json) +# print the JSON string representation of the object +print(HeaderArg.to_json()) + +# convert the object into a dict +header_arg_dict = header_arg_instance.to_dict() +# create an instance of HeaderArg from a dict +header_arg_from_dict = HeaderArg.from_dict(header_arg_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/python-httpx2/petstore_api/__init__.py b/samples/openapi3/client/petstore/python-httpx2/petstore_api/__init__.py index c7f461775f59..55be0097b9d0 100644 --- a/samples/openapi3/client/petstore/python-httpx2/petstore_api/__init__.py +++ b/samples/openapi3/client/petstore/python-httpx2/petstore_api/__init__.py @@ -86,6 +86,7 @@ "FooGetDefaultResponse", "FormatTest", "HasOnlyReadOnly", + "HeaderArg", "HealthCheckResult", "HuntingDog", "Info", @@ -225,6 +226,7 @@ from petstore_api.models.foo_get_default_response import FooGetDefaultResponse as FooGetDefaultResponse from petstore_api.models.format_test import FormatTest as FormatTest from petstore_api.models.has_only_read_only import HasOnlyReadOnly as HasOnlyReadOnly +from petstore_api.models.header_arg import HeaderArg as HeaderArg from petstore_api.models.health_check_result import HealthCheckResult as HealthCheckResult from petstore_api.models.hunting_dog import HuntingDog as HuntingDog from petstore_api.models.info import Info as Info diff --git a/samples/openapi3/client/petstore/python-httpx2/petstore_api/api/fake_api.py b/samples/openapi3/client/petstore/python-httpx2/petstore_api/api/fake_api.py index 6adfebde84fb..7fb0a185a264 100644 --- a/samples/openapi3/client/petstore/python-httpx2/petstore_api/api/fake_api.py +++ b/samples/openapi3/client/petstore/python-httpx2/petstore_api/api/fake_api.py @@ -10,6 +10,7 @@ """ # noqa: E501 +import json import warnings from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt from typing import Any, Dict, List, Optional, Tuple, Union @@ -23,6 +24,7 @@ from petstore_api.models.client import Client from petstore_api.models.enum_class import EnumClass from petstore_api.models.file_schema_test_class import FileSchemaTestClass +from petstore_api.models.header_arg import HeaderArg from petstore_api.models.health_check_result import HealthCheckResult from petstore_api.models.model_api_response import ModelApiResponse from petstore_api.models.outer_composite import OuterComposite @@ -8925,6 +8927,273 @@ def _test_json_form_data_serialize( + @validate_call + async def test_json_header_content( + self, + x_json_arg: HeaderArg, + x_plain_arg: Optional[StrictStr] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> None: + """test_json_header_content + + + :param x_json_arg: (required) + :type x_json_arg: HeaderArg + :param x_plain_arg: + :type x_plain_arg: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._test_json_header_content_serialize( + x_json_arg=x_json_arg, + x_plain_arg=x_plain_arg, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '204': None, + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + async def test_json_header_content_with_http_info( + self, + x_json_arg: HeaderArg, + x_plain_arg: Optional[StrictStr] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[None]: + """test_json_header_content + + + :param x_json_arg: (required) + :type x_json_arg: HeaderArg + :param x_plain_arg: + :type x_plain_arg: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._test_json_header_content_serialize( + x_json_arg=x_json_arg, + x_plain_arg=x_plain_arg, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '204': None, + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + async def test_json_header_content_without_preload_content( + self, + x_json_arg: HeaderArg, + x_plain_arg: Optional[StrictStr] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """test_json_header_content + + + :param x_json_arg: (required) + :type x_json_arg: HeaderArg + :param x_plain_arg: + :type x_plain_arg: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._test_json_header_content_serialize( + x_json_arg=x_json_arg, + x_plain_arg=x_plain_arg, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '204': None, + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _test_json_header_content_serialize( + self, + x_json_arg, + x_plain_arg, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + if x_json_arg is not None: + _header_params['X-Json-Arg'] = json.dumps( + self.api_client.sanitize_for_serialization(x_json_arg) + ) + if x_plain_arg is not None: + _header_params['X-Plain-Arg'] = x_plain_arg + # process the form parameters + # process the body parameter + + + + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='POST', + resource_path='/test/json-header-content', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + @validate_call async def test_object_for_multipart_requests( self, diff --git a/samples/openapi3/client/petstore/python-httpx2/petstore_api/models/__init__.py b/samples/openapi3/client/petstore/python-httpx2/petstore_api/models/__init__.py index 308e6dfc3ebb..488a82150d32 100644 --- a/samples/openapi3/client/petstore/python-httpx2/petstore_api/models/__init__.py +++ b/samples/openapi3/client/petstore/python-httpx2/petstore_api/models/__init__.py @@ -63,6 +63,7 @@ from petstore_api.models.foo_get_default_response import FooGetDefaultResponse from petstore_api.models.format_test import FormatTest from petstore_api.models.has_only_read_only import HasOnlyReadOnly +from petstore_api.models.header_arg import HeaderArg from petstore_api.models.health_check_result import HealthCheckResult from petstore_api.models.hunting_dog import HuntingDog from petstore_api.models.info import Info diff --git a/samples/openapi3/client/petstore/python-httpx2/petstore_api/models/header_arg.py b/samples/openapi3/client/petstore/python-httpx2/petstore_api/models/header_arg.py new file mode 100644 index 000000000000..bd8d1b0090ed --- /dev/null +++ b/samples/openapi3/client/petstore/python-httpx2/petstore_api/models/header_arg.py @@ -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: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictBool, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from typing import Optional, Set +from typing_extensions import Self +from pydantic_core import to_jsonable_python + +class HeaderArg(BaseModel): + """ + HeaderArg + """ # noqa: E501 + path: Optional[StrictStr] = None + recursive: Optional[StrictBool] = None + __properties: ClassVar[List[str]] = ["path", "recursive"] + + model_config = ConfigDict( + validate_by_name=True, + validate_by_alias=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(to_jsonable_python(self.to_dict())) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of HeaderArg from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of HeaderArg from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "path": obj.get("path"), + "recursive": obj.get("recursive") + }) + return _obj + + diff --git a/samples/openapi3/client/petstore/python-httpx2/test/test_header_arg.py b/samples/openapi3/client/petstore/python-httpx2/test/test_header_arg.py new file mode 100644 index 000000000000..f4577965fcce --- /dev/null +++ b/samples/openapi3/client/petstore/python-httpx2/test/test_header_arg.py @@ -0,0 +1,52 @@ +# 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: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from petstore_api.models.header_arg import HeaderArg + +class TestHeaderArg(unittest.TestCase): + """HeaderArg unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> HeaderArg: + """Test HeaderArg + include_optional is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `HeaderArg` + """ + model = HeaderArg() + if include_optional: + return HeaderArg( + path = '', + recursive = True + ) + else: + return HeaderArg( + ) + """ + + def testHeaderArg(self): + """Test HeaderArg""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-lazyImports/.openapi-generator/FILES b/samples/openapi3/client/petstore/python-lazyImports/.openapi-generator/FILES index 1eb565d74f11..d808742215cb 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/.openapi-generator/FILES +++ b/samples/openapi3/client/petstore/python-lazyImports/.openapi-generator/FILES @@ -57,6 +57,7 @@ docs/Foo.md docs/FooGetDefaultResponse.md docs/FormatTest.md docs/HasOnlyReadOnly.md +docs/HeaderArg.md docs/HealthCheckResult.md docs/HuntingDog.md docs/ImportTestDatetimeApi.md @@ -191,6 +192,7 @@ petstore_api/models/foo.py petstore_api/models/foo_get_default_response.py petstore_api/models/format_test.py petstore_api/models/has_only_read_only.py +petstore_api/models/header_arg.py petstore_api/models/health_check_result.py petstore_api/models/hunting_dog.py petstore_api/models/info.py diff --git a/samples/openapi3/client/petstore/python-lazyImports/README.md b/samples/openapi3/client/petstore/python-lazyImports/README.md index fdaf54802dff..e25561c194cc 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/README.md +++ b/samples/openapi3/client/petstore/python-lazyImports/README.md @@ -148,6 +148,7 @@ Class | Method | HTTP request | Description *FakeApi* | [**test_inline_additional_properties**](docs/FakeApi.md#test_inline_additional_properties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties *FakeApi* | [**test_inline_freeform_additional_properties**](docs/FakeApi.md#test_inline_freeform_additional_properties) | **POST** /fake/inline-freeform-additionalProperties | test inline free-form additionalProperties *FakeApi* | [**test_json_form_data**](docs/FakeApi.md#test_json_form_data) | **GET** /fake/jsonFormData | test json serialization of form data +*FakeApi* | [**test_json_header_content**](docs/FakeApi.md#test_json_header_content) | **POST** /test/json-header-content | *FakeApi* | [**test_object_for_multipart_requests**](docs/FakeApi.md#test_object_for_multipart_requests) | **POST** /fake/object_for_multipart_requests | *FakeApi* | [**test_query_parameter_collection_format**](docs/FakeApi.md#test_query_parameter_collection_format) | **PUT** /fake/test-query-parameters | *FakeApi* | [**test_string_map_reference**](docs/FakeApi.md#test_string_map_reference) | **POST** /fake/stringMap-reference | test referenced string map @@ -229,6 +230,7 @@ Class | Method | HTTP request | Description - [FooGetDefaultResponse](docs/FooGetDefaultResponse.md) - [FormatTest](docs/FormatTest.md) - [HasOnlyReadOnly](docs/HasOnlyReadOnly.md) + - [HeaderArg](docs/HeaderArg.md) - [HealthCheckResult](docs/HealthCheckResult.md) - [HuntingDog](docs/HuntingDog.md) - [Info](docs/Info.md) diff --git a/samples/openapi3/client/petstore/python-lazyImports/docs/FakeApi.md b/samples/openapi3/client/petstore/python-lazyImports/docs/FakeApi.md index 813bc5e71df5..16f36a568f2f 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/docs/FakeApi.md +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/FakeApi.md @@ -37,6 +37,7 @@ Method | HTTP request | Description [**test_inline_additional_properties**](FakeApi.md#test_inline_additional_properties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties [**test_inline_freeform_additional_properties**](FakeApi.md#test_inline_freeform_additional_properties) | **POST** /fake/inline-freeform-additionalProperties | test inline free-form additionalProperties [**test_json_form_data**](FakeApi.md#test_json_form_data) | **GET** /fake/jsonFormData | test json serialization of form data +[**test_json_header_content**](FakeApi.md#test_json_header_content) | **POST** /test/json-header-content | [**test_object_for_multipart_requests**](FakeApi.md#test_object_for_multipart_requests) | **POST** /fake/object_for_multipart_requests | [**test_query_parameter_collection_format**](FakeApi.md#test_query_parameter_collection_format) | **PUT** /fake/test-query-parameters | [**test_string_map_reference**](FakeApi.md#test_string_map_reference) | **POST** /fake/stringMap-reference | test referenced string map @@ -2265,6 +2266,69 @@ 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) +# **test_json_header_content** +> test_json_header_content(x_json_arg, x_plain_arg=x_plain_arg) + +### Example + + +```python +import petstore_api +from petstore_api.models.header_arg import HeaderArg +from petstore_api.rest import ApiException +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 = petstore_api.FakeApi(api_client) + x_json_arg = petstore_api.HeaderArg() # HeaderArg | + x_plain_arg = 'x_plain_arg_example' # str | (optional) + + try: + api_instance.test_json_header_content(x_json_arg, x_plain_arg=x_plain_arg) + except Exception as e: + print("Exception when calling FakeApi->test_json_header_content: %s\n" % e) +``` + + + +### Parameters + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **x_json_arg** | [**HeaderArg**](.md)| | + **x_plain_arg** | **str**| | [optional] + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + +### HTTP response details + +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**204** | No content | - | + +[[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) + # **test_object_for_multipart_requests** > test_object_for_multipart_requests(marker) diff --git a/samples/openapi3/client/petstore/python-lazyImports/docs/HeaderArg.md b/samples/openapi3/client/petstore/python-lazyImports/docs/HeaderArg.md new file mode 100644 index 000000000000..e38f4d753d6d --- /dev/null +++ b/samples/openapi3/client/petstore/python-lazyImports/docs/HeaderArg.md @@ -0,0 +1,30 @@ +# HeaderArg + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**path** | **str** | | [optional] +**recursive** | **bool** | | [optional] + +## Example + +```python +from petstore_api.models.header_arg import HeaderArg + +# TODO update the JSON string below +json = "{}" +# create an instance of HeaderArg from a JSON string +header_arg_instance = HeaderArg.from_json(json) +# print the JSON string representation of the object +print(HeaderArg.to_json()) + +# convert the object into a dict +header_arg_dict = header_arg_instance.to_dict() +# create an instance of HeaderArg from a dict +header_arg_from_dict = HeaderArg.from_dict(header_arg_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/__init__.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/__init__.py index 619a79ecf490..e488e2a0ab56 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/__init__.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/__init__.py @@ -86,6 +86,7 @@ "FooGetDefaultResponse", "FormatTest", "HasOnlyReadOnly", + "HeaderArg", "HealthCheckResult", "HuntingDog", "Info", @@ -228,6 +229,7 @@ from petstore_api.models.foo_get_default_response import FooGetDefaultResponse as FooGetDefaultResponse from petstore_api.models.format_test import FormatTest as FormatTest from petstore_api.models.has_only_read_only import HasOnlyReadOnly as HasOnlyReadOnly + from petstore_api.models.header_arg import HeaderArg as HeaderArg from petstore_api.models.health_check_result import HealthCheckResult as HealthCheckResult from petstore_api.models.hunting_dog import HuntingDog as HuntingDog from petstore_api.models.info import Info as Info @@ -365,6 +367,7 @@ "FooGetDefaultResponse": ".models.foo_get_default_response", "FormatTest": ".models.format_test", "HasOnlyReadOnly": ".models.has_only_read_only", + "HeaderArg": ".models.header_arg", "HealthCheckResult": ".models.health_check_result", "HuntingDog": ".models.hunting_dog", "Info": ".models.info", diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/api/fake_api.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/api/fake_api.py index feba662440e8..b2e1cd1be926 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/api/fake_api.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/api/fake_api.py @@ -10,6 +10,7 @@ """ # noqa: E501 +import json import warnings from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt from typing import Any, Dict, List, Optional, Tuple, Union @@ -23,6 +24,7 @@ from petstore_api.models.client import Client from petstore_api.models.enum_class import EnumClass from petstore_api.models.file_schema_test_class import FileSchemaTestClass +from petstore_api.models.header_arg import HeaderArg from petstore_api.models.health_check_result import HealthCheckResult from petstore_api.models.model_api_response import ModelApiResponse from petstore_api.models.outer_composite import OuterComposite @@ -8945,6 +8947,273 @@ def _test_json_form_data_serialize( + @validate_call + def test_json_header_content( + self, + x_json_arg: HeaderArg, + x_plain_arg: Optional[StrictStr] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> None: + """test_json_header_content + + + :param x_json_arg: (required) + :type x_json_arg: HeaderArg + :param x_plain_arg: + :type x_plain_arg: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._test_json_header_content_serialize( + x_json_arg=x_json_arg, + x_plain_arg=x_plain_arg, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '204': None, + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def test_json_header_content_with_http_info( + self, + x_json_arg: HeaderArg, + x_plain_arg: Optional[StrictStr] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[None]: + """test_json_header_content + + + :param x_json_arg: (required) + :type x_json_arg: HeaderArg + :param x_plain_arg: + :type x_plain_arg: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._test_json_header_content_serialize( + x_json_arg=x_json_arg, + x_plain_arg=x_plain_arg, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '204': None, + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def test_json_header_content_without_preload_content( + self, + x_json_arg: HeaderArg, + x_plain_arg: Optional[StrictStr] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """test_json_header_content + + + :param x_json_arg: (required) + :type x_json_arg: HeaderArg + :param x_plain_arg: + :type x_plain_arg: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._test_json_header_content_serialize( + x_json_arg=x_json_arg, + x_plain_arg=x_plain_arg, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '204': None, + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _test_json_header_content_serialize( + self, + x_json_arg, + x_plain_arg, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + if x_json_arg is not None: + _header_params['X-Json-Arg'] = json.dumps( + self.api_client.sanitize_for_serialization(x_json_arg) + ) + if x_plain_arg is not None: + _header_params['X-Plain-Arg'] = x_plain_arg + # process the form parameters + # process the body parameter + + + + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='POST', + resource_path='/test/json-header-content', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + @validate_call def test_object_for_multipart_requests( self, diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/__init__.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/__init__.py index 407cbf7cee53..cd5b0e8ca469 100644 --- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/__init__.py +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/__init__.py @@ -63,6 +63,7 @@ "FooGetDefaultResponse", "FormatTest", "HasOnlyReadOnly", + "HeaderArg", "HealthCheckResult", "HuntingDog", "Info", @@ -183,6 +184,7 @@ from petstore_api.models.foo_get_default_response import FooGetDefaultResponse from petstore_api.models.format_test import FormatTest from petstore_api.models.has_only_read_only import HasOnlyReadOnly + from petstore_api.models.header_arg import HeaderArg from petstore_api.models.health_check_result import HealthCheckResult from petstore_api.models.hunting_dog import HuntingDog from petstore_api.models.info import Info @@ -302,6 +304,7 @@ "FooGetDefaultResponse": ".foo_get_default_response", "FormatTest": ".format_test", "HasOnlyReadOnly": ".has_only_read_only", + "HeaderArg": ".header_arg", "HealthCheckResult": ".health_check_result", "HuntingDog": ".hunting_dog", "Info": ".info", diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/header_arg.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/header_arg.py new file mode 100644 index 000000000000..a9c6fc72c56a --- /dev/null +++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/header_arg.py @@ -0,0 +1,103 @@ +# 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: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictBool, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from typing import Optional, Set +from typing_extensions import Self +from pydantic_core import to_jsonable_python + +class HeaderArg(BaseModel): + """ + HeaderArg + """ # noqa: E501 + path: Optional[StrictStr] = None + recursive: Optional[StrictBool] = None + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["path", "recursive"] + + model_config = ConfigDict( + validate_by_name=True, + validate_by_alias=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(to_jsonable_python(self.to_dict())) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of HeaderArg from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of HeaderArg from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "path": obj.get("path"), + "recursive": obj.get("recursive") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/samples/openapi3/client/petstore/python-lazyImports/test/test_header_arg.py b/samples/openapi3/client/petstore/python-lazyImports/test/test_header_arg.py new file mode 100644 index 000000000000..f4577965fcce --- /dev/null +++ b/samples/openapi3/client/petstore/python-lazyImports/test/test_header_arg.py @@ -0,0 +1,52 @@ +# 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: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from petstore_api.models.header_arg import HeaderArg + +class TestHeaderArg(unittest.TestCase): + """HeaderArg unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> HeaderArg: + """Test HeaderArg + include_optional is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `HeaderArg` + """ + model = HeaderArg() + if include_optional: + return HeaderArg( + path = '', + recursive = True + ) + else: + return HeaderArg( + ) + """ + + def testHeaderArg(self): + """Test HeaderArg""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/.openapi-generator/FILES b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/.openapi-generator/FILES index 3bdfdd3eebd9..c2c1ad09f121 100644 --- a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/.openapi-generator/FILES +++ b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/.openapi-generator/FILES @@ -59,6 +59,7 @@ docs/Foo.md docs/FooGetDefaultResponse.md docs/FormatTest.md docs/HasOnlyReadOnly.md +docs/HeaderArg.md docs/HealthCheckResult.md docs/HuntingDog.md docs/ImportTestDatetimeApi.md @@ -193,6 +194,7 @@ petstore_api/models/foo.py petstore_api/models/foo_get_default_response.py petstore_api/models/format_test.py petstore_api/models/has_only_read_only.py +petstore_api/models/header_arg.py petstore_api/models/health_check_result.py petstore_api/models/hunting_dog.py petstore_api/models/info.py diff --git a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/README.md b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/README.md index 91f5fddf86c1..86b3becb86bb 100644 --- a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/README.md +++ b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/README.md @@ -121,6 +121,7 @@ Class | Method | HTTP request | Description *FakeApi* | [**test_inline_additional_properties**](docs/FakeApi.md#test_inline_additional_properties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties *FakeApi* | [**test_inline_freeform_additional_properties**](docs/FakeApi.md#test_inline_freeform_additional_properties) | **POST** /fake/inline-freeform-additionalProperties | test inline free-form additionalProperties *FakeApi* | [**test_json_form_data**](docs/FakeApi.md#test_json_form_data) | **GET** /fake/jsonFormData | test json serialization of form data +*FakeApi* | [**test_json_header_content**](docs/FakeApi.md#test_json_header_content) | **POST** /test/json-header-content | *FakeApi* | [**test_object_for_multipart_requests**](docs/FakeApi.md#test_object_for_multipart_requests) | **POST** /fake/object_for_multipart_requests | *FakeApi* | [**test_query_parameter_collection_format**](docs/FakeApi.md#test_query_parameter_collection_format) | **PUT** /fake/test-query-parameters | *FakeApi* | [**test_string_map_reference**](docs/FakeApi.md#test_string_map_reference) | **POST** /fake/stringMap-reference | test referenced string map @@ -204,6 +205,7 @@ Class | Method | HTTP request | Description - [FooGetDefaultResponse](docs/FooGetDefaultResponse.md) - [FormatTest](docs/FormatTest.md) - [HasOnlyReadOnly](docs/HasOnlyReadOnly.md) + - [HeaderArg](docs/HeaderArg.md) - [HealthCheckResult](docs/HealthCheckResult.md) - [HuntingDog](docs/HuntingDog.md) - [Info](docs/Info.md) diff --git a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/docs/FakeApi.md b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/docs/FakeApi.md index 6aa84ef041f1..0f68b53803e8 100644 --- a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/docs/FakeApi.md +++ b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/docs/FakeApi.md @@ -37,6 +37,7 @@ Method | HTTP request | Description [**test_inline_additional_properties**](FakeApi.md#test_inline_additional_properties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties [**test_inline_freeform_additional_properties**](FakeApi.md#test_inline_freeform_additional_properties) | **POST** /fake/inline-freeform-additionalProperties | test inline free-form additionalProperties [**test_json_form_data**](FakeApi.md#test_json_form_data) | **GET** /fake/jsonFormData | test json serialization of form data +[**test_json_header_content**](FakeApi.md#test_json_header_content) | **POST** /test/json-header-content | [**test_object_for_multipart_requests**](FakeApi.md#test_object_for_multipart_requests) | **POST** /fake/object_for_multipart_requests | [**test_query_parameter_collection_format**](FakeApi.md#test_query_parameter_collection_format) | **PUT** /fake/test-query-parameters | [**test_string_map_reference**](FakeApi.md#test_string_map_reference) | **POST** /fake/stringMap-reference | test referenced string map @@ -2286,6 +2287,72 @@ 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) +# **test_json_header_content** +> test_json_header_content(x_json_arg, x_plain_arg=x_plain_arg) + + + + + +### Example + +```python +import time +import os +import petstore_api +from petstore_api.models.header_arg import HeaderArg +from petstore_api.rest import ApiException +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 +async with petstore_api.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = petstore_api.FakeApi(api_client) + x_json_arg = petstore_api.HeaderArg() # HeaderArg | + x_plain_arg = 'x_plain_arg_example' # str | (optional) + + try: + await api_instance.test_json_header_content(x_json_arg, x_plain_arg=x_plain_arg) + except Exception as e: + print("Exception when calling FakeApi->test_json_header_content: %s\n" % e) +``` + + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **x_json_arg** | [**HeaderArg**](.md)| | + **x_plain_arg** | **str**| | [optional] + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**204** | No content | - | + +[[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) + # **test_object_for_multipart_requests** > test_object_for_multipart_requests(marker) diff --git a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/docs/HeaderArg.md b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/docs/HeaderArg.md new file mode 100644 index 000000000000..7e1594c57b3d --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/docs/HeaderArg.md @@ -0,0 +1,29 @@ +# HeaderArg + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**path** | **str** | | [optional] +**recursive** | **bool** | | [optional] + +## Example + +```python +from petstore_api.models.header_arg import HeaderArg + +# TODO update the JSON string below +json = "{}" +# create an instance of HeaderArg from a JSON string +header_arg_instance = HeaderArg.from_json(json) +# print the JSON string representation of the object +print HeaderArg.to_json() + +# convert the object into a dict +header_arg_dict = header_arg_instance.to_dict() +# create an instance of HeaderArg from a dict +header_arg_from_dict = HeaderArg.from_dict(header_arg_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/__init__.py b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/__init__.py index e89049d66426..ed391cc674af 100644 --- a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/__init__.py +++ b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/__init__.py @@ -88,6 +88,7 @@ "FooGetDefaultResponse", "FormatTest", "HasOnlyReadOnly", + "HeaderArg", "HealthCheckResult", "HuntingDog", "Info", @@ -227,6 +228,7 @@ from petstore_api.models.foo_get_default_response import FooGetDefaultResponse as FooGetDefaultResponse from petstore_api.models.format_test import FormatTest as FormatTest from petstore_api.models.has_only_read_only import HasOnlyReadOnly as HasOnlyReadOnly +from petstore_api.models.header_arg import HeaderArg as HeaderArg from petstore_api.models.health_check_result import HealthCheckResult as HealthCheckResult from petstore_api.models.hunting_dog import HuntingDog as HuntingDog from petstore_api.models.info import Info as Info diff --git a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/api/fake_api.py b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/api/fake_api.py index 7ee53259a5b9..a67bdd48a97a 100644 --- a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/api/fake_api.py +++ b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/api/fake_api.py @@ -30,6 +30,7 @@ from petstore_api.models.client import Client from petstore_api.models.enum_class import EnumClass from petstore_api.models.file_schema_test_class import FileSchemaTestClass +from petstore_api.models.header_arg import HeaderArg from petstore_api.models.health_check_result import HealthCheckResult from petstore_api.models.outer_composite import OuterComposite from petstore_api.models.outer_enum_integer import OuterEnumInteger @@ -4246,6 +4247,130 @@ async def test_json_form_data_with_http_info(self, param : Annotated[StrictStr, collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) + @validate_arguments + async def test_json_header_content(self, x_json_arg : HeaderArg, x_plain_arg : Optional[StrictStr] = None, **kwargs) -> None: # noqa: E501 + """test_json_header_content # noqa: E501 + + + :param x_json_arg: (required) + :type x_json_arg: HeaderArg + :param x_plain_arg: + :type x_plain_arg: str + :param _request_timeout: timeout setting for this request. + If one number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: None + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + message = "Error! Please call the test_json_header_content_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 + raise ValueError(message) + return await self.test_json_header_content_with_http_info(x_json_arg, x_plain_arg, **kwargs) # noqa: E501 + + @validate_arguments + async def test_json_header_content_with_http_info(self, x_json_arg : HeaderArg, x_plain_arg : Optional[StrictStr] = None, **kwargs) -> ApiResponse: # noqa: E501 + """test_json_header_content # noqa: E501 + + + :param x_json_arg: (required) + :type x_json_arg: HeaderArg + :param x_plain_arg: + :type x_plain_arg: str + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_auth: dict, optional + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: None + """ + + _params = locals() + + _all_params = [ + 'x_json_arg', + 'x_plain_arg' + ] + _all_params.extend( + [ + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method test_json_header_content" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + + # process the query parameters + _query_params = [] + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + if _params['x_json_arg'] is not None: + _header_params['X-Json-Arg'] = _params['x_json_arg'] + + if _params['x_plain_arg'] is not None: + _header_params['X-Plain-Arg'] = _params['x_plain_arg'] + + # process the form parameters + _form_params = [] + _files = {} + # process the body parameter + _body_params = None + # authentication setting + _auth_settings = [] # noqa: E501 + + _response_types_map = {} + + return await self.api_client.call_api( + '/test/json-header-content', 'POST', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) + @validate_arguments async def test_object_for_multipart_requests(self, marker : TestObjectForMultipartRequestsRequestMarker, **kwargs) -> None: # noqa: E501 """test_object_for_multipart_requests # noqa: E501 diff --git a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/models/__init__.py b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/models/__init__.py index 51cf981e4b26..1f1469015ee0 100644 --- a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/models/__init__.py +++ b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/models/__init__.py @@ -66,6 +66,7 @@ from petstore_api.models.foo_get_default_response import FooGetDefaultResponse from petstore_api.models.format_test import FormatTest from petstore_api.models.has_only_read_only import HasOnlyReadOnly +from petstore_api.models.header_arg import HeaderArg from petstore_api.models.health_check_result import HealthCheckResult from petstore_api.models.hunting_dog import HuntingDog from petstore_api.models.info import Info diff --git a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/models/header_arg.py b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/models/header_arg.py new file mode 100644 index 000000000000..7fb4aa17fa7f --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/models/header_arg.py @@ -0,0 +1,73 @@ +# 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: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Optional +from pydantic import BaseModel, StrictBool, StrictStr + +class HeaderArg(BaseModel): + """ + HeaderArg + """ + path: Optional[StrictStr] = None + recursive: Optional[StrictBool] = None + __properties = ["path", "recursive"] + + class Config: + """Pydantic configuration""" + allow_population_by_field_name = True + validate_assignment = True + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> HeaderArg: + """Create an instance of HeaderArg from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + }, + exclude_none=True) + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> HeaderArg: + """Create an instance of HeaderArg from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return HeaderArg.parse_obj(obj) + + _obj = HeaderArg.parse_obj({ + "path": obj.get("path"), + "recursive": obj.get("recursive") + }) + return _obj + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/test/test_header_arg.py b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/test/test_header_arg.py new file mode 100644 index 000000000000..22b3d39c88d1 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/test/test_header_arg.py @@ -0,0 +1,53 @@ +# 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: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest +import datetime + +from petstore_api.models.header_arg import HeaderArg # noqa: E501 + +class TestHeaderArg(unittest.TestCase): + """HeaderArg unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> HeaderArg: + """Test HeaderArg + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `HeaderArg` + """ + model = HeaderArg() # noqa: E501 + if include_optional: + return HeaderArg( + path = '', + recursive = True + ) + else: + return HeaderArg( + ) + """ + + def testHeaderArg(self): + """Test HeaderArg""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v1/.openapi-generator/FILES b/samples/openapi3/client/petstore/python-pydantic-v1/.openapi-generator/FILES index 3bdfdd3eebd9..c2c1ad09f121 100644 --- a/samples/openapi3/client/petstore/python-pydantic-v1/.openapi-generator/FILES +++ b/samples/openapi3/client/petstore/python-pydantic-v1/.openapi-generator/FILES @@ -59,6 +59,7 @@ docs/Foo.md docs/FooGetDefaultResponse.md docs/FormatTest.md docs/HasOnlyReadOnly.md +docs/HeaderArg.md docs/HealthCheckResult.md docs/HuntingDog.md docs/ImportTestDatetimeApi.md @@ -193,6 +194,7 @@ petstore_api/models/foo.py petstore_api/models/foo_get_default_response.py petstore_api/models/format_test.py petstore_api/models/has_only_read_only.py +petstore_api/models/header_arg.py petstore_api/models/health_check_result.py petstore_api/models/hunting_dog.py petstore_api/models/info.py diff --git a/samples/openapi3/client/petstore/python-pydantic-v1/README.md b/samples/openapi3/client/petstore/python-pydantic-v1/README.md index df20391210ef..e2ad40592c8f 100644 --- a/samples/openapi3/client/petstore/python-pydantic-v1/README.md +++ b/samples/openapi3/client/petstore/python-pydantic-v1/README.md @@ -121,6 +121,7 @@ Class | Method | HTTP request | Description *FakeApi* | [**test_inline_additional_properties**](docs/FakeApi.md#test_inline_additional_properties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties *FakeApi* | [**test_inline_freeform_additional_properties**](docs/FakeApi.md#test_inline_freeform_additional_properties) | **POST** /fake/inline-freeform-additionalProperties | test inline free-form additionalProperties *FakeApi* | [**test_json_form_data**](docs/FakeApi.md#test_json_form_data) | **GET** /fake/jsonFormData | test json serialization of form data +*FakeApi* | [**test_json_header_content**](docs/FakeApi.md#test_json_header_content) | **POST** /test/json-header-content | *FakeApi* | [**test_object_for_multipart_requests**](docs/FakeApi.md#test_object_for_multipart_requests) | **POST** /fake/object_for_multipart_requests | *FakeApi* | [**test_query_parameter_collection_format**](docs/FakeApi.md#test_query_parameter_collection_format) | **PUT** /fake/test-query-parameters | *FakeApi* | [**test_string_map_reference**](docs/FakeApi.md#test_string_map_reference) | **POST** /fake/stringMap-reference | test referenced string map @@ -204,6 +205,7 @@ Class | Method | HTTP request | Description - [FooGetDefaultResponse](docs/FooGetDefaultResponse.md) - [FormatTest](docs/FormatTest.md) - [HasOnlyReadOnly](docs/HasOnlyReadOnly.md) + - [HeaderArg](docs/HeaderArg.md) - [HealthCheckResult](docs/HealthCheckResult.md) - [HuntingDog](docs/HuntingDog.md) - [Info](docs/Info.md) diff --git a/samples/openapi3/client/petstore/python-pydantic-v1/docs/FakeApi.md b/samples/openapi3/client/petstore/python-pydantic-v1/docs/FakeApi.md index 6935c8587a23..22fbdf54ab53 100644 --- a/samples/openapi3/client/petstore/python-pydantic-v1/docs/FakeApi.md +++ b/samples/openapi3/client/petstore/python-pydantic-v1/docs/FakeApi.md @@ -37,6 +37,7 @@ Method | HTTP request | Description [**test_inline_additional_properties**](FakeApi.md#test_inline_additional_properties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties [**test_inline_freeform_additional_properties**](FakeApi.md#test_inline_freeform_additional_properties) | **POST** /fake/inline-freeform-additionalProperties | test inline free-form additionalProperties [**test_json_form_data**](FakeApi.md#test_json_form_data) | **GET** /fake/jsonFormData | test json serialization of form data +[**test_json_header_content**](FakeApi.md#test_json_header_content) | **POST** /test/json-header-content | [**test_object_for_multipart_requests**](FakeApi.md#test_object_for_multipart_requests) | **POST** /fake/object_for_multipart_requests | [**test_query_parameter_collection_format**](FakeApi.md#test_query_parameter_collection_format) | **PUT** /fake/test-query-parameters | [**test_string_map_reference**](FakeApi.md#test_string_map_reference) | **POST** /fake/stringMap-reference | test referenced string map @@ -2286,6 +2287,72 @@ 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) +# **test_json_header_content** +> test_json_header_content(x_json_arg, x_plain_arg=x_plain_arg) + + + + + +### Example + +```python +import time +import os +import petstore_api +from petstore_api.models.header_arg import HeaderArg +from petstore_api.rest import ApiException +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 = petstore_api.FakeApi(api_client) + x_json_arg = petstore_api.HeaderArg() # HeaderArg | + x_plain_arg = 'x_plain_arg_example' # str | (optional) + + try: + api_instance.test_json_header_content(x_json_arg, x_plain_arg=x_plain_arg) + except Exception as e: + print("Exception when calling FakeApi->test_json_header_content: %s\n" % e) +``` + + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **x_json_arg** | [**HeaderArg**](.md)| | + **x_plain_arg** | **str**| | [optional] + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**204** | No content | - | + +[[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) + # **test_object_for_multipart_requests** > test_object_for_multipart_requests(marker) diff --git a/samples/openapi3/client/petstore/python-pydantic-v1/docs/HeaderArg.md b/samples/openapi3/client/petstore/python-pydantic-v1/docs/HeaderArg.md new file mode 100644 index 000000000000..7e1594c57b3d --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1/docs/HeaderArg.md @@ -0,0 +1,29 @@ +# HeaderArg + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**path** | **str** | | [optional] +**recursive** | **bool** | | [optional] + +## Example + +```python +from petstore_api.models.header_arg import HeaderArg + +# TODO update the JSON string below +json = "{}" +# create an instance of HeaderArg from a JSON string +header_arg_instance = HeaderArg.from_json(json) +# print the JSON string representation of the object +print HeaderArg.to_json() + +# convert the object into a dict +header_arg_dict = header_arg_instance.to_dict() +# create an instance of HeaderArg from a dict +header_arg_from_dict = HeaderArg.from_dict(header_arg_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/__init__.py b/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/__init__.py index e89049d66426..ed391cc674af 100644 --- a/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/__init__.py +++ b/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/__init__.py @@ -88,6 +88,7 @@ "FooGetDefaultResponse", "FormatTest", "HasOnlyReadOnly", + "HeaderArg", "HealthCheckResult", "HuntingDog", "Info", @@ -227,6 +228,7 @@ from petstore_api.models.foo_get_default_response import FooGetDefaultResponse as FooGetDefaultResponse from petstore_api.models.format_test import FormatTest as FormatTest from petstore_api.models.has_only_read_only import HasOnlyReadOnly as HasOnlyReadOnly +from petstore_api.models.header_arg import HeaderArg as HeaderArg from petstore_api.models.health_check_result import HealthCheckResult as HealthCheckResult from petstore_api.models.hunting_dog import HuntingDog as HuntingDog from petstore_api.models.info import Info as Info diff --git a/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/api/fake_api.py b/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/api/fake_api.py index 62ef06ed6b0e..6e617e6df04e 100644 --- a/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/api/fake_api.py +++ b/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/api/fake_api.py @@ -29,6 +29,7 @@ from petstore_api.models.client import Client from petstore_api.models.enum_class import EnumClass from petstore_api.models.file_schema_test_class import FileSchemaTestClass +from petstore_api.models.header_arg import HeaderArg from petstore_api.models.health_check_result import HealthCheckResult from petstore_api.models.outer_composite import OuterComposite from petstore_api.models.outer_enum_integer import OuterEnumInteger @@ -4773,6 +4774,146 @@ def test_json_form_data_with_http_info(self, param : Annotated[StrictStr, Field( collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) + @validate_arguments + def test_json_header_content(self, x_json_arg : HeaderArg, x_plain_arg : Optional[StrictStr] = None, **kwargs) -> None: # noqa: E501 + """test_json_header_content # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.test_json_header_content(x_json_arg, x_plain_arg, async_req=True) + >>> result = thread.get() + + :param x_json_arg: (required) + :type x_json_arg: HeaderArg + :param x_plain_arg: + :type x_plain_arg: str + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _request_timeout: timeout setting for this request. + If one number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: None + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + message = "Error! Please call the test_json_header_content_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 + raise ValueError(message) + return self.test_json_header_content_with_http_info(x_json_arg, x_plain_arg, **kwargs) # noqa: E501 + + @validate_arguments + def test_json_header_content_with_http_info(self, x_json_arg : HeaderArg, x_plain_arg : Optional[StrictStr] = None, **kwargs) -> ApiResponse: # noqa: E501 + """test_json_header_content # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.test_json_header_content_with_http_info(x_json_arg, x_plain_arg, async_req=True) + >>> result = thread.get() + + :param x_json_arg: (required) + :type x_json_arg: HeaderArg + :param x_plain_arg: + :type x_plain_arg: str + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_auth: dict, optional + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: None + """ + + _params = locals() + + _all_params = [ + 'x_json_arg', + 'x_plain_arg' + ] + _all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method test_json_header_content" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + + # process the query parameters + _query_params = [] + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + if _params['x_json_arg'] is not None: + _header_params['X-Json-Arg'] = _params['x_json_arg'] + + if _params['x_plain_arg'] is not None: + _header_params['X-Plain-Arg'] = _params['x_plain_arg'] + + # process the form parameters + _form_params = [] + _files = {} + # process the body parameter + _body_params = None + # authentication setting + _auth_settings = [] # noqa: E501 + + _response_types_map = {} + + return self.api_client.call_api( + '/test/json-header-content', 'POST', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + async_req=_params.get('async_req'), + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) + @validate_arguments def test_object_for_multipart_requests(self, marker : TestObjectForMultipartRequestsRequestMarker, **kwargs) -> None: # noqa: E501 """test_object_for_multipart_requests # noqa: E501 diff --git a/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/models/__init__.py b/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/models/__init__.py index 51cf981e4b26..1f1469015ee0 100644 --- a/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/models/__init__.py +++ b/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/models/__init__.py @@ -66,6 +66,7 @@ from petstore_api.models.foo_get_default_response import FooGetDefaultResponse from petstore_api.models.format_test import FormatTest from petstore_api.models.has_only_read_only import HasOnlyReadOnly +from petstore_api.models.header_arg import HeaderArg from petstore_api.models.health_check_result import HealthCheckResult from petstore_api.models.hunting_dog import HuntingDog from petstore_api.models.info import Info diff --git a/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/models/header_arg.py b/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/models/header_arg.py new file mode 100644 index 000000000000..a070e330a651 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/models/header_arg.py @@ -0,0 +1,85 @@ +# 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: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Any, Dict, Optional +from pydantic import BaseModel, StrictBool, StrictStr + +class HeaderArg(BaseModel): + """ + HeaderArg + """ + path: Optional[StrictStr] = None + recursive: Optional[StrictBool] = None + additional_properties: Dict[str, Any] = {} + __properties = ["path", "recursive"] + + class Config: + """Pydantic configuration""" + allow_population_by_field_name = True + validate_assignment = True + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> HeaderArg: + """Create an instance of HeaderArg from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + "additional_properties" + }, + exclude_none=True) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> HeaderArg: + """Create an instance of HeaderArg from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return HeaderArg.parse_obj(obj) + + _obj = HeaderArg.parse_obj({ + "path": obj.get("path"), + "recursive": obj.get("recursive") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v1/test/test_header_arg.py b/samples/openapi3/client/petstore/python-pydantic-v1/test/test_header_arg.py new file mode 100644 index 000000000000..22b3d39c88d1 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1/test/test_header_arg.py @@ -0,0 +1,53 @@ +# 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: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest +import datetime + +from petstore_api.models.header_arg import HeaderArg # noqa: E501 + +class TestHeaderArg(unittest.TestCase): + """HeaderArg unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> HeaderArg: + """Test HeaderArg + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `HeaderArg` + """ + model = HeaderArg() # noqa: E501 + if include_optional: + return HeaderArg( + path = '', + recursive = True + ) + else: + return HeaderArg( + ) + """ + + def testHeaderArg(self): + """Test HeaderArg""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python/.openapi-generator/FILES b/samples/openapi3/client/petstore/python/.openapi-generator/FILES index 1eb565d74f11..d808742215cb 100755 --- a/samples/openapi3/client/petstore/python/.openapi-generator/FILES +++ b/samples/openapi3/client/petstore/python/.openapi-generator/FILES @@ -57,6 +57,7 @@ docs/Foo.md docs/FooGetDefaultResponse.md docs/FormatTest.md docs/HasOnlyReadOnly.md +docs/HeaderArg.md docs/HealthCheckResult.md docs/HuntingDog.md docs/ImportTestDatetimeApi.md @@ -191,6 +192,7 @@ petstore_api/models/foo.py petstore_api/models/foo_get_default_response.py petstore_api/models/format_test.py petstore_api/models/has_only_read_only.py +petstore_api/models/header_arg.py petstore_api/models/health_check_result.py petstore_api/models/hunting_dog.py petstore_api/models/info.py diff --git a/samples/openapi3/client/petstore/python/README.md b/samples/openapi3/client/petstore/python/README.md index 5a3798c1b20a..8b8090a64c7e 100755 --- a/samples/openapi3/client/petstore/python/README.md +++ b/samples/openapi3/client/petstore/python/README.md @@ -125,6 +125,7 @@ Class | Method | HTTP request | Description *FakeApi* | [**test_inline_additional_properties**](docs/FakeApi.md#test_inline_additional_properties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties *FakeApi* | [**test_inline_freeform_additional_properties**](docs/FakeApi.md#test_inline_freeform_additional_properties) | **POST** /fake/inline-freeform-additionalProperties | test inline free-form additionalProperties *FakeApi* | [**test_json_form_data**](docs/FakeApi.md#test_json_form_data) | **GET** /fake/jsonFormData | test json serialization of form data +*FakeApi* | [**test_json_header_content**](docs/FakeApi.md#test_json_header_content) | **POST** /test/json-header-content | *FakeApi* | [**test_object_for_multipart_requests**](docs/FakeApi.md#test_object_for_multipart_requests) | **POST** /fake/object_for_multipart_requests | *FakeApi* | [**test_query_parameter_collection_format**](docs/FakeApi.md#test_query_parameter_collection_format) | **PUT** /fake/test-query-parameters | *FakeApi* | [**test_string_map_reference**](docs/FakeApi.md#test_string_map_reference) | **POST** /fake/stringMap-reference | test referenced string map @@ -206,6 +207,7 @@ Class | Method | HTTP request | Description - [FooGetDefaultResponse](docs/FooGetDefaultResponse.md) - [FormatTest](docs/FormatTest.md) - [HasOnlyReadOnly](docs/HasOnlyReadOnly.md) + - [HeaderArg](docs/HeaderArg.md) - [HealthCheckResult](docs/HealthCheckResult.md) - [HuntingDog](docs/HuntingDog.md) - [Info](docs/Info.md) diff --git a/samples/openapi3/client/petstore/python/docs/FakeApi.md b/samples/openapi3/client/petstore/python/docs/FakeApi.md index 813bc5e71df5..16f36a568f2f 100644 --- a/samples/openapi3/client/petstore/python/docs/FakeApi.md +++ b/samples/openapi3/client/petstore/python/docs/FakeApi.md @@ -37,6 +37,7 @@ Method | HTTP request | Description [**test_inline_additional_properties**](FakeApi.md#test_inline_additional_properties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties [**test_inline_freeform_additional_properties**](FakeApi.md#test_inline_freeform_additional_properties) | **POST** /fake/inline-freeform-additionalProperties | test inline free-form additionalProperties [**test_json_form_data**](FakeApi.md#test_json_form_data) | **GET** /fake/jsonFormData | test json serialization of form data +[**test_json_header_content**](FakeApi.md#test_json_header_content) | **POST** /test/json-header-content | [**test_object_for_multipart_requests**](FakeApi.md#test_object_for_multipart_requests) | **POST** /fake/object_for_multipart_requests | [**test_query_parameter_collection_format**](FakeApi.md#test_query_parameter_collection_format) | **PUT** /fake/test-query-parameters | [**test_string_map_reference**](FakeApi.md#test_string_map_reference) | **POST** /fake/stringMap-reference | test referenced string map @@ -2265,6 +2266,69 @@ 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) +# **test_json_header_content** +> test_json_header_content(x_json_arg, x_plain_arg=x_plain_arg) + +### Example + + +```python +import petstore_api +from petstore_api.models.header_arg import HeaderArg +from petstore_api.rest import ApiException +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 = petstore_api.FakeApi(api_client) + x_json_arg = petstore_api.HeaderArg() # HeaderArg | + x_plain_arg = 'x_plain_arg_example' # str | (optional) + + try: + api_instance.test_json_header_content(x_json_arg, x_plain_arg=x_plain_arg) + except Exception as e: + print("Exception when calling FakeApi->test_json_header_content: %s\n" % e) +``` + + + +### Parameters + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **x_json_arg** | [**HeaderArg**](.md)| | + **x_plain_arg** | **str**| | [optional] + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + +### HTTP response details + +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**204** | No content | - | + +[[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) + # **test_object_for_multipart_requests** > test_object_for_multipart_requests(marker) diff --git a/samples/openapi3/client/petstore/python/docs/HeaderArg.md b/samples/openapi3/client/petstore/python/docs/HeaderArg.md new file mode 100644 index 000000000000..e38f4d753d6d --- /dev/null +++ b/samples/openapi3/client/petstore/python/docs/HeaderArg.md @@ -0,0 +1,30 @@ +# HeaderArg + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**path** | **str** | | [optional] +**recursive** | **bool** | | [optional] + +## Example + +```python +from petstore_api.models.header_arg import HeaderArg + +# TODO update the JSON string below +json = "{}" +# create an instance of HeaderArg from a JSON string +header_arg_instance = HeaderArg.from_json(json) +# print the JSON string representation of the object +print(HeaderArg.to_json()) + +# convert the object into a dict +header_arg_dict = header_arg_instance.to_dict() +# create an instance of HeaderArg from a dict +header_arg_from_dict = HeaderArg.from_dict(header_arg_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/python/petstore_api/__init__.py b/samples/openapi3/client/petstore/python/petstore_api/__init__.py index c7f461775f59..55be0097b9d0 100755 --- a/samples/openapi3/client/petstore/python/petstore_api/__init__.py +++ b/samples/openapi3/client/petstore/python/petstore_api/__init__.py @@ -86,6 +86,7 @@ "FooGetDefaultResponse", "FormatTest", "HasOnlyReadOnly", + "HeaderArg", "HealthCheckResult", "HuntingDog", "Info", @@ -225,6 +226,7 @@ from petstore_api.models.foo_get_default_response import FooGetDefaultResponse as FooGetDefaultResponse from petstore_api.models.format_test import FormatTest as FormatTest from petstore_api.models.has_only_read_only import HasOnlyReadOnly as HasOnlyReadOnly +from petstore_api.models.header_arg import HeaderArg as HeaderArg from petstore_api.models.health_check_result import HealthCheckResult as HealthCheckResult from petstore_api.models.hunting_dog import HuntingDog as HuntingDog from petstore_api.models.info import Info as Info diff --git a/samples/openapi3/client/petstore/python/petstore_api/api/fake_api.py b/samples/openapi3/client/petstore/python/petstore_api/api/fake_api.py index 0605972caae5..fca5d8161a3d 100755 --- a/samples/openapi3/client/petstore/python/petstore_api/api/fake_api.py +++ b/samples/openapi3/client/petstore/python/petstore_api/api/fake_api.py @@ -10,6 +10,7 @@ """ # noqa: E501 +import json import warnings from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt from typing import Any, Dict, List, Optional, Tuple, Union @@ -23,6 +24,7 @@ from petstore_api.models.client import Client from petstore_api.models.enum_class import EnumClass from petstore_api.models.file_schema_test_class import FileSchemaTestClass +from petstore_api.models.header_arg import HeaderArg from petstore_api.models.health_check_result import HealthCheckResult from petstore_api.models.model_api_response import ModelApiResponse from petstore_api.models.outer_composite import OuterComposite @@ -8925,6 +8927,273 @@ def _test_json_form_data_serialize( + @validate_call + def test_json_header_content( + self, + x_json_arg: HeaderArg, + x_plain_arg: Optional[StrictStr] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> None: + """test_json_header_content + + + :param x_json_arg: (required) + :type x_json_arg: HeaderArg + :param x_plain_arg: + :type x_plain_arg: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._test_json_header_content_serialize( + x_json_arg=x_json_arg, + x_plain_arg=x_plain_arg, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '204': None, + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def test_json_header_content_with_http_info( + self, + x_json_arg: HeaderArg, + x_plain_arg: Optional[StrictStr] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[None]: + """test_json_header_content + + + :param x_json_arg: (required) + :type x_json_arg: HeaderArg + :param x_plain_arg: + :type x_plain_arg: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._test_json_header_content_serialize( + x_json_arg=x_json_arg, + x_plain_arg=x_plain_arg, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '204': None, + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def test_json_header_content_without_preload_content( + self, + x_json_arg: HeaderArg, + x_plain_arg: Optional[StrictStr] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """test_json_header_content + + + :param x_json_arg: (required) + :type x_json_arg: HeaderArg + :param x_plain_arg: + :type x_plain_arg: str + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._test_json_header_content_serialize( + x_json_arg=x_json_arg, + x_plain_arg=x_plain_arg, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '204': None, + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _test_json_header_content_serialize( + self, + x_json_arg, + x_plain_arg, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[ + str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + if x_json_arg is not None: + _header_params['X-Json-Arg'] = json.dumps( + self.api_client.sanitize_for_serialization(x_json_arg) + ) + if x_plain_arg is not None: + _header_params['X-Plain-Arg'] = x_plain_arg + # process the form parameters + # process the body parameter + + + + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='POST', + resource_path='/test/json-header-content', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + @validate_call def test_object_for_multipart_requests( self, diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/__init__.py b/samples/openapi3/client/petstore/python/petstore_api/models/__init__.py index 308e6dfc3ebb..488a82150d32 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/__init__.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/__init__.py @@ -63,6 +63,7 @@ from petstore_api.models.foo_get_default_response import FooGetDefaultResponse from petstore_api.models.format_test import FormatTest from petstore_api.models.has_only_read_only import HasOnlyReadOnly +from petstore_api.models.header_arg import HeaderArg from petstore_api.models.health_check_result import HealthCheckResult from petstore_api.models.hunting_dog import HuntingDog from petstore_api.models.info import Info diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/header_arg.py b/samples/openapi3/client/petstore/python/petstore_api/models/header_arg.py new file mode 100644 index 000000000000..a9c6fc72c56a --- /dev/null +++ b/samples/openapi3/client/petstore/python/petstore_api/models/header_arg.py @@ -0,0 +1,103 @@ +# 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: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictBool, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from typing import Optional, Set +from typing_extensions import Self +from pydantic_core import to_jsonable_python + +class HeaderArg(BaseModel): + """ + HeaderArg + """ # noqa: E501 + path: Optional[StrictStr] = None + recursive: Optional[StrictBool] = None + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["path", "recursive"] + + model_config = ConfigDict( + validate_by_name=True, + validate_by_alias=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(to_jsonable_python(self.to_dict())) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of HeaderArg from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of HeaderArg from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "path": obj.get("path"), + "recursive": obj.get("recursive") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/samples/openapi3/client/petstore/python/test/test_header_arg.py b/samples/openapi3/client/petstore/python/test/test_header_arg.py new file mode 100644 index 000000000000..f4577965fcce --- /dev/null +++ b/samples/openapi3/client/petstore/python/test/test_header_arg.py @@ -0,0 +1,52 @@ +# 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: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from petstore_api.models.header_arg import HeaderArg + +class TestHeaderArg(unittest.TestCase): + """HeaderArg unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> HeaderArg: + """Test HeaderArg + include_optional is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `HeaderArg` + """ + model = HeaderArg() + if include_optional: + return HeaderArg( + path = '', + recursive = True + ) + else: + return HeaderArg( + ) + """ + + def testHeaderArg(self): + """Test HeaderArg""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main()