From 927bfa481f6d12ff2470ea0996a3707ad8fb8cc6 Mon Sep 17 00:00:00 2001 From: devhl-labs Date: Tue, 7 Feb 2023 08:54:20 -0500 Subject: [PATCH] Inline allOf parameters are always not required (#14278) * fixed the issue * added comment --- .../openapitools/codegen/DefaultCodegen.java | 3 + ...odels-for-testing-with-http-signature.yaml | 17 ++ .../README.md | 1 + .../docs/DefaultApi.md | 84 ++++++++ .../src/Org.OpenAPITools/Api/DefaultApi.cs | 187 +++++++++++++++++ .../docs/apis/DefaultApi.md | 84 ++++++++ .../src/Org.OpenAPITools/Api/DefaultApi.cs | 189 ++++++++++++++++++ .../docs/apis/DefaultApi.md | 84 ++++++++ .../src/Org.OpenAPITools/Api/DefaultApi.cs | 178 +++++++++++++++++ .../docs/apis/DefaultApi.md | 84 ++++++++ .../src/Org.OpenAPITools/Api/DefaultApi.cs | 178 +++++++++++++++++ .../OpenAPIClient-httpclient/README.md | 1 + .../docs/DefaultApi.md | 88 ++++++++ .../src/Org.OpenAPITools/Api/DefaultApi.cs | 154 ++++++++++++++ .../OpenAPIClient-net47/README.md | 1 + .../OpenAPIClient-net47/docs/DefaultApi.md | 84 ++++++++ .../src/Org.OpenAPITools/Api/DefaultApi.cs | 187 +++++++++++++++++ .../OpenAPIClient-net48/README.md | 1 + .../OpenAPIClient-net48/docs/DefaultApi.md | 84 ++++++++ .../src/Org.OpenAPITools/Api/DefaultApi.cs | 187 +++++++++++++++++ .../OpenAPIClient-net5.0/README.md | 1 + .../OpenAPIClient-net5.0/docs/DefaultApi.md | 84 ++++++++ .../src/Org.OpenAPITools/Api/DefaultApi.cs | 187 +++++++++++++++++ .../csharp-netcore/OpenAPIClient/README.md | 1 + .../OpenAPIClient/docs/DefaultApi.md | 84 ++++++++ .../src/Org.OpenAPITools/Api/DefaultApi.cs | 187 +++++++++++++++++ .../OpenAPIClientCore/README.md | 1 + .../OpenAPIClientCore/docs/DefaultApi.md | 84 ++++++++ .../src/Org.OpenAPITools/Api/DefaultApi.cs | 187 +++++++++++++++++ 29 files changed, 2692 insertions(+) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java index eb3c227d125..f198bb1c8ae 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java @@ -6722,6 +6722,9 @@ public class DefaultCodegen implements CodegenConfig { // Set 'required' flag defined in the schema element if (!codegenParameter.required && schema.getRequired() != null) { codegenParameter.required = schema.getRequired().contains(entry.getKey()); + } else if (!codegenParameter.required) { + // Set 'required' flag for properties declared inside the allOf + codegenParameter.required = allRequired.stream().anyMatch(r -> r.equals(codegenParameter.paramName)); } parameters.add(codegenParameter); diff --git a/modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml b/modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml index ff40f507720..8a003841821 100644 --- a/modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml @@ -1117,6 +1117,23 @@ paths: application/json: schema: $ref: '#/components/schemas/ArrayOfEnums' + /country: + post: + operationId: getCountry + requestBody: + content: + application/x-www-form-urlencoded: + schema: + allOf: + - required: + - country + type: object + properties: + country: + type: string + responses: + '200': + description: OK servers: - url: 'http://{server}.swagger.io:{port}/v2' description: petstore server diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-ConditionalSerialization/README.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-ConditionalSerialization/README.md index bff23f31e56..cf4a21009f8 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-ConditionalSerialization/README.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-ConditionalSerialization/README.md @@ -105,6 +105,7 @@ Class | Method | HTTP request | Description ------------ | ------------- | ------------- | ------------- *AnotherFakeApi* | [**Call123TestSpecialTags**](docs/AnotherFakeApi.md#call123testspecialtags) | **PATCH** /another-fake/dummy | To test special tags *DefaultApi* | [**FooGet**](docs/DefaultApi.md#fooget) | **GET** /foo | +*DefaultApi* | [**GetCountry**](docs/DefaultApi.md#getcountry) | **POST** /country | *FakeApi* | [**FakeHealthGet**](docs/FakeApi.md#fakehealthget) | **GET** /fake/health | Health check endpoint *FakeApi* | [**FakeOuterBooleanSerialize**](docs/FakeApi.md#fakeouterbooleanserialize) | **POST** /fake/outer/boolean | *FakeApi* | [**FakeOuterCompositeSerialize**](docs/FakeApi.md#fakeoutercompositeserialize) | **POST** /fake/outer/composite | diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-ConditionalSerialization/docs/DefaultApi.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-ConditionalSerialization/docs/DefaultApi.md index 3a93305e15b..265fec1a6f9 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-ConditionalSerialization/docs/DefaultApi.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-ConditionalSerialization/docs/DefaultApi.md @@ -5,6 +5,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* | Method | HTTP request | Description | |--------|--------------|-------------| | [**FooGet**](DefaultApi.md#fooget) | **GET** /foo | | +| [**GetCountry**](DefaultApi.md#getcountry) | **POST** /country | | # **FooGet** @@ -88,3 +89,86 @@ 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) + +# **GetCountry** +> void GetCountry (string country) + + + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class GetCountryExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new DefaultApi(config); + var country = "country_example"; // string | + + try + { + apiInstance.GetCountry(country); + } + catch (ApiException e) + { + Debug.Print("Exception when calling DefaultApi.GetCountry: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the GetCountryWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + apiInstance.GetCountryWithHttpInfo(country); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling DefaultApi.GetCountryWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **country** | **string** | | | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/x-www-form-urlencoded + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | OK | - | + +[[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) + diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Api/DefaultApi.cs index bc5b5556d25..0ae306612df 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -45,6 +45,26 @@ namespace Org.OpenAPITools.Api /// Index associated with the operation. /// ApiResponse of FooGetDefaultResponse ApiResponse FooGetWithHttpInfo(int operationIndex = 0); + /// + /// + /// + /// Thrown when fails to make API call + /// + /// Index associated with the operation. + /// + void GetCountry(string country, int operationIndex = 0); + + /// + /// + /// + /// + /// + /// + /// Thrown when fails to make API call + /// + /// Index associated with the operation. + /// ApiResponse of Object(void) + ApiResponse GetCountryWithHttpInfo(string country, int operationIndex = 0); #endregion Synchronous Operations } @@ -77,6 +97,31 @@ namespace Org.OpenAPITools.Api /// Cancellation Token to cancel the request. /// Task of ApiResponse (FooGetDefaultResponse) System.Threading.Tasks.Task> FooGetWithHttpInfoAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + /// + /// + /// + /// + /// + /// + /// Thrown when fails to make API call + /// + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of void + System.Threading.Tasks.Task GetCountryAsync(string country, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + + /// + /// + /// + /// + /// + /// + /// Thrown when fails to make API call + /// + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of ApiResponse + System.Threading.Tasks.Task> GetCountryWithHttpInfoAsync(string country, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); #endregion Asynchronous Operations } @@ -323,5 +368,147 @@ namespace Org.OpenAPITools.Api return localVarResponse; } + /// + /// + /// + /// Thrown when fails to make API call + /// + /// Index associated with the operation. + /// + public void GetCountry(string country, int operationIndex = 0) + { + GetCountryWithHttpInfo(country); + } + + /// + /// + /// + /// Thrown when fails to make API call + /// + /// Index associated with the operation. + /// ApiResponse of Object(void) + public Org.OpenAPITools.Client.ApiResponse GetCountryWithHttpInfo(string country, int operationIndex = 0) + { + // verify the required parameter 'country' is set + if (country == null) + { + throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'country' when calling DefaultApi->GetCountry"); + } + + Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); + + string[] _contentTypes = new string[] { + "application/x-www-form-urlencoded" + }; + + // to determine the Accept header + string[] _accepts = new string[] { + }; + + var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); + if (localVarContentType != null) + { + localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + } + + var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); + if (localVarAccept != null) + { + localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + } + + localVarRequestOptions.FormParameters.Add("country", Org.OpenAPITools.Client.ClientUtils.ParameterToString(country)); // form parameter + + localVarRequestOptions.Operation = "DefaultApi.GetCountry"; + localVarRequestOptions.OperationIndex = operationIndex; + + + // make the HTTP request + var localVarResponse = this.Client.Post("/country", localVarRequestOptions, this.Configuration); + if (this.ExceptionFactory != null) + { + Exception _exception = this.ExceptionFactory("GetCountry", localVarResponse); + if (_exception != null) + { + throw _exception; + } + } + + return localVarResponse; + } + + /// + /// + /// + /// Thrown when fails to make API call + /// + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of void + public async System.Threading.Tasks.Task GetCountryAsync(string country, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + await GetCountryWithHttpInfoAsync(country, operationIndex, cancellationToken).ConfigureAwait(false); + } + + /// + /// + /// + /// Thrown when fails to make API call + /// + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of ApiResponse + public async System.Threading.Tasks.Task> GetCountryWithHttpInfoAsync(string country, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + // verify the required parameter 'country' is set + if (country == null) + { + throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'country' when calling DefaultApi->GetCountry"); + } + + + Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); + + string[] _contentTypes = new string[] { + "application/x-www-form-urlencoded" + }; + + // to determine the Accept header + string[] _accepts = new string[] { + }; + + var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); + if (localVarContentType != null) + { + localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + } + + var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); + if (localVarAccept != null) + { + localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + } + + localVarRequestOptions.FormParameters.Add("country", Org.OpenAPITools.Client.ClientUtils.ParameterToString(country)); // form parameter + + localVarRequestOptions.Operation = "DefaultApi.GetCountry"; + localVarRequestOptions.OperationIndex = operationIndex; + + + // make the HTTP request + var localVarResponse = await this.AsynchronousClient.PostAsync("/country", localVarRequestOptions, this.Configuration, cancellationToken).ConfigureAwait(false); + + if (this.ExceptionFactory != null) + { + Exception _exception = this.ExceptionFactory("GetCountry", localVarResponse); + if (_exception != null) + { + throw _exception; + } + } + + return localVarResponse; + } + } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/apis/DefaultApi.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/apis/DefaultApi.md index 44c4a0cfac6..82d8c6cb2c7 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/apis/DefaultApi.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/apis/DefaultApi.md @@ -5,6 +5,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* | Method | HTTP request | Description | |--------|--------------|-------------| | [**FooGet**](DefaultApi.md#fooget) | **GET** /foo | | +| [**GetCountry**](DefaultApi.md#getcountry) | **POST** /country | | # **FooGet** @@ -88,3 +89,86 @@ 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) + +# **GetCountry** +> void GetCountry (string country) + + + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class GetCountryExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new DefaultApi(config); + var country = "country_example"; // string | + + try + { + apiInstance.GetCountry(country); + } + catch (ApiException e) + { + Debug.Print("Exception when calling DefaultApi.GetCountry: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the GetCountryWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + apiInstance.GetCountryWithHttpInfo(country); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling DefaultApi.GetCountryWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **country** | **string** | | | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/x-www-form-urlencoded + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | OK | - | + +[[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) + diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Api/DefaultApi.cs index c7947592799..29d3cf24839 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -60,6 +60,41 @@ namespace Org.OpenAPITools.IApi /// Cancellation Token to cancel the request. /// Task of ApiResponse<FooGetDefaultResponse?> Task FooGetOrDefaultAsync(System.Threading.CancellationToken? cancellationToken = null); + + /// + /// + /// + /// + /// + /// + /// Thrown when fails to make API call + /// + /// Cancellation Token to cancel the request. + /// Task<ApiResponse<object?>> + Task> GetCountryWithHttpInfoAsync(string country, System.Threading.CancellationToken? cancellationToken = null); + + /// + /// + /// + /// + /// + /// + /// Thrown when fails to make API call + /// + /// Cancellation Token to cancel the request. + /// Task of ApiResponse<object> + Task GetCountryAsync(string country, System.Threading.CancellationToken? cancellationToken = null); + + /// + /// + /// + /// + /// + /// + /// + /// Cancellation Token to cancel the request. + /// Task of ApiResponse<object?> + Task GetCountryOrDefaultAsync(string country, System.Threading.CancellationToken? cancellationToken = null); } } @@ -265,5 +300,159 @@ namespace Org.OpenAPITools.Api throw; } } + + /// + /// + /// + /// Thrown when fails to make API call + /// + /// Cancellation Token to cancel the request. + /// <> + public async Task GetCountryAsync(string country, System.Threading.CancellationToken? cancellationToken = null) + { + ApiResponse result = await GetCountryWithHttpInfoAsync(country, cancellationToken).ConfigureAwait(false); + + if (result.Content == null) + throw new ApiException(result.ReasonPhrase, result.StatusCode, result.RawContent); + + return result.Content; + } + + /// + /// + /// + /// Thrown when fails to make API call + /// + /// Cancellation Token to cancel the request. + /// <> + public async Task GetCountryOrDefaultAsync(string country, System.Threading.CancellationToken? cancellationToken = null) + { + ApiResponse? result = null; + try + { + result = await GetCountryWithHttpInfoAsync(country, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + } + + return result != null && result.IsSuccessStatusCode + ? result.Content + : null; + } + + /// + /// Validates the request parameters + /// + /// + /// + protected virtual string OnGetCountry(string country) + { + #pragma warning disable CS0472 // The result of the expression is always the same since a value of this type is never equal to 'null' + #pragma warning disable CS8073 // The result of the expression is always the same since a value of this type is never equal to 'null' + + if (country == null) + throw new ArgumentNullException(nameof(country)); + + #pragma warning disable CS0472 // The result of the expression is always the same since a value of this type is never equal to 'null' + #pragma warning disable CS8073 // The result of the expression is always the same since a value of this type is never equal to 'null' + + return country; + } + + /// + /// Processes the server response + /// + /// + /// + protected virtual void AfterGetCountry(ApiResponse apiResponse, string country) + { + } + + /// + /// Processes the server response + /// + /// + /// + /// + /// + protected virtual void OnErrorGetCountry(Exception exception, string pathFormat, string path, string country) + { + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// + /// + /// Thrown when fails to make API call + /// + /// Cancellation Token to cancel the request. + /// <> where T : + public async Task> GetCountryWithHttpInfoAsync(string country, System.Threading.CancellationToken? cancellationToken = null) + { + UriBuilder uriBuilder = new UriBuilder(); + + try + { + country = OnGetCountry(country); + + using (HttpRequestMessage request = new HttpRequestMessage()) + { + uriBuilder.Host = HttpClient.BaseAddress!.Host; + uriBuilder.Port = HttpClient.BaseAddress!.Port; + uriBuilder.Scheme = ClientUtils.SCHEME; + uriBuilder.Path = ClientUtils.CONTEXT_PATH + "/country"; + + MultipartContent multipartContent = new MultipartContent(); + + request.Content = multipartContent; + + List> formParams = new List>(); + + multipartContent.Add(new FormUrlEncodedContent(formParams)); + + formParams.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); + + + + request.RequestUri = uriBuilder.Uri; + + string[] contentTypes = new string[] { + "application/x-www-form-urlencoded" + }; + + string? contentType = ClientUtils.SelectHeaderContentType(contentTypes); + + if (contentType != null) + request.Content.Headers.ContentType = new MediaTypeHeaderValue(contentType); + + request.Method = HttpMethod.Post; + + DateTime requestedAt = DateTime.UtcNow; + + using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) + { + OnApiResponded(new ApiResponseEventArgs(requestedAt, DateTime.UtcNow, responseMessage.StatusCode, "/country", uriBuilder.Path)); + + string responseContent = await responseMessage.Content.ReadAsStringAsync(cancellationToken.GetValueOrDefault()).ConfigureAwait(false); + + ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); + + if (apiResponse.IsSuccessStatusCode) + { + apiResponse.Content = JsonSerializer.Deserialize(apiResponse.RawContent, _jsonSerializerOptions); + AfterGetCountry(apiResponse, country); + } + + return apiResponse; + } + } + } + catch(Exception e) + { + OnErrorGetCountry(e, "/country", uriBuilder.Path, country); + throw; + } + } } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/apis/DefaultApi.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/apis/DefaultApi.md index 44c4a0cfac6..82d8c6cb2c7 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/apis/DefaultApi.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/apis/DefaultApi.md @@ -5,6 +5,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* | Method | HTTP request | Description | |--------|--------------|-------------| | [**FooGet**](DefaultApi.md#fooget) | **GET** /foo | | +| [**GetCountry**](DefaultApi.md#getcountry) | **POST** /country | | # **FooGet** @@ -88,3 +89,86 @@ 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) + +# **GetCountry** +> void GetCountry (string country) + + + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class GetCountryExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new DefaultApi(config); + var country = "country_example"; // string | + + try + { + apiInstance.GetCountry(country); + } + catch (ApiException e) + { + Debug.Print("Exception when calling DefaultApi.GetCountry: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the GetCountryWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + apiInstance.GetCountryWithHttpInfo(country); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling DefaultApi.GetCountryWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **country** | **string** | | | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/x-www-form-urlencoded + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | OK | - | + +[[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) + diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Api/DefaultApi.cs index 708148c438b..a713f440179 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -48,6 +48,30 @@ namespace Org.OpenAPITools.IApi /// Cancellation Token to cancel the request. /// Task of ApiResponse<FooGetDefaultResponse> Task FooGetAsync(System.Threading.CancellationToken? cancellationToken = null); + + /// + /// + /// + /// + /// + /// + /// Thrown when fails to make API call + /// + /// Cancellation Token to cancel the request. + /// Task<ApiResponse<object>> + Task> GetCountryWithHttpInfoAsync(string country, System.Threading.CancellationToken? cancellationToken = null); + + /// + /// + /// + /// + /// + /// + /// Thrown when fails to make API call + /// + /// Cancellation Token to cancel the request. + /// Task of ApiResponse<object> + Task GetCountryAsync(string country, System.Threading.CancellationToken? cancellationToken = null); } } @@ -253,5 +277,159 @@ namespace Org.OpenAPITools.Api throw; } } + + /// + /// + /// + /// Thrown when fails to make API call + /// + /// Cancellation Token to cancel the request. + /// <> + public async Task GetCountryAsync(string country, System.Threading.CancellationToken? cancellationToken = null) + { + ApiResponse result = await GetCountryWithHttpInfoAsync(country, cancellationToken).ConfigureAwait(false); + + if (result.Content == null) + throw new ApiException(result.ReasonPhrase, result.StatusCode, result.RawContent); + + return result.Content; + } + + /// + /// + /// + /// Thrown when fails to make API call + /// + /// Cancellation Token to cancel the request. + /// <> + public async Task GetCountryOrDefaultAsync(string country, System.Threading.CancellationToken? cancellationToken = null) + { + ApiResponse result = null; + try + { + result = await GetCountryWithHttpInfoAsync(country, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + } + + return result != null && result.IsSuccessStatusCode + ? result.Content + : null; + } + + /// + /// Validates the request parameters + /// + /// + /// + protected virtual string OnGetCountry(string country) + { + #pragma warning disable CS0472 // The result of the expression is always the same since a value of this type is never equal to 'null' + #pragma warning disable CS8073 // The result of the expression is always the same since a value of this type is never equal to 'null' + + if (country == null) + throw new ArgumentNullException(nameof(country)); + + #pragma warning disable CS0472 // The result of the expression is always the same since a value of this type is never equal to 'null' + #pragma warning disable CS8073 // The result of the expression is always the same since a value of this type is never equal to 'null' + + return country; + } + + /// + /// Processes the server response + /// + /// + /// + protected virtual void AfterGetCountry(ApiResponse apiResponse, string country) + { + } + + /// + /// Processes the server response + /// + /// + /// + /// + /// + protected virtual void OnErrorGetCountry(Exception exception, string pathFormat, string path, string country) + { + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// + /// + /// Thrown when fails to make API call + /// + /// Cancellation Token to cancel the request. + /// <> where T : + public async Task> GetCountryWithHttpInfoAsync(string country, System.Threading.CancellationToken? cancellationToken = null) + { + UriBuilder uriBuilder = new UriBuilder(); + + try + { + country = OnGetCountry(country); + + using (HttpRequestMessage request = new HttpRequestMessage()) + { + uriBuilder.Host = HttpClient.BaseAddress.Host; + uriBuilder.Port = HttpClient.BaseAddress.Port; + uriBuilder.Scheme = ClientUtils.SCHEME; + uriBuilder.Path = ClientUtils.CONTEXT_PATH + "/country"; + + MultipartContent multipartContent = new MultipartContent(); + + request.Content = multipartContent; + + List> formParams = new List>(); + + multipartContent.Add(new FormUrlEncodedContent(formParams)); + + formParams.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); + + + + request.RequestUri = uriBuilder.Uri; + + string[] contentTypes = new string[] { + "application/x-www-form-urlencoded" + }; + + string contentType = ClientUtils.SelectHeaderContentType(contentTypes); + + if (contentType != null) + request.Content.Headers.ContentType = new MediaTypeHeaderValue(contentType); + + request.Method = HttpMethod.Post; + + DateTime requestedAt = DateTime.UtcNow; + + using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) + { + OnApiResponded(new ApiResponseEventArgs(requestedAt, DateTime.UtcNow, responseMessage.StatusCode, "/country", uriBuilder.Path)); + + string responseContent = await responseMessage.Content.ReadAsStringAsync(cancellationToken.GetValueOrDefault()).ConfigureAwait(false); + + ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); + + if (apiResponse.IsSuccessStatusCode) + { + apiResponse.Content = JsonSerializer.Deserialize(apiResponse.RawContent, _jsonSerializerOptions); + AfterGetCountry(apiResponse, country); + } + + return apiResponse; + } + } + } + catch(Exception e) + { + OnErrorGetCountry(e, "/country", uriBuilder.Path, country); + throw; + } + } } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/apis/DefaultApi.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/apis/DefaultApi.md index 44c4a0cfac6..82d8c6cb2c7 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/apis/DefaultApi.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/apis/DefaultApi.md @@ -5,6 +5,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* | Method | HTTP request | Description | |--------|--------------|-------------| | [**FooGet**](DefaultApi.md#fooget) | **GET** /foo | | +| [**GetCountry**](DefaultApi.md#getcountry) | **POST** /country | | # **FooGet** @@ -88,3 +89,86 @@ 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) + +# **GetCountry** +> void GetCountry (string country) + + + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class GetCountryExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new DefaultApi(config); + var country = "country_example"; // string | + + try + { + apiInstance.GetCountry(country); + } + catch (ApiException e) + { + Debug.Print("Exception when calling DefaultApi.GetCountry: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the GetCountryWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + apiInstance.GetCountryWithHttpInfo(country); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling DefaultApi.GetCountryWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **country** | **string** | | | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/x-www-form-urlencoded + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | OK | - | + +[[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) + diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Api/DefaultApi.cs index fccc25399cb..3a09528f0b0 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -48,6 +48,30 @@ namespace Org.OpenAPITools.IApi /// Cancellation Token to cancel the request. /// Task of ApiResponse<FooGetDefaultResponse> Task FooGetAsync(System.Threading.CancellationToken? cancellationToken = null); + + /// + /// + /// + /// + /// + /// + /// Thrown when fails to make API call + /// + /// Cancellation Token to cancel the request. + /// Task<ApiResponse<object>> + Task> GetCountryWithHttpInfoAsync(string country, System.Threading.CancellationToken? cancellationToken = null); + + /// + /// + /// + /// + /// + /// + /// Thrown when fails to make API call + /// + /// Cancellation Token to cancel the request. + /// Task of ApiResponse<object> + Task GetCountryAsync(string country, System.Threading.CancellationToken? cancellationToken = null); } } @@ -253,5 +277,159 @@ namespace Org.OpenAPITools.Api throw; } } + + /// + /// + /// + /// Thrown when fails to make API call + /// + /// Cancellation Token to cancel the request. + /// <> + public async Task GetCountryAsync(string country, System.Threading.CancellationToken? cancellationToken = null) + { + ApiResponse result = await GetCountryWithHttpInfoAsync(country, cancellationToken).ConfigureAwait(false); + + if (result.Content == null) + throw new ApiException(result.ReasonPhrase, result.StatusCode, result.RawContent); + + return result.Content; + } + + /// + /// + /// + /// Thrown when fails to make API call + /// + /// Cancellation Token to cancel the request. + /// <> + public async Task GetCountryOrDefaultAsync(string country, System.Threading.CancellationToken? cancellationToken = null) + { + ApiResponse result = null; + try + { + result = await GetCountryWithHttpInfoAsync(country, cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + } + + return result != null && result.IsSuccessStatusCode + ? result.Content + : null; + } + + /// + /// Validates the request parameters + /// + /// + /// + protected virtual string OnGetCountry(string country) + { + #pragma warning disable CS0472 // The result of the expression is always the same since a value of this type is never equal to 'null' + #pragma warning disable CS8073 // The result of the expression is always the same since a value of this type is never equal to 'null' + + if (country == null) + throw new ArgumentNullException(nameof(country)); + + #pragma warning disable CS0472 // The result of the expression is always the same since a value of this type is never equal to 'null' + #pragma warning disable CS8073 // The result of the expression is always the same since a value of this type is never equal to 'null' + + return country; + } + + /// + /// Processes the server response + /// + /// + /// + protected virtual void AfterGetCountry(ApiResponse apiResponse, string country) + { + } + + /// + /// Processes the server response + /// + /// + /// + /// + /// + protected virtual void OnErrorGetCountry(Exception exception, string pathFormat, string path, string country) + { + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// + /// + /// Thrown when fails to make API call + /// + /// Cancellation Token to cancel the request. + /// <> where T : + public async Task> GetCountryWithHttpInfoAsync(string country, System.Threading.CancellationToken? cancellationToken = null) + { + UriBuilder uriBuilder = new UriBuilder(); + + try + { + country = OnGetCountry(country); + + using (HttpRequestMessage request = new HttpRequestMessage()) + { + uriBuilder.Host = HttpClient.BaseAddress.Host; + uriBuilder.Port = HttpClient.BaseAddress.Port; + uriBuilder.Scheme = ClientUtils.SCHEME; + uriBuilder.Path = ClientUtils.CONTEXT_PATH + "/country"; + + MultipartContent multipartContent = new MultipartContent(); + + request.Content = multipartContent; + + List> formParams = new List>(); + + multipartContent.Add(new FormUrlEncodedContent(formParams)); + + formParams.Add(new KeyValuePair("country", ClientUtils.ParameterToString(country))); + + + + request.RequestUri = uriBuilder.Uri; + + string[] contentTypes = new string[] { + "application/x-www-form-urlencoded" + }; + + string contentType = ClientUtils.SelectHeaderContentType(contentTypes); + + if (contentType != null) + request.Content.Headers.ContentType = new MediaTypeHeaderValue(contentType); + + request.Method = new HttpMethod("POST"); + + DateTime requestedAt = DateTime.UtcNow; + + using (HttpResponseMessage responseMessage = await HttpClient.SendAsync(request, cancellationToken.GetValueOrDefault()).ConfigureAwait(false)) + { + OnApiResponded(new ApiResponseEventArgs(requestedAt, DateTime.UtcNow, responseMessage.StatusCode, "/country", uriBuilder.Path)); + + string responseContent = await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false); + + ApiResponse apiResponse = new ApiResponse(responseMessage, responseContent); + + if (apiResponse.IsSuccessStatusCode) + { + apiResponse.Content = JsonSerializer.Deserialize(apiResponse.RawContent, _jsonSerializerOptions); + AfterGetCountry(apiResponse, country); + } + + return apiResponse; + } + } + } + catch(Exception e) + { + OnErrorGetCountry(e, "/country", uriBuilder.Path, country); + throw; + } + } } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/README.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/README.md index 31eb0250661..548538cc7a2 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/README.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/README.md @@ -130,6 +130,7 @@ Class | Method | HTTP request | Description ------------ | ------------- | ------------- | ------------- *AnotherFakeApi* | [**Call123TestSpecialTags**](docs/AnotherFakeApi.md#call123testspecialtags) | **PATCH** /another-fake/dummy | To test special tags *DefaultApi* | [**FooGet**](docs/DefaultApi.md#fooget) | **GET** /foo | +*DefaultApi* | [**GetCountry**](docs/DefaultApi.md#getcountry) | **POST** /country | *FakeApi* | [**FakeHealthGet**](docs/FakeApi.md#fakehealthget) | **GET** /fake/health | Health check endpoint *FakeApi* | [**FakeOuterBooleanSerialize**](docs/FakeApi.md#fakeouterbooleanserialize) | **POST** /fake/outer/boolean | *FakeApi* | [**FakeOuterCompositeSerialize**](docs/FakeApi.md#fakeoutercompositeserialize) | **POST** /fake/outer/composite | diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/docs/DefaultApi.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/docs/DefaultApi.md index 62dbad7c491..3733b7c3ff9 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/docs/DefaultApi.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/docs/DefaultApi.md @@ -5,6 +5,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* | Method | HTTP request | Description | |--------|--------------|-------------| | [**FooGet**](DefaultApi.md#fooget) | **GET** /foo | | +| [**GetCountry**](DefaultApi.md#getcountry) | **POST** /country | | # **FooGet** @@ -92,3 +93,90 @@ 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) + +# **GetCountry** +> void GetCountry (string country) + + + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using System.Net.Http; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class GetCountryExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + // create instances of HttpClient, HttpClientHandler to be reused later with different Api classes + HttpClient httpClient = new HttpClient(); + HttpClientHandler httpClientHandler = new HttpClientHandler(); + var apiInstance = new DefaultApi(httpClient, config, httpClientHandler); + var country = "country_example"; // string | + + try + { + apiInstance.GetCountry(country); + } + catch (ApiException e) + { + Debug.Print("Exception when calling DefaultApi.GetCountry: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the GetCountryWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + apiInstance.GetCountryWithHttpInfo(country); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling DefaultApi.GetCountryWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **country** | **string** | | | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/x-www-form-urlencoded + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | OK | - | + +[[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) + diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/DefaultApi.cs index 186eb266e6d..083dc76c26d 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -43,6 +43,24 @@ namespace Org.OpenAPITools.Api /// Thrown when fails to make API call /// ApiResponse of FooGetDefaultResponse ApiResponse FooGetWithHttpInfo(); + /// + /// + /// + /// Thrown when fails to make API call + /// + /// + void GetCountry(string country); + + /// + /// + /// + /// + /// + /// + /// Thrown when fails to make API call + /// + /// ApiResponse of Object(void) + ApiResponse GetCountryWithHttpInfo(string country); #endregion Synchronous Operations } @@ -73,6 +91,29 @@ namespace Org.OpenAPITools.Api /// Cancellation Token to cancel the request. /// Task of ApiResponse (FooGetDefaultResponse) System.Threading.Tasks.Task> FooGetWithHttpInfoAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + /// + /// + /// + /// + /// + /// + /// Thrown when fails to make API call + /// + /// Cancellation Token to cancel the request. + /// Task of void + System.Threading.Tasks.Task GetCountryAsync(string country, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + + /// + /// + /// + /// + /// + /// + /// Thrown when fails to make API call + /// + /// Cancellation Token to cancel the request. + /// Task of ApiResponse + System.Threading.Tasks.Task> GetCountryWithHttpInfoAsync(string country, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); #endregion Asynchronous Operations } @@ -387,5 +428,118 @@ namespace Org.OpenAPITools.Api return localVarResponse; } + /// + /// + /// + /// Thrown when fails to make API call + /// + /// + public void GetCountry(string country) + { + GetCountryWithHttpInfo(country); + } + + /// + /// + /// + /// Thrown when fails to make API call + /// + /// ApiResponse of Object(void) + public Org.OpenAPITools.Client.ApiResponse GetCountryWithHttpInfo(string country) + { + // verify the required parameter 'country' is set + if (country == null) + throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'country' when calling DefaultApi->GetCountry"); + + Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); + + string[] _contentTypes = new string[] { + "application/x-www-form-urlencoded" + }; + + // to determine the Accept header + string[] _accepts = new string[] { + }; + + var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); + if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + + var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); + if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + + localVarRequestOptions.FormParameters.Add("country", Org.OpenAPITools.Client.ClientUtils.ParameterToString(country)); // form parameter + + + // make the HTTP request + var localVarResponse = this.Client.Post("/country", localVarRequestOptions, this.Configuration); + + if (this.ExceptionFactory != null) + { + Exception _exception = this.ExceptionFactory("GetCountry", localVarResponse); + if (_exception != null) throw _exception; + } + + return localVarResponse; + } + + /// + /// + /// + /// Thrown when fails to make API call + /// + /// Cancellation Token to cancel the request. + /// Task of void + public async System.Threading.Tasks.Task GetCountryAsync(string country, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + await GetCountryWithHttpInfoAsync(country, cancellationToken).ConfigureAwait(false); + } + + /// + /// + /// + /// Thrown when fails to make API call + /// + /// Cancellation Token to cancel the request. + /// Task of ApiResponse + public async System.Threading.Tasks.Task> GetCountryWithHttpInfoAsync(string country, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + // verify the required parameter 'country' is set + if (country == null) + throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'country' when calling DefaultApi->GetCountry"); + + + Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); + + string[] _contentTypes = new string[] { + "application/x-www-form-urlencoded" + }; + + // to determine the Accept header + string[] _accepts = new string[] { + }; + + + var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); + if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + + var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); + if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + + localVarRequestOptions.FormParameters.Add("country", Org.OpenAPITools.Client.ClientUtils.ParameterToString(country)); // form parameter + + + // make the HTTP request + + var localVarResponse = await this.AsynchronousClient.PostAsync("/country", localVarRequestOptions, this.Configuration, cancellationToken).ConfigureAwait(false); + + if (this.ExceptionFactory != null) + { + Exception _exception = this.ExceptionFactory("GetCountry", localVarResponse); + if (_exception != null) throw _exception; + } + + return localVarResponse; + } + } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-net47/README.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-net47/README.md index 244986de824..31c4c4a2ce2 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-net47/README.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-net47/README.md @@ -117,6 +117,7 @@ Class | Method | HTTP request | Description ------------ | ------------- | ------------- | ------------- *AnotherFakeApi* | [**Call123TestSpecialTags**](docs/AnotherFakeApi.md#call123testspecialtags) | **PATCH** /another-fake/dummy | To test special tags *DefaultApi* | [**FooGet**](docs/DefaultApi.md#fooget) | **GET** /foo | +*DefaultApi* | [**GetCountry**](docs/DefaultApi.md#getcountry) | **POST** /country | *FakeApi* | [**FakeHealthGet**](docs/FakeApi.md#fakehealthget) | **GET** /fake/health | Health check endpoint *FakeApi* | [**FakeOuterBooleanSerialize**](docs/FakeApi.md#fakeouterbooleanserialize) | **POST** /fake/outer/boolean | *FakeApi* | [**FakeOuterCompositeSerialize**](docs/FakeApi.md#fakeoutercompositeserialize) | **POST** /fake/outer/composite | diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-net47/docs/DefaultApi.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-net47/docs/DefaultApi.md index 3a93305e15b..265fec1a6f9 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-net47/docs/DefaultApi.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-net47/docs/DefaultApi.md @@ -5,6 +5,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* | Method | HTTP request | Description | |--------|--------------|-------------| | [**FooGet**](DefaultApi.md#fooget) | **GET** /foo | | +| [**GetCountry**](DefaultApi.md#getcountry) | **POST** /country | | # **FooGet** @@ -88,3 +89,86 @@ 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) + +# **GetCountry** +> void GetCountry (string country) + + + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class GetCountryExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new DefaultApi(config); + var country = "country_example"; // string | + + try + { + apiInstance.GetCountry(country); + } + catch (ApiException e) + { + Debug.Print("Exception when calling DefaultApi.GetCountry: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the GetCountryWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + apiInstance.GetCountryWithHttpInfo(country); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling DefaultApi.GetCountryWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **country** | **string** | | | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/x-www-form-urlencoded + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | OK | - | + +[[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) + diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-net47/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-net47/src/Org.OpenAPITools/Api/DefaultApi.cs index bc5b5556d25..0ae306612df 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-net47/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-net47/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -45,6 +45,26 @@ namespace Org.OpenAPITools.Api /// Index associated with the operation. /// ApiResponse of FooGetDefaultResponse ApiResponse FooGetWithHttpInfo(int operationIndex = 0); + /// + /// + /// + /// Thrown when fails to make API call + /// + /// Index associated with the operation. + /// + void GetCountry(string country, int operationIndex = 0); + + /// + /// + /// + /// + /// + /// + /// Thrown when fails to make API call + /// + /// Index associated with the operation. + /// ApiResponse of Object(void) + ApiResponse GetCountryWithHttpInfo(string country, int operationIndex = 0); #endregion Synchronous Operations } @@ -77,6 +97,31 @@ namespace Org.OpenAPITools.Api /// Cancellation Token to cancel the request. /// Task of ApiResponse (FooGetDefaultResponse) System.Threading.Tasks.Task> FooGetWithHttpInfoAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + /// + /// + /// + /// + /// + /// + /// Thrown when fails to make API call + /// + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of void + System.Threading.Tasks.Task GetCountryAsync(string country, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + + /// + /// + /// + /// + /// + /// + /// Thrown when fails to make API call + /// + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of ApiResponse + System.Threading.Tasks.Task> GetCountryWithHttpInfoAsync(string country, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); #endregion Asynchronous Operations } @@ -323,5 +368,147 @@ namespace Org.OpenAPITools.Api return localVarResponse; } + /// + /// + /// + /// Thrown when fails to make API call + /// + /// Index associated with the operation. + /// + public void GetCountry(string country, int operationIndex = 0) + { + GetCountryWithHttpInfo(country); + } + + /// + /// + /// + /// Thrown when fails to make API call + /// + /// Index associated with the operation. + /// ApiResponse of Object(void) + public Org.OpenAPITools.Client.ApiResponse GetCountryWithHttpInfo(string country, int operationIndex = 0) + { + // verify the required parameter 'country' is set + if (country == null) + { + throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'country' when calling DefaultApi->GetCountry"); + } + + Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); + + string[] _contentTypes = new string[] { + "application/x-www-form-urlencoded" + }; + + // to determine the Accept header + string[] _accepts = new string[] { + }; + + var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); + if (localVarContentType != null) + { + localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + } + + var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); + if (localVarAccept != null) + { + localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + } + + localVarRequestOptions.FormParameters.Add("country", Org.OpenAPITools.Client.ClientUtils.ParameterToString(country)); // form parameter + + localVarRequestOptions.Operation = "DefaultApi.GetCountry"; + localVarRequestOptions.OperationIndex = operationIndex; + + + // make the HTTP request + var localVarResponse = this.Client.Post("/country", localVarRequestOptions, this.Configuration); + if (this.ExceptionFactory != null) + { + Exception _exception = this.ExceptionFactory("GetCountry", localVarResponse); + if (_exception != null) + { + throw _exception; + } + } + + return localVarResponse; + } + + /// + /// + /// + /// Thrown when fails to make API call + /// + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of void + public async System.Threading.Tasks.Task GetCountryAsync(string country, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + await GetCountryWithHttpInfoAsync(country, operationIndex, cancellationToken).ConfigureAwait(false); + } + + /// + /// + /// + /// Thrown when fails to make API call + /// + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of ApiResponse + public async System.Threading.Tasks.Task> GetCountryWithHttpInfoAsync(string country, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + // verify the required parameter 'country' is set + if (country == null) + { + throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'country' when calling DefaultApi->GetCountry"); + } + + + Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); + + string[] _contentTypes = new string[] { + "application/x-www-form-urlencoded" + }; + + // to determine the Accept header + string[] _accepts = new string[] { + }; + + var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); + if (localVarContentType != null) + { + localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + } + + var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); + if (localVarAccept != null) + { + localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + } + + localVarRequestOptions.FormParameters.Add("country", Org.OpenAPITools.Client.ClientUtils.ParameterToString(country)); // form parameter + + localVarRequestOptions.Operation = "DefaultApi.GetCountry"; + localVarRequestOptions.OperationIndex = operationIndex; + + + // make the HTTP request + var localVarResponse = await this.AsynchronousClient.PostAsync("/country", localVarRequestOptions, this.Configuration, cancellationToken).ConfigureAwait(false); + + if (this.ExceptionFactory != null) + { + Exception _exception = this.ExceptionFactory("GetCountry", localVarResponse); + if (_exception != null) + { + throw _exception; + } + } + + return localVarResponse; + } + } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-net48/README.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-net48/README.md index 244986de824..31c4c4a2ce2 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-net48/README.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-net48/README.md @@ -117,6 +117,7 @@ Class | Method | HTTP request | Description ------------ | ------------- | ------------- | ------------- *AnotherFakeApi* | [**Call123TestSpecialTags**](docs/AnotherFakeApi.md#call123testspecialtags) | **PATCH** /another-fake/dummy | To test special tags *DefaultApi* | [**FooGet**](docs/DefaultApi.md#fooget) | **GET** /foo | +*DefaultApi* | [**GetCountry**](docs/DefaultApi.md#getcountry) | **POST** /country | *FakeApi* | [**FakeHealthGet**](docs/FakeApi.md#fakehealthget) | **GET** /fake/health | Health check endpoint *FakeApi* | [**FakeOuterBooleanSerialize**](docs/FakeApi.md#fakeouterbooleanserialize) | **POST** /fake/outer/boolean | *FakeApi* | [**FakeOuterCompositeSerialize**](docs/FakeApi.md#fakeoutercompositeserialize) | **POST** /fake/outer/composite | diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-net48/docs/DefaultApi.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-net48/docs/DefaultApi.md index 3a93305e15b..265fec1a6f9 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-net48/docs/DefaultApi.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-net48/docs/DefaultApi.md @@ -5,6 +5,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* | Method | HTTP request | Description | |--------|--------------|-------------| | [**FooGet**](DefaultApi.md#fooget) | **GET** /foo | | +| [**GetCountry**](DefaultApi.md#getcountry) | **POST** /country | | # **FooGet** @@ -88,3 +89,86 @@ 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) + +# **GetCountry** +> void GetCountry (string country) + + + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class GetCountryExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new DefaultApi(config); + var country = "country_example"; // string | + + try + { + apiInstance.GetCountry(country); + } + catch (ApiException e) + { + Debug.Print("Exception when calling DefaultApi.GetCountry: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the GetCountryWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + apiInstance.GetCountryWithHttpInfo(country); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling DefaultApi.GetCountryWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **country** | **string** | | | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/x-www-form-urlencoded + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | OK | - | + +[[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) + diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-net48/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-net48/src/Org.OpenAPITools/Api/DefaultApi.cs index bc5b5556d25..0ae306612df 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-net48/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-net48/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -45,6 +45,26 @@ namespace Org.OpenAPITools.Api /// Index associated with the operation. /// ApiResponse of FooGetDefaultResponse ApiResponse FooGetWithHttpInfo(int operationIndex = 0); + /// + /// + /// + /// Thrown when fails to make API call + /// + /// Index associated with the operation. + /// + void GetCountry(string country, int operationIndex = 0); + + /// + /// + /// + /// + /// + /// + /// Thrown when fails to make API call + /// + /// Index associated with the operation. + /// ApiResponse of Object(void) + ApiResponse GetCountryWithHttpInfo(string country, int operationIndex = 0); #endregion Synchronous Operations } @@ -77,6 +97,31 @@ namespace Org.OpenAPITools.Api /// Cancellation Token to cancel the request. /// Task of ApiResponse (FooGetDefaultResponse) System.Threading.Tasks.Task> FooGetWithHttpInfoAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + /// + /// + /// + /// + /// + /// + /// Thrown when fails to make API call + /// + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of void + System.Threading.Tasks.Task GetCountryAsync(string country, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + + /// + /// + /// + /// + /// + /// + /// Thrown when fails to make API call + /// + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of ApiResponse + System.Threading.Tasks.Task> GetCountryWithHttpInfoAsync(string country, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); #endregion Asynchronous Operations } @@ -323,5 +368,147 @@ namespace Org.OpenAPITools.Api return localVarResponse; } + /// + /// + /// + /// Thrown when fails to make API call + /// + /// Index associated with the operation. + /// + public void GetCountry(string country, int operationIndex = 0) + { + GetCountryWithHttpInfo(country); + } + + /// + /// + /// + /// Thrown when fails to make API call + /// + /// Index associated with the operation. + /// ApiResponse of Object(void) + public Org.OpenAPITools.Client.ApiResponse GetCountryWithHttpInfo(string country, int operationIndex = 0) + { + // verify the required parameter 'country' is set + if (country == null) + { + throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'country' when calling DefaultApi->GetCountry"); + } + + Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); + + string[] _contentTypes = new string[] { + "application/x-www-form-urlencoded" + }; + + // to determine the Accept header + string[] _accepts = new string[] { + }; + + var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); + if (localVarContentType != null) + { + localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + } + + var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); + if (localVarAccept != null) + { + localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + } + + localVarRequestOptions.FormParameters.Add("country", Org.OpenAPITools.Client.ClientUtils.ParameterToString(country)); // form parameter + + localVarRequestOptions.Operation = "DefaultApi.GetCountry"; + localVarRequestOptions.OperationIndex = operationIndex; + + + // make the HTTP request + var localVarResponse = this.Client.Post("/country", localVarRequestOptions, this.Configuration); + if (this.ExceptionFactory != null) + { + Exception _exception = this.ExceptionFactory("GetCountry", localVarResponse); + if (_exception != null) + { + throw _exception; + } + } + + return localVarResponse; + } + + /// + /// + /// + /// Thrown when fails to make API call + /// + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of void + public async System.Threading.Tasks.Task GetCountryAsync(string country, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + await GetCountryWithHttpInfoAsync(country, operationIndex, cancellationToken).ConfigureAwait(false); + } + + /// + /// + /// + /// Thrown when fails to make API call + /// + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of ApiResponse + public async System.Threading.Tasks.Task> GetCountryWithHttpInfoAsync(string country, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + // verify the required parameter 'country' is set + if (country == null) + { + throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'country' when calling DefaultApi->GetCountry"); + } + + + Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); + + string[] _contentTypes = new string[] { + "application/x-www-form-urlencoded" + }; + + // to determine the Accept header + string[] _accepts = new string[] { + }; + + var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); + if (localVarContentType != null) + { + localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + } + + var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); + if (localVarAccept != null) + { + localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + } + + localVarRequestOptions.FormParameters.Add("country", Org.OpenAPITools.Client.ClientUtils.ParameterToString(country)); // form parameter + + localVarRequestOptions.Operation = "DefaultApi.GetCountry"; + localVarRequestOptions.OperationIndex = operationIndex; + + + // make the HTTP request + var localVarResponse = await this.AsynchronousClient.PostAsync("/country", localVarRequestOptions, this.Configuration, cancellationToken).ConfigureAwait(false); + + if (this.ExceptionFactory != null) + { + Exception _exception = this.ExceptionFactory("GetCountry", localVarResponse); + if (_exception != null) + { + throw _exception; + } + } + + return localVarResponse; + } + } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-net5.0/README.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-net5.0/README.md index 244986de824..31c4c4a2ce2 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-net5.0/README.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-net5.0/README.md @@ -117,6 +117,7 @@ Class | Method | HTTP request | Description ------------ | ------------- | ------------- | ------------- *AnotherFakeApi* | [**Call123TestSpecialTags**](docs/AnotherFakeApi.md#call123testspecialtags) | **PATCH** /another-fake/dummy | To test special tags *DefaultApi* | [**FooGet**](docs/DefaultApi.md#fooget) | **GET** /foo | +*DefaultApi* | [**GetCountry**](docs/DefaultApi.md#getcountry) | **POST** /country | *FakeApi* | [**FakeHealthGet**](docs/FakeApi.md#fakehealthget) | **GET** /fake/health | Health check endpoint *FakeApi* | [**FakeOuterBooleanSerialize**](docs/FakeApi.md#fakeouterbooleanserialize) | **POST** /fake/outer/boolean | *FakeApi* | [**FakeOuterCompositeSerialize**](docs/FakeApi.md#fakeoutercompositeserialize) | **POST** /fake/outer/composite | diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-net5.0/docs/DefaultApi.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-net5.0/docs/DefaultApi.md index 3a93305e15b..265fec1a6f9 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-net5.0/docs/DefaultApi.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-net5.0/docs/DefaultApi.md @@ -5,6 +5,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* | Method | HTTP request | Description | |--------|--------------|-------------| | [**FooGet**](DefaultApi.md#fooget) | **GET** /foo | | +| [**GetCountry**](DefaultApi.md#getcountry) | **POST** /country | | # **FooGet** @@ -88,3 +89,86 @@ 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) + +# **GetCountry** +> void GetCountry (string country) + + + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class GetCountryExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new DefaultApi(config); + var country = "country_example"; // string | + + try + { + apiInstance.GetCountry(country); + } + catch (ApiException e) + { + Debug.Print("Exception when calling DefaultApi.GetCountry: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the GetCountryWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + apiInstance.GetCountryWithHttpInfo(country); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling DefaultApi.GetCountryWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **country** | **string** | | | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/x-www-form-urlencoded + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | OK | - | + +[[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) + diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-net5.0/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-net5.0/src/Org.OpenAPITools/Api/DefaultApi.cs index bc5b5556d25..0ae306612df 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-net5.0/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-net5.0/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -45,6 +45,26 @@ namespace Org.OpenAPITools.Api /// Index associated with the operation. /// ApiResponse of FooGetDefaultResponse ApiResponse FooGetWithHttpInfo(int operationIndex = 0); + /// + /// + /// + /// Thrown when fails to make API call + /// + /// Index associated with the operation. + /// + void GetCountry(string country, int operationIndex = 0); + + /// + /// + /// + /// + /// + /// + /// Thrown when fails to make API call + /// + /// Index associated with the operation. + /// ApiResponse of Object(void) + ApiResponse GetCountryWithHttpInfo(string country, int operationIndex = 0); #endregion Synchronous Operations } @@ -77,6 +97,31 @@ namespace Org.OpenAPITools.Api /// Cancellation Token to cancel the request. /// Task of ApiResponse (FooGetDefaultResponse) System.Threading.Tasks.Task> FooGetWithHttpInfoAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + /// + /// + /// + /// + /// + /// + /// Thrown when fails to make API call + /// + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of void + System.Threading.Tasks.Task GetCountryAsync(string country, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + + /// + /// + /// + /// + /// + /// + /// Thrown when fails to make API call + /// + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of ApiResponse + System.Threading.Tasks.Task> GetCountryWithHttpInfoAsync(string country, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); #endregion Asynchronous Operations } @@ -323,5 +368,147 @@ namespace Org.OpenAPITools.Api return localVarResponse; } + /// + /// + /// + /// Thrown when fails to make API call + /// + /// Index associated with the operation. + /// + public void GetCountry(string country, int operationIndex = 0) + { + GetCountryWithHttpInfo(country); + } + + /// + /// + /// + /// Thrown when fails to make API call + /// + /// Index associated with the operation. + /// ApiResponse of Object(void) + public Org.OpenAPITools.Client.ApiResponse GetCountryWithHttpInfo(string country, int operationIndex = 0) + { + // verify the required parameter 'country' is set + if (country == null) + { + throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'country' when calling DefaultApi->GetCountry"); + } + + Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); + + string[] _contentTypes = new string[] { + "application/x-www-form-urlencoded" + }; + + // to determine the Accept header + string[] _accepts = new string[] { + }; + + var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); + if (localVarContentType != null) + { + localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + } + + var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); + if (localVarAccept != null) + { + localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + } + + localVarRequestOptions.FormParameters.Add("country", Org.OpenAPITools.Client.ClientUtils.ParameterToString(country)); // form parameter + + localVarRequestOptions.Operation = "DefaultApi.GetCountry"; + localVarRequestOptions.OperationIndex = operationIndex; + + + // make the HTTP request + var localVarResponse = this.Client.Post("/country", localVarRequestOptions, this.Configuration); + if (this.ExceptionFactory != null) + { + Exception _exception = this.ExceptionFactory("GetCountry", localVarResponse); + if (_exception != null) + { + throw _exception; + } + } + + return localVarResponse; + } + + /// + /// + /// + /// Thrown when fails to make API call + /// + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of void + public async System.Threading.Tasks.Task GetCountryAsync(string country, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + await GetCountryWithHttpInfoAsync(country, operationIndex, cancellationToken).ConfigureAwait(false); + } + + /// + /// + /// + /// Thrown when fails to make API call + /// + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of ApiResponse + public async System.Threading.Tasks.Task> GetCountryWithHttpInfoAsync(string country, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + // verify the required parameter 'country' is set + if (country == null) + { + throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'country' when calling DefaultApi->GetCountry"); + } + + + Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); + + string[] _contentTypes = new string[] { + "application/x-www-form-urlencoded" + }; + + // to determine the Accept header + string[] _accepts = new string[] { + }; + + var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); + if (localVarContentType != null) + { + localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + } + + var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); + if (localVarAccept != null) + { + localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + } + + localVarRequestOptions.FormParameters.Add("country", Org.OpenAPITools.Client.ClientUtils.ParameterToString(country)); // form parameter + + localVarRequestOptions.Operation = "DefaultApi.GetCountry"; + localVarRequestOptions.OperationIndex = operationIndex; + + + // make the HTTP request + var localVarResponse = await this.AsynchronousClient.PostAsync("/country", localVarRequestOptions, this.Configuration, cancellationToken).ConfigureAwait(false); + + if (this.ExceptionFactory != null) + { + Exception _exception = this.ExceptionFactory("GetCountry", localVarResponse); + if (_exception != null) + { + throw _exception; + } + } + + return localVarResponse; + } + } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient/README.md b/samples/client/petstore/csharp-netcore/OpenAPIClient/README.md index bff23f31e56..cf4a21009f8 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient/README.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient/README.md @@ -105,6 +105,7 @@ Class | Method | HTTP request | Description ------------ | ------------- | ------------- | ------------- *AnotherFakeApi* | [**Call123TestSpecialTags**](docs/AnotherFakeApi.md#call123testspecialtags) | **PATCH** /another-fake/dummy | To test special tags *DefaultApi* | [**FooGet**](docs/DefaultApi.md#fooget) | **GET** /foo | +*DefaultApi* | [**GetCountry**](docs/DefaultApi.md#getcountry) | **POST** /country | *FakeApi* | [**FakeHealthGet**](docs/FakeApi.md#fakehealthget) | **GET** /fake/health | Health check endpoint *FakeApi* | [**FakeOuterBooleanSerialize**](docs/FakeApi.md#fakeouterbooleanserialize) | **POST** /fake/outer/boolean | *FakeApi* | [**FakeOuterCompositeSerialize**](docs/FakeApi.md#fakeoutercompositeserialize) | **POST** /fake/outer/composite | diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient/docs/DefaultApi.md b/samples/client/petstore/csharp-netcore/OpenAPIClient/docs/DefaultApi.md index 3a93305e15b..265fec1a6f9 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient/docs/DefaultApi.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient/docs/DefaultApi.md @@ -5,6 +5,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* | Method | HTTP request | Description | |--------|--------------|-------------| | [**FooGet**](DefaultApi.md#fooget) | **GET** /foo | | +| [**GetCountry**](DefaultApi.md#getcountry) | **POST** /country | | # **FooGet** @@ -88,3 +89,86 @@ 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) + +# **GetCountry** +> void GetCountry (string country) + + + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class GetCountryExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new DefaultApi(config); + var country = "country_example"; // string | + + try + { + apiInstance.GetCountry(country); + } + catch (ApiException e) + { + Debug.Print("Exception when calling DefaultApi.GetCountry: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the GetCountryWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + apiInstance.GetCountryWithHttpInfo(country); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling DefaultApi.GetCountryWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **country** | **string** | | | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/x-www-form-urlencoded + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | OK | - | + +[[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) + diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient/src/Org.OpenAPITools/Api/DefaultApi.cs index bc5b5556d25..0ae306612df 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -45,6 +45,26 @@ namespace Org.OpenAPITools.Api /// Index associated with the operation. /// ApiResponse of FooGetDefaultResponse ApiResponse FooGetWithHttpInfo(int operationIndex = 0); + /// + /// + /// + /// Thrown when fails to make API call + /// + /// Index associated with the operation. + /// + void GetCountry(string country, int operationIndex = 0); + + /// + /// + /// + /// + /// + /// + /// Thrown when fails to make API call + /// + /// Index associated with the operation. + /// ApiResponse of Object(void) + ApiResponse GetCountryWithHttpInfo(string country, int operationIndex = 0); #endregion Synchronous Operations } @@ -77,6 +97,31 @@ namespace Org.OpenAPITools.Api /// Cancellation Token to cancel the request. /// Task of ApiResponse (FooGetDefaultResponse) System.Threading.Tasks.Task> FooGetWithHttpInfoAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + /// + /// + /// + /// + /// + /// + /// Thrown when fails to make API call + /// + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of void + System.Threading.Tasks.Task GetCountryAsync(string country, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + + /// + /// + /// + /// + /// + /// + /// Thrown when fails to make API call + /// + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of ApiResponse + System.Threading.Tasks.Task> GetCountryWithHttpInfoAsync(string country, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); #endregion Asynchronous Operations } @@ -323,5 +368,147 @@ namespace Org.OpenAPITools.Api return localVarResponse; } + /// + /// + /// + /// Thrown when fails to make API call + /// + /// Index associated with the operation. + /// + public void GetCountry(string country, int operationIndex = 0) + { + GetCountryWithHttpInfo(country); + } + + /// + /// + /// + /// Thrown when fails to make API call + /// + /// Index associated with the operation. + /// ApiResponse of Object(void) + public Org.OpenAPITools.Client.ApiResponse GetCountryWithHttpInfo(string country, int operationIndex = 0) + { + // verify the required parameter 'country' is set + if (country == null) + { + throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'country' when calling DefaultApi->GetCountry"); + } + + Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); + + string[] _contentTypes = new string[] { + "application/x-www-form-urlencoded" + }; + + // to determine the Accept header + string[] _accepts = new string[] { + }; + + var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); + if (localVarContentType != null) + { + localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + } + + var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); + if (localVarAccept != null) + { + localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + } + + localVarRequestOptions.FormParameters.Add("country", Org.OpenAPITools.Client.ClientUtils.ParameterToString(country)); // form parameter + + localVarRequestOptions.Operation = "DefaultApi.GetCountry"; + localVarRequestOptions.OperationIndex = operationIndex; + + + // make the HTTP request + var localVarResponse = this.Client.Post("/country", localVarRequestOptions, this.Configuration); + if (this.ExceptionFactory != null) + { + Exception _exception = this.ExceptionFactory("GetCountry", localVarResponse); + if (_exception != null) + { + throw _exception; + } + } + + return localVarResponse; + } + + /// + /// + /// + /// Thrown when fails to make API call + /// + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of void + public async System.Threading.Tasks.Task GetCountryAsync(string country, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + await GetCountryWithHttpInfoAsync(country, operationIndex, cancellationToken).ConfigureAwait(false); + } + + /// + /// + /// + /// Thrown when fails to make API call + /// + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of ApiResponse + public async System.Threading.Tasks.Task> GetCountryWithHttpInfoAsync(string country, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + // verify the required parameter 'country' is set + if (country == null) + { + throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'country' when calling DefaultApi->GetCountry"); + } + + + Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); + + string[] _contentTypes = new string[] { + "application/x-www-form-urlencoded" + }; + + // to determine the Accept header + string[] _accepts = new string[] { + }; + + var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); + if (localVarContentType != null) + { + localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + } + + var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); + if (localVarAccept != null) + { + localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + } + + localVarRequestOptions.FormParameters.Add("country", Org.OpenAPITools.Client.ClientUtils.ParameterToString(country)); // form parameter + + localVarRequestOptions.Operation = "DefaultApi.GetCountry"; + localVarRequestOptions.OperationIndex = operationIndex; + + + // make the HTTP request + var localVarResponse = await this.AsynchronousClient.PostAsync("/country", localVarRequestOptions, this.Configuration, cancellationToken).ConfigureAwait(false); + + if (this.ExceptionFactory != null) + { + Exception _exception = this.ExceptionFactory("GetCountry", localVarResponse); + if (_exception != null) + { + throw _exception; + } + } + + return localVarResponse; + } + } } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClientCore/README.md b/samples/client/petstore/csharp-netcore/OpenAPIClientCore/README.md index 244986de824..31c4c4a2ce2 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClientCore/README.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClientCore/README.md @@ -117,6 +117,7 @@ Class | Method | HTTP request | Description ------------ | ------------- | ------------- | ------------- *AnotherFakeApi* | [**Call123TestSpecialTags**](docs/AnotherFakeApi.md#call123testspecialtags) | **PATCH** /another-fake/dummy | To test special tags *DefaultApi* | [**FooGet**](docs/DefaultApi.md#fooget) | **GET** /foo | +*DefaultApi* | [**GetCountry**](docs/DefaultApi.md#getcountry) | **POST** /country | *FakeApi* | [**FakeHealthGet**](docs/FakeApi.md#fakehealthget) | **GET** /fake/health | Health check endpoint *FakeApi* | [**FakeOuterBooleanSerialize**](docs/FakeApi.md#fakeouterbooleanserialize) | **POST** /fake/outer/boolean | *FakeApi* | [**FakeOuterCompositeSerialize**](docs/FakeApi.md#fakeoutercompositeserialize) | **POST** /fake/outer/composite | diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClientCore/docs/DefaultApi.md b/samples/client/petstore/csharp-netcore/OpenAPIClientCore/docs/DefaultApi.md index 3a93305e15b..265fec1a6f9 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClientCore/docs/DefaultApi.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClientCore/docs/DefaultApi.md @@ -5,6 +5,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* | Method | HTTP request | Description | |--------|--------------|-------------| | [**FooGet**](DefaultApi.md#fooget) | **GET** /foo | | +| [**GetCountry**](DefaultApi.md#getcountry) | **POST** /country | | # **FooGet** @@ -88,3 +89,86 @@ 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) + +# **GetCountry** +> void GetCountry (string country) + + + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class GetCountryExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new DefaultApi(config); + var country = "country_example"; // string | + + try + { + apiInstance.GetCountry(country); + } + catch (ApiException e) + { + Debug.Print("Exception when calling DefaultApi.GetCountry: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the GetCountryWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + apiInstance.GetCountryWithHttpInfo(country); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling DefaultApi.GetCountryWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------|------|-------------|-------| +| **country** | **string** | | | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/x-www-form-urlencoded + - **Accept**: Not defined + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | OK | - | + +[[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) + diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClientCore/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClientCore/src/Org.OpenAPITools/Api/DefaultApi.cs index bc5b5556d25..0ae306612df 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClientCore/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClientCore/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -45,6 +45,26 @@ namespace Org.OpenAPITools.Api /// Index associated with the operation. /// ApiResponse of FooGetDefaultResponse ApiResponse FooGetWithHttpInfo(int operationIndex = 0); + /// + /// + /// + /// Thrown when fails to make API call + /// + /// Index associated with the operation. + /// + void GetCountry(string country, int operationIndex = 0); + + /// + /// + /// + /// + /// + /// + /// Thrown when fails to make API call + /// + /// Index associated with the operation. + /// ApiResponse of Object(void) + ApiResponse GetCountryWithHttpInfo(string country, int operationIndex = 0); #endregion Synchronous Operations } @@ -77,6 +97,31 @@ namespace Org.OpenAPITools.Api /// Cancellation Token to cancel the request. /// Task of ApiResponse (FooGetDefaultResponse) System.Threading.Tasks.Task> FooGetWithHttpInfoAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + /// + /// + /// + /// + /// + /// + /// Thrown when fails to make API call + /// + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of void + System.Threading.Tasks.Task GetCountryAsync(string country, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + + /// + /// + /// + /// + /// + /// + /// Thrown when fails to make API call + /// + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of ApiResponse + System.Threading.Tasks.Task> GetCountryWithHttpInfoAsync(string country, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); #endregion Asynchronous Operations } @@ -323,5 +368,147 @@ namespace Org.OpenAPITools.Api return localVarResponse; } + /// + /// + /// + /// Thrown when fails to make API call + /// + /// Index associated with the operation. + /// + public void GetCountry(string country, int operationIndex = 0) + { + GetCountryWithHttpInfo(country); + } + + /// + /// + /// + /// Thrown when fails to make API call + /// + /// Index associated with the operation. + /// ApiResponse of Object(void) + public Org.OpenAPITools.Client.ApiResponse GetCountryWithHttpInfo(string country, int operationIndex = 0) + { + // verify the required parameter 'country' is set + if (country == null) + { + throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'country' when calling DefaultApi->GetCountry"); + } + + Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); + + string[] _contentTypes = new string[] { + "application/x-www-form-urlencoded" + }; + + // to determine the Accept header + string[] _accepts = new string[] { + }; + + var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); + if (localVarContentType != null) + { + localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + } + + var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); + if (localVarAccept != null) + { + localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + } + + localVarRequestOptions.FormParameters.Add("country", Org.OpenAPITools.Client.ClientUtils.ParameterToString(country)); // form parameter + + localVarRequestOptions.Operation = "DefaultApi.GetCountry"; + localVarRequestOptions.OperationIndex = operationIndex; + + + // make the HTTP request + var localVarResponse = this.Client.Post("/country", localVarRequestOptions, this.Configuration); + if (this.ExceptionFactory != null) + { + Exception _exception = this.ExceptionFactory("GetCountry", localVarResponse); + if (_exception != null) + { + throw _exception; + } + } + + return localVarResponse; + } + + /// + /// + /// + /// Thrown when fails to make API call + /// + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of void + public async System.Threading.Tasks.Task GetCountryAsync(string country, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + await GetCountryWithHttpInfoAsync(country, operationIndex, cancellationToken).ConfigureAwait(false); + } + + /// + /// + /// + /// Thrown when fails to make API call + /// + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of ApiResponse + public async System.Threading.Tasks.Task> GetCountryWithHttpInfoAsync(string country, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + // verify the required parameter 'country' is set + if (country == null) + { + throw new Org.OpenAPITools.Client.ApiException(400, "Missing required parameter 'country' when calling DefaultApi->GetCountry"); + } + + + Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); + + string[] _contentTypes = new string[] { + "application/x-www-form-urlencoded" + }; + + // to determine the Accept header + string[] _accepts = new string[] { + }; + + var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); + if (localVarContentType != null) + { + localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + } + + var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); + if (localVarAccept != null) + { + localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + } + + localVarRequestOptions.FormParameters.Add("country", Org.OpenAPITools.Client.ClientUtils.ParameterToString(country)); // form parameter + + localVarRequestOptions.Operation = "DefaultApi.GetCountry"; + localVarRequestOptions.OperationIndex = operationIndex; + + + // make the HTTP request + var localVarResponse = await this.AsynchronousClient.PostAsync("/country", localVarRequestOptions, this.Configuration, cancellationToken).ConfigureAwait(false); + + if (this.ExceptionFactory != null) + { + Exception _exception = this.ExceptionFactory("GetCountry", localVarResponse); + if (_exception != null) + { + throw _exception; + } + } + + return localVarResponse; + } + } }