diff --git a/modules/openapi-generator/src/test/resources/3_0/echo_api.yaml b/modules/openapi-generator/src/test/resources/3_0/echo_api.yaml
index 534ababda74..0ac182de116 100644
--- a/modules/openapi-generator/src/test/resources/3_0/echo_api.yaml
+++ b/modules/openapi-generator/src/test/resources/3_0/echo_api.yaml
@@ -485,8 +485,28 @@ paths:
text/plain:
schema:
type: string
-
+ # To test http basic auth
+ /auth/http/basic:
+ post:
+ tags:
+ - auth
+ security:
+ - http_auth: []
+ summary: To test HTTP basic authentication
+ description: To test HTTP basic authentication
+ operationId: test/auth/http/basic
+ responses:
+ '200':
+ description: Successful operation
+ content:
+ text/plain:
+ schema:
+ type: string
components:
+ securitySchemes:
+ http_auth:
+ type: http
+ scheme: basic
requestBodies:
Pet:
content:
diff --git a/samples/client/echo_api/csharp-restsharp/.openapi-generator/FILES b/samples/client/echo_api/csharp-restsharp/.openapi-generator/FILES
index bcdb24f868e..b311c4be4b3 100644
--- a/samples/client/echo_api/csharp-restsharp/.openapi-generator/FILES
+++ b/samples/client/echo_api/csharp-restsharp/.openapi-generator/FILES
@@ -3,6 +3,7 @@ Org.OpenAPITools.sln
README.md
api/openapi.yaml
appveyor.yml
+docs/AuthApi.md
docs/Bird.md
docs/BodyApi.md
docs/Category.md
@@ -21,6 +22,7 @@ docs/TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.md
docs/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.md
git_push.sh
src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj
+src/Org.OpenAPITools/Api/AuthApi.cs
src/Org.OpenAPITools/Api/BodyApi.cs
src/Org.OpenAPITools/Api/FormApi.cs
src/Org.OpenAPITools/Api/HeaderApi.cs
diff --git a/samples/client/echo_api/csharp-restsharp/README.md b/samples/client/echo_api/csharp-restsharp/README.md
index c5d5fff5f0b..616da41eae0 100644
--- a/samples/client/echo_api/csharp-restsharp/README.md
+++ b/samples/client/echo_api/csharp-restsharp/README.md
@@ -85,17 +85,21 @@ namespace Example
Configuration config = new Configuration();
config.BasePath = "http://localhost:3000";
- var apiInstance = new BodyApi(config);
+ // Configure HTTP basic authorization: http_auth
+ config.Username = "YOUR_USERNAME";
+ config.Password = "YOUR_PASSWORD";
+
+ var apiInstance = new AuthApi(config);
try
{
- // Test binary (gif) response body
- System.IO.Stream result = apiInstance.TestBinaryGif();
+ // To test HTTP basic authentication
+ string result = apiInstance.TestAuthHttpBasic();
Debug.WriteLine(result);
}
catch (ApiException e)
{
- Debug.Print("Exception when calling BodyApi.TestBinaryGif: " + e.Message );
+ Debug.Print("Exception when calling AuthApi.TestAuthHttpBasic: " + e.Message );
Debug.Print("Status Code: "+ e.ErrorCode);
Debug.Print(e.StackTrace);
}
@@ -112,6 +116,7 @@ All URIs are relative to *http://localhost:3000*
Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
+*AuthApi* | [**TestAuthHttpBasic**](docs/AuthApi.md#testauthhttpbasic) | **POST** /auth/http/basic | To test HTTP basic authentication
*BodyApi* | [**TestBinaryGif**](docs/BodyApi.md#testbinarygif) | **POST** /binary/gif | Test binary (gif) response body
*BodyApi* | [**TestBodyApplicationOctetstreamBinary**](docs/BodyApi.md#testbodyapplicationoctetstreambinary) | **POST** /body/application/octetstream/binary | Test body parameter(s)
*BodyApi* | [**TestBodyMultipartFormdataArrayOfBinary**](docs/BodyApi.md#testbodymultipartformdataarrayofbinary) | **POST** /body/application/octetstream/array_of_binary | Test array of binary in multipart mime
@@ -152,5 +157,10 @@ Class | Method | HTTP request | Description
## Documentation for Authorization
-Endpoints do not require authorization.
+
+Authentication schemes defined for the API:
+
+### http_auth
+
+- **Type**: HTTP basic authentication
diff --git a/samples/client/echo_api/csharp-restsharp/api/openapi.yaml b/samples/client/echo_api/csharp-restsharp/api/openapi.yaml
index 9699db191cd..3b57b9f69c1 100644
--- a/samples/client/echo_api/csharp-restsharp/api/openapi.yaml
+++ b/samples/client/echo_api/csharp-restsharp/api/openapi.yaml
@@ -442,6 +442,22 @@ paths:
summary: Test array of binary in multipart mime
tags:
- body
+ /auth/http/basic:
+ post:
+ description: To test HTTP basic authentication
+ operationId: test/auth/http/basic
+ responses:
+ "200":
+ content:
+ text/plain:
+ schema:
+ type: string
+ description: Successful operation
+ security:
+ - http_auth: []
+ summary: To test HTTP basic authentication
+ tags:
+ - auth
components:
requestBodies:
Pet:
@@ -702,4 +718,8 @@ components:
required:
- files
type: object
+ securitySchemes:
+ http_auth:
+ scheme: basic
+ type: http
diff --git a/samples/client/echo_api/csharp-restsharp/docs/AuthApi.md b/samples/client/echo_api/csharp-restsharp/docs/AuthApi.md
new file mode 100644
index 00000000000..cd93cd1eb3a
--- /dev/null
+++ b/samples/client/echo_api/csharp-restsharp/docs/AuthApi.md
@@ -0,0 +1,98 @@
+# Org.OpenAPITools.Api.AuthApi
+
+All URIs are relative to *http://localhost:3000*
+
+| Method | HTTP request | Description |
+|--------|--------------|-------------|
+| [**TestAuthHttpBasic**](AuthApi.md#testauthhttpbasic) | **POST** /auth/http/basic | To test HTTP basic authentication |
+
+
+# **TestAuthHttpBasic**
+> string TestAuthHttpBasic ()
+
+To test HTTP basic authentication
+
+To test HTTP basic authentication
+
+### 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 TestAuthHttpBasicExample
+ {
+ public static void Main()
+ {
+ Configuration config = new Configuration();
+ config.BasePath = "http://localhost:3000";
+ // Configure HTTP basic authorization: http_auth
+ config.Username = "YOUR_USERNAME";
+ config.Password = "YOUR_PASSWORD";
+
+ var apiInstance = new AuthApi(config);
+
+ try
+ {
+ // To test HTTP basic authentication
+ string result = apiInstance.TestAuthHttpBasic();
+ Debug.WriteLine(result);
+ }
+ catch (ApiException e)
+ {
+ Debug.Print("Exception when calling AuthApi.TestAuthHttpBasic: " + e.Message);
+ Debug.Print("Status Code: " + e.ErrorCode);
+ Debug.Print(e.StackTrace);
+ }
+ }
+ }
+}
+```
+
+#### Using the TestAuthHttpBasicWithHttpInfo variant
+This returns an ApiResponse object which contains the response data, status code and headers.
+
+```csharp
+try
+{
+ // To test HTTP basic authentication
+ ApiResponse response = apiInstance.TestAuthHttpBasicWithHttpInfo();
+ Debug.Write("Status Code: " + response.StatusCode);
+ Debug.Write("Response Headers: " + response.Headers);
+ Debug.Write("Response Body: " + response.Data);
+}
+catch (ApiException e)
+{
+ Debug.Print("Exception when calling AuthApi.TestAuthHttpBasicWithHttpInfo: " + e.Message);
+ Debug.Print("Status Code: " + e.ErrorCode);
+ Debug.Print(e.StackTrace);
+}
+```
+
+### Parameters
+This endpoint does not need any parameter.
+### Return type
+
+**string**
+
+### Authorization
+
+[http_auth](../README.md#http_auth)
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: text/plain
+
+
+### HTTP response details
+| Status code | Description | Response headers |
+|-------------|-------------|------------------|
+| **200** | Successful operation | - |
+
+[[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/echo_api/csharp-restsharp/src/Org.OpenAPITools.Test/Api/AuthApiTests.cs b/samples/client/echo_api/csharp-restsharp/src/Org.OpenAPITools.Test/Api/AuthApiTests.cs
new file mode 100644
index 00000000000..456245d7bab
--- /dev/null
+++ b/samples/client/echo_api/csharp-restsharp/src/Org.OpenAPITools.Test/Api/AuthApiTests.cs
@@ -0,0 +1,67 @@
+/*
+ * Echo Server API
+ *
+ * Echo Server API
+ *
+ * The version of the OpenAPI document: 0.1.0
+ * Contact: team@openapitools.org
+ * Generated by: https://github.com/openapitools/openapi-generator.git
+ */
+
+using System;
+using System.IO;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Reflection;
+using RestSharp;
+using Xunit;
+
+using Org.OpenAPITools.Client;
+using Org.OpenAPITools.Api;
+
+namespace Org.OpenAPITools.Test.Api
+{
+ ///
+ /// Class for testing AuthApi
+ ///
+ ///
+ /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech).
+ /// Please update the test case below to test the API endpoint.
+ ///
+ public class AuthApiTests : IDisposable
+ {
+ private AuthApi instance;
+
+ public AuthApiTests()
+ {
+ instance = new AuthApi();
+ }
+
+ public void Dispose()
+ {
+ // Cleanup when everything is done.
+ }
+
+ ///
+ /// Test an instance of AuthApi
+ ///
+ [Fact]
+ public void InstanceTest()
+ {
+ // TODO uncomment below to test 'IsType' AuthApi
+ //Assert.IsType(instance);
+ }
+
+ ///
+ /// Test TestAuthHttpBasic
+ ///
+ [Fact]
+ public void TestAuthHttpBasicTest()
+ {
+ // TODO uncomment below to test the method and replace null with proper value
+ //var response = instance.TestAuthHttpBasic();
+ //Assert.IsType(response);
+ }
+ }
+}
diff --git a/samples/client/echo_api/csharp-restsharp/src/Org.OpenAPITools/Api/AuthApi.cs b/samples/client/echo_api/csharp-restsharp/src/Org.OpenAPITools/Api/AuthApi.cs
new file mode 100644
index 00000000000..0e631350b5f
--- /dev/null
+++ b/samples/client/echo_api/csharp-restsharp/src/Org.OpenAPITools/Api/AuthApi.cs
@@ -0,0 +1,341 @@
+/*
+ * Echo Server API
+ *
+ * Echo Server API
+ *
+ * The version of the OpenAPI document: 0.1.0
+ * Contact: team@openapitools.org
+ * Generated by: https://github.com/openapitools/openapi-generator.git
+ */
+
+
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Net;
+using System.Net.Mime;
+using Org.OpenAPITools.Client;
+
+namespace Org.OpenAPITools.Api
+{
+
+ ///
+ /// Represents a collection of functions to interact with the API endpoints
+ ///
+ public interface IAuthApiSync : IApiAccessor
+ {
+ #region Synchronous Operations
+ ///
+ /// To test HTTP basic authentication
+ ///
+ ///
+ /// To test HTTP basic authentication
+ ///
+ /// Thrown when fails to make API call
+ /// Index associated with the operation.
+ /// string
+ string TestAuthHttpBasic(int operationIndex = 0);
+
+ ///
+ /// To test HTTP basic authentication
+ ///
+ ///
+ /// To test HTTP basic authentication
+ ///
+ /// Thrown when fails to make API call
+ /// Index associated with the operation.
+ /// ApiResponse of string
+ ApiResponse TestAuthHttpBasicWithHttpInfo(int operationIndex = 0);
+ #endregion Synchronous Operations
+ }
+
+ ///
+ /// Represents a collection of functions to interact with the API endpoints
+ ///
+ public interface IAuthApiAsync : IApiAccessor
+ {
+ #region Asynchronous Operations
+ ///
+ /// To test HTTP basic authentication
+ ///
+ ///
+ /// To test HTTP basic authentication
+ ///
+ /// Thrown when fails to make API call
+ /// Index associated with the operation.
+ /// Cancellation Token to cancel the request.
+ /// Task of string
+ System.Threading.Tasks.Task TestAuthHttpBasicAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken));
+
+ ///
+ /// To test HTTP basic authentication
+ ///
+ ///
+ /// To test HTTP basic authentication
+ ///
+ /// Thrown when fails to make API call
+ /// Index associated with the operation.
+ /// Cancellation Token to cancel the request.
+ /// Task of ApiResponse (string)
+ System.Threading.Tasks.Task> TestAuthHttpBasicWithHttpInfoAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken));
+ #endregion Asynchronous Operations
+ }
+
+ ///
+ /// Represents a collection of functions to interact with the API endpoints
+ ///
+ public interface IAuthApi : IAuthApiSync, IAuthApiAsync
+ {
+
+ }
+
+ ///
+ /// Represents a collection of functions to interact with the API endpoints
+ ///
+ public partial class AuthApi : IAuthApi
+ {
+ private Org.OpenAPITools.Client.ExceptionFactory _exceptionFactory = (name, response) => null;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ ///
+ public AuthApi() : this((string)null)
+ {
+ }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ ///
+ public AuthApi(string basePath)
+ {
+ this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations(
+ Org.OpenAPITools.Client.GlobalConfiguration.Instance,
+ new Org.OpenAPITools.Client.Configuration { BasePath = basePath }
+ );
+ this.Client = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath);
+ this.AsynchronousClient = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath);
+ this.ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory;
+ }
+
+ ///
+ /// Initializes a new instance of the class
+ /// using Configuration object
+ ///
+ /// An instance of Configuration
+ ///
+ public AuthApi(Org.OpenAPITools.Client.Configuration configuration)
+ {
+ if (configuration == null) throw new ArgumentNullException("configuration");
+
+ this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations(
+ Org.OpenAPITools.Client.GlobalConfiguration.Instance,
+ configuration
+ );
+ this.Client = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath);
+ this.AsynchronousClient = new Org.OpenAPITools.Client.ApiClient(this.Configuration.BasePath);
+ ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory;
+ }
+
+ ///
+ /// Initializes a new instance of the class
+ /// using a Configuration object and client instance.
+ ///
+ /// The client interface for synchronous API access.
+ /// The client interface for asynchronous API access.
+ /// The configuration object.
+ public AuthApi(Org.OpenAPITools.Client.ISynchronousClient client, Org.OpenAPITools.Client.IAsynchronousClient asyncClient, Org.OpenAPITools.Client.IReadableConfiguration configuration)
+ {
+ if (client == null) throw new ArgumentNullException("client");
+ if (asyncClient == null) throw new ArgumentNullException("asyncClient");
+ if (configuration == null) throw new ArgumentNullException("configuration");
+
+ this.Client = client;
+ this.AsynchronousClient = asyncClient;
+ this.Configuration = configuration;
+ this.ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory;
+ }
+
+ ///
+ /// The client for accessing this underlying API asynchronously.
+ ///
+ public Org.OpenAPITools.Client.IAsynchronousClient AsynchronousClient { get; set; }
+
+ ///
+ /// The client for accessing this underlying API synchronously.
+ ///
+ public Org.OpenAPITools.Client.ISynchronousClient Client { get; set; }
+
+ ///
+ /// Gets the base path of the API client.
+ ///
+ /// The base path
+ public string GetBasePath()
+ {
+ return this.Configuration.BasePath;
+ }
+
+ ///
+ /// Gets or sets the configuration object
+ ///
+ /// An instance of the Configuration
+ public Org.OpenAPITools.Client.IReadableConfiguration Configuration { get; set; }
+
+ ///
+ /// Provides a factory method hook for the creation of exceptions.
+ ///
+ public Org.OpenAPITools.Client.ExceptionFactory ExceptionFactory
+ {
+ get
+ {
+ if (_exceptionFactory != null && _exceptionFactory.GetInvocationList().Length > 1)
+ {
+ throw new InvalidOperationException("Multicast delegate for ExceptionFactory is unsupported.");
+ }
+ return _exceptionFactory;
+ }
+ set { _exceptionFactory = value; }
+ }
+
+ ///
+ /// To test HTTP basic authentication To test HTTP basic authentication
+ ///
+ /// Thrown when fails to make API call
+ /// Index associated with the operation.
+ /// string
+ public string TestAuthHttpBasic(int operationIndex = 0)
+ {
+ Org.OpenAPITools.Client.ApiResponse localVarResponse = TestAuthHttpBasicWithHttpInfo();
+ return localVarResponse.Data;
+ }
+
+ ///
+ /// To test HTTP basic authentication To test HTTP basic authentication
+ ///
+ /// Thrown when fails to make API call
+ /// Index associated with the operation.
+ /// ApiResponse of string
+ public Org.OpenAPITools.Client.ApiResponse TestAuthHttpBasicWithHttpInfo(int operationIndex = 0)
+ {
+ Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions();
+
+ string[] _contentTypes = new string[] {
+ };
+
+ // to determine the Accept header
+ string[] _accepts = new string[] {
+ "text/plain"
+ };
+
+ 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.Operation = "AuthApi.TestAuthHttpBasic";
+ localVarRequestOptions.OperationIndex = operationIndex;
+
+ // authentication (http_auth) required
+ // http basic authentication required
+ if (!string.IsNullOrEmpty(this.Configuration.Username) || !string.IsNullOrEmpty(this.Configuration.Password) && !localVarRequestOptions.HeaderParameters.ContainsKey("Authorization"))
+ {
+ localVarRequestOptions.HeaderParameters.Add("Authorization", "Basic " + Org.OpenAPITools.Client.ClientUtils.Base64Encode(this.Configuration.Username + ":" + this.Configuration.Password));
+ }
+
+ // make the HTTP request
+ var localVarResponse = this.Client.Post("/auth/http/basic", localVarRequestOptions, this.Configuration);
+ if (this.ExceptionFactory != null)
+ {
+ Exception _exception = this.ExceptionFactory("TestAuthHttpBasic", localVarResponse);
+ if (_exception != null)
+ {
+ throw _exception;
+ }
+ }
+
+ return localVarResponse;
+ }
+
+ ///
+ /// To test HTTP basic authentication To test HTTP basic authentication
+ ///
+ /// Thrown when fails to make API call
+ /// Index associated with the operation.
+ /// Cancellation Token to cancel the request.
+ /// Task of string
+ public async System.Threading.Tasks.Task TestAuthHttpBasicAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
+ {
+ Org.OpenAPITools.Client.ApiResponse localVarResponse = await TestAuthHttpBasicWithHttpInfoAsync(operationIndex, cancellationToken).ConfigureAwait(false);
+ return localVarResponse.Data;
+ }
+
+ ///
+ /// To test HTTP basic authentication To test HTTP basic authentication
+ ///
+ /// Thrown when fails to make API call
+ /// Index associated with the operation.
+ /// Cancellation Token to cancel the request.
+ /// Task of ApiResponse (string)
+ public async System.Threading.Tasks.Task> TestAuthHttpBasicWithHttpInfoAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
+ {
+
+ Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions();
+
+ string[] _contentTypes = new string[] {
+ };
+
+ // to determine the Accept header
+ string[] _accepts = new string[] {
+ "text/plain"
+ };
+
+ 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.Operation = "AuthApi.TestAuthHttpBasic";
+ localVarRequestOptions.OperationIndex = operationIndex;
+
+ // authentication (http_auth) required
+ // http basic authentication required
+ if (!string.IsNullOrEmpty(this.Configuration.Username) || !string.IsNullOrEmpty(this.Configuration.Password) && !localVarRequestOptions.HeaderParameters.ContainsKey("Authorization"))
+ {
+ localVarRequestOptions.HeaderParameters.Add("Authorization", "Basic " + Org.OpenAPITools.Client.ClientUtils.Base64Encode(this.Configuration.Username + ":" + this.Configuration.Password));
+ }
+
+ // make the HTTP request
+ var localVarResponse = await this.AsynchronousClient.PostAsync("/auth/http/basic", localVarRequestOptions, this.Configuration, cancellationToken).ConfigureAwait(false);
+
+ if (this.ExceptionFactory != null)
+ {
+ Exception _exception = this.ExceptionFactory("TestAuthHttpBasic", localVarResponse);
+ if (_exception != null)
+ {
+ throw _exception;
+ }
+ }
+
+ return localVarResponse;
+ }
+
+ }
+}
diff --git a/samples/client/echo_api/java/apache-httpclient/.openapi-generator/FILES b/samples/client/echo_api/java/apache-httpclient/.openapi-generator/FILES
index 29a6dcea8fd..8add1570ae0 100644
--- a/samples/client/echo_api/java/apache-httpclient/.openapi-generator/FILES
+++ b/samples/client/echo_api/java/apache-httpclient/.openapi-generator/FILES
@@ -5,6 +5,7 @@ README.md
api/openapi.yaml
build.gradle
build.sbt
+docs/AuthApi.md
docs/Bird.md
docs/BodyApi.md
docs/Category.md
@@ -39,6 +40,7 @@ src/main/java/org/openapitools/client/RFC3339DateFormat.java
src/main/java/org/openapitools/client/ServerConfiguration.java
src/main/java/org/openapitools/client/ServerVariable.java
src/main/java/org/openapitools/client/StringUtil.java
+src/main/java/org/openapitools/client/api/AuthApi.java
src/main/java/org/openapitools/client/api/BodyApi.java
src/main/java/org/openapitools/client/api/FormApi.java
src/main/java/org/openapitools/client/api/HeaderApi.java
diff --git a/samples/client/echo_api/java/apache-httpclient/README.md b/samples/client/echo_api/java/apache-httpclient/README.md
index b3d34287c2e..bdd48dc7040 100644
--- a/samples/client/echo_api/java/apache-httpclient/README.md
+++ b/samples/client/echo_api/java/apache-httpclient/README.md
@@ -75,20 +75,25 @@ Please follow the [installation](#installation) instruction and execute the foll
import org.openapitools.client.*;
import org.openapitools.client.auth.*;
import org.openapitools.client.model.*;
-import org.openapitools.client.api.BodyApi;
+import org.openapitools.client.api.AuthApi;
-public class BodyApiExample {
+public class AuthApiExample {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("http://localhost:3000");
- BodyApi apiInstance = new BodyApi(defaultClient);
+ // Configure HTTP basic authorization: http_auth
+ HttpBasicAuth http_auth = (HttpBasicAuth) defaultClient.getAuthentication("http_auth");
+ http_auth.setUsername("YOUR USERNAME");
+ http_auth.setPassword("YOUR PASSWORD");
+
+ AuthApi apiInstance = new AuthApi(defaultClient);
try {
- File result = apiInstance.testBinaryGif();
+ String result = apiInstance.testAuthHttpBasic();
System.out.println(result);
} catch (ApiException e) {
- System.err.println("Exception when calling BodyApi#testBinaryGif");
+ System.err.println("Exception when calling AuthApi#testAuthHttpBasic");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
@@ -105,6 +110,7 @@ All URIs are relative to *http://localhost:3000*
Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
+*AuthApi* | [**testAuthHttpBasic**](docs/AuthApi.md#testAuthHttpBasic) | **POST** /auth/http/basic | To test HTTP basic authentication
*BodyApi* | [**testBinaryGif**](docs/BodyApi.md#testBinaryGif) | **POST** /binary/gif | Test binary (gif) response body
*BodyApi* | [**testBodyApplicationOctetstreamBinary**](docs/BodyApi.md#testBodyApplicationOctetstreamBinary) | **POST** /body/application/octetstream/binary | Test body parameter(s)
*BodyApi* | [**testBodyMultipartFormdataArrayOfBinary**](docs/BodyApi.md#testBodyMultipartFormdataArrayOfBinary) | **POST** /body/application/octetstream/array_of_binary | Test array of binary in multipart mime
@@ -144,7 +150,13 @@ Class | Method | HTTP request | Description
## Documentation for Authorization
-Endpoints do not require authorization.
+
+Authentication schemes defined for the API:
+
+### http_auth
+
+
+- **Type**: HTTP basic authentication
## Recommendation
diff --git a/samples/client/echo_api/java/apache-httpclient/api/openapi.yaml b/samples/client/echo_api/java/apache-httpclient/api/openapi.yaml
index a32ee32bd49..36261c0bd77 100644
--- a/samples/client/echo_api/java/apache-httpclient/api/openapi.yaml
+++ b/samples/client/echo_api/java/apache-httpclient/api/openapi.yaml
@@ -469,6 +469,23 @@ paths:
- body
x-content-type: multipart/form-data
x-accepts: text/plain
+ /auth/http/basic:
+ post:
+ description: To test HTTP basic authentication
+ operationId: test/auth/http/basic
+ responses:
+ "200":
+ content:
+ text/plain:
+ schema:
+ type: string
+ description: Successful operation
+ security:
+ - http_auth: []
+ summary: To test HTTP basic authentication
+ tags:
+ - auth
+ x-accepts: text/plain
components:
requestBodies:
Pet:
@@ -729,4 +746,8 @@ components:
required:
- files
type: object
+ securitySchemes:
+ http_auth:
+ scheme: basic
+ type: http
diff --git a/samples/client/echo_api/java/apache-httpclient/docs/AuthApi.md b/samples/client/echo_api/java/apache-httpclient/docs/AuthApi.md
new file mode 100644
index 00000000000..508c4c555cb
--- /dev/null
+++ b/samples/client/echo_api/java/apache-httpclient/docs/AuthApi.md
@@ -0,0 +1,77 @@
+# AuthApi
+
+All URIs are relative to *http://localhost:3000*
+
+| Method | HTTP request | Description |
+|------------- | ------------- | -------------|
+| [**testAuthHttpBasic**](AuthApi.md#testAuthHttpBasic) | **POST** /auth/http/basic | To test HTTP basic authentication |
+
+
+
+## testAuthHttpBasic
+
+> String testAuthHttpBasic()
+
+To test HTTP basic authentication
+
+To test HTTP basic authentication
+
+### Example
+
+```java
+// Import classes:
+import org.openapitools.client.ApiClient;
+import org.openapitools.client.ApiException;
+import org.openapitools.client.Configuration;
+import org.openapitools.client.auth.*;
+import org.openapitools.client.models.*;
+import org.openapitools.client.api.AuthApi;
+
+public class Example {
+ public static void main(String[] args) {
+ ApiClient defaultClient = Configuration.getDefaultApiClient();
+ defaultClient.setBasePath("http://localhost:3000");
+
+ // Configure HTTP basic authorization: http_auth
+ HttpBasicAuth http_auth = (HttpBasicAuth) defaultClient.getAuthentication("http_auth");
+ http_auth.setUsername("YOUR USERNAME");
+ http_auth.setPassword("YOUR PASSWORD");
+
+ AuthApi apiInstance = new AuthApi(defaultClient);
+ try {
+ String result = apiInstance.testAuthHttpBasic();
+ System.out.println(result);
+ } catch (ApiException e) {
+ System.err.println("Exception when calling AuthApi#testAuthHttpBasic");
+ System.err.println("Status code: " + e.getCode());
+ System.err.println("Reason: " + e.getResponseBody());
+ System.err.println("Response headers: " + e.getResponseHeaders());
+ e.printStackTrace();
+ }
+ }
+}
+```
+
+### Parameters
+
+This endpoint does not need any parameter.
+
+### Return type
+
+**String**
+
+### Authorization
+
+[http_auth](../README.md#http_auth)
+
+### HTTP request headers
+
+- **Content-Type**: Not defined
+- **Accept**: text/plain
+
+
+### HTTP response details
+| Status code | Description | Response headers |
+|-------------|-------------|------------------|
+| **200** | Successful operation | - |
+
diff --git a/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/ApiClient.java b/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/ApiClient.java
index 1f9408a4110..71e2d4d1ec1 100644
--- a/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/ApiClient.java
+++ b/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/ApiClient.java
@@ -76,6 +76,7 @@ import java.net.URI;
import java.text.DateFormat;
import org.openapitools.client.auth.Authentication;
+import org.openapitools.client.auth.HttpBasicAuth;
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
public class ApiClient extends JavaTimeFormatter {
@@ -127,6 +128,7 @@ public class ApiClient extends JavaTimeFormatter {
// Setup authentications (key: authentication name, value: authentication).
authentications = new HashMap();
+ authentications.put("http_auth", new HttpBasicAuth());
// Prevent the authentications from being modified.
authentications = Collections.unmodifiableMap(authentications);
@@ -287,6 +289,36 @@ public class ApiClient extends JavaTimeFormatter {
}
+ /**
+ * Helper method to set username for the first HTTP basic authentication.
+ * @param username Username
+ * @return API client
+ */
+ public ApiClient setUsername(String username) {
+ for (Authentication auth : authentications.values()) {
+ if (auth instanceof HttpBasicAuth) {
+ ((HttpBasicAuth) auth).setUsername(username);
+ return this;
+ }
+ }
+ throw new RuntimeException("No HTTP basic authentication configured!");
+ }
+
+ /**
+ * Helper method to set password for the first HTTP basic authentication.
+ * @param password Password
+ * @return API client
+ */
+ public ApiClient setPassword(String password) {
+ for (Authentication auth : authentications.values()) {
+ if (auth instanceof HttpBasicAuth) {
+ ((HttpBasicAuth) auth).setPassword(password);
+ return this;
+ }
+ }
+ throw new RuntimeException("No HTTP basic authentication configured!");
+ }
+
diff --git a/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/api/AuthApi.java b/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/api/AuthApi.java
new file mode 100644
index 00000000000..f709addc0f6
--- /dev/null
+++ b/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/api/AuthApi.java
@@ -0,0 +1,120 @@
+/*
+ * Echo Server API
+ * Echo Server API
+ *
+ * The version of the OpenAPI document: 0.1.0
+ * Contact: team@openapitools.org
+ *
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * https://openapi-generator.tech
+ * Do not edit the class manually.
+ */
+
+package org.openapitools.client.api;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+
+import org.openapitools.client.ApiException;
+import org.openapitools.client.ApiClient;
+import org.openapitools.client.Configuration;
+import org.openapitools.client.Pair;
+
+
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.StringJoiner;
+
+@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
+public class AuthApi {
+
+
+ private ApiClient apiClient;
+
+ public AuthApi() {
+ this(Configuration.getDefaultApiClient());
+ }
+
+ public AuthApi(ApiClient apiClient) {
+ this.apiClient = apiClient;
+ }
+
+ public ApiClient getApiClient() {
+ return apiClient;
+ }
+
+ public void setApiClient(ApiClient apiClient) {
+ this.apiClient = apiClient;
+ }
+
+ /**
+ * To test HTTP basic authentication
+ * To test HTTP basic authentication
+ * @return String
+ * @throws ApiException if fails to make API call
+ */
+ public String testAuthHttpBasic() throws ApiException {
+ return this.testAuthHttpBasic(Collections.emptyMap());
+ }
+
+
+ /**
+ * To test HTTP basic authentication
+ * To test HTTP basic authentication
+ * @param additionalHeaders additionalHeaders for this call
+ * @return String
+ * @throws ApiException if fails to make API call
+ */
+ public String testAuthHttpBasic(Map additionalHeaders) throws ApiException {
+ Object localVarPostBody = null;
+
+ // create path and map variables
+ String localVarPath = "/auth/http/basic";
+
+ StringJoiner localVarQueryStringJoiner = new StringJoiner("&");
+ String localVarQueryParameterBaseName;
+ List localVarQueryParams = new ArrayList();
+ List localVarCollectionQueryParams = new ArrayList();
+ Map localVarHeaderParams = new HashMap();
+ Map localVarCookieParams = new HashMap();
+ Map localVarFormParams = new HashMap();
+
+
+ localVarHeaderParams.putAll(additionalHeaders);
+
+
+
+ final String[] localVarAccepts = {
+ "text/plain"
+ };
+ final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
+
+ final String[] localVarContentTypes = {
+
+ };
+ final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
+
+ String[] localVarAuthNames = new String[] { "http_auth" };
+
+ TypeReference localVarReturnType = new TypeReference() {};
+ return apiClient.invokeAPI(
+ localVarPath,
+ "POST",
+ localVarQueryParams,
+ localVarCollectionQueryParams,
+ localVarQueryStringJoiner.toString(),
+ localVarPostBody,
+ localVarHeaderParams,
+ localVarCookieParams,
+ localVarFormParams,
+ localVarAccept,
+ localVarContentType,
+ localVarAuthNames,
+ localVarReturnType
+ );
+ }
+
+}
diff --git a/samples/client/echo_api/java/apache-httpclient/src/test/java/org/openapitools/client/api/AuthApiTest.java b/samples/client/echo_api/java/apache-httpclient/src/test/java/org/openapitools/client/api/AuthApiTest.java
new file mode 100644
index 00000000000..ac4fa203fbc
--- /dev/null
+++ b/samples/client/echo_api/java/apache-httpclient/src/test/java/org/openapitools/client/api/AuthApiTest.java
@@ -0,0 +1,50 @@
+/*
+ * Echo Server API
+ * Echo Server API
+ *
+ * The version of the OpenAPI document: 0.1.0
+ * Contact: team@openapitools.org
+ *
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * https://openapi-generator.tech
+ * Do not edit the class manually.
+ */
+
+
+package org.openapitools.client.api;
+
+import org.openapitools.client.ApiException;
+import org.junit.Test;
+import org.junit.Ignore;
+import org.junit.Assert;
+
+import java.time.LocalDate;
+import java.time.OffsetDateTime;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * API tests for AuthApi
+ */
+@Ignore
+public class AuthApiTest {
+
+ private final AuthApi api = new AuthApi();
+
+ /**
+ * To test HTTP basic authentication
+ *
+ * To test HTTP basic authentication
+ *
+ * @throws ApiException
+ * if the Api call fails
+ */
+ @Test
+ public void testAuthHttpBasicTest() throws ApiException {
+ String response = api.testAuthHttpBasic();
+
+ // TODO: test validations
+ }
+}
diff --git a/samples/client/echo_api/java/feign-gson/.openapi-generator/FILES b/samples/client/echo_api/java/feign-gson/.openapi-generator/FILES
index 44d56af6f1f..d47a3b59b23 100644
--- a/samples/client/echo_api/java/feign-gson/.openapi-generator/FILES
+++ b/samples/client/echo_api/java/feign-gson/.openapi-generator/FILES
@@ -19,6 +19,7 @@ src/main/java/org/openapitools/client/EncodingUtils.java
src/main/java/org/openapitools/client/ServerConfiguration.java
src/main/java/org/openapitools/client/ServerVariable.java
src/main/java/org/openapitools/client/StringUtil.java
+src/main/java/org/openapitools/client/api/AuthApi.java
src/main/java/org/openapitools/client/api/BodyApi.java
src/main/java/org/openapitools/client/api/FormApi.java
src/main/java/org/openapitools/client/api/HeaderApi.java
diff --git a/samples/client/echo_api/java/feign-gson/api/openapi.yaml b/samples/client/echo_api/java/feign-gson/api/openapi.yaml
index a32ee32bd49..36261c0bd77 100644
--- a/samples/client/echo_api/java/feign-gson/api/openapi.yaml
+++ b/samples/client/echo_api/java/feign-gson/api/openapi.yaml
@@ -469,6 +469,23 @@ paths:
- body
x-content-type: multipart/form-data
x-accepts: text/plain
+ /auth/http/basic:
+ post:
+ description: To test HTTP basic authentication
+ operationId: test/auth/http/basic
+ responses:
+ "200":
+ content:
+ text/plain:
+ schema:
+ type: string
+ description: Successful operation
+ security:
+ - http_auth: []
+ summary: To test HTTP basic authentication
+ tags:
+ - auth
+ x-accepts: text/plain
components:
requestBodies:
Pet:
@@ -729,4 +746,8 @@ components:
required:
- files
type: object
+ securitySchemes:
+ http_auth:
+ scheme: basic
+ type: http
diff --git a/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/ApiClient.java b/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/ApiClient.java
index b122f0e05eb..9184a09164c 100644
--- a/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/ApiClient.java
+++ b/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/ApiClient.java
@@ -39,7 +39,15 @@ public class ApiClient {
this();
for(String authName : authNames) {
log.log(Level.FINE, "Creating authentication {0}", authName);
- throw new RuntimeException("auth name \"" + authName + "\" not found in available auth names");
+ RequestInterceptor auth = null;
+ if ("http_auth".equals(authName)) {
+ auth = new HttpBasicAuth();
+ } else {
+ throw new RuntimeException("auth name \"" + authName + "\" not found in available auth names");
+ }
+ if (auth != null) {
+ addAuthorization(authName, auth);
+ }
}
}
diff --git a/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/api/AuthApi.java b/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/api/AuthApi.java
new file mode 100644
index 00000000000..2c2524805f0
--- /dev/null
+++ b/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/api/AuthApi.java
@@ -0,0 +1,42 @@
+package org.openapitools.client.api;
+
+import org.openapitools.client.ApiClient;
+import org.openapitools.client.EncodingUtils;
+import org.openapitools.client.model.ApiResponse;
+
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import feign.*;
+
+@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
+public interface AuthApi extends ApiClient.Api {
+
+
+ /**
+ * To test HTTP basic authentication
+ * To test HTTP basic authentication
+ * @return String
+ */
+ @RequestLine("POST /auth/http/basic")
+ @Headers({
+ "Accept: text/plain",
+ })
+ String testAuthHttpBasic();
+
+ /**
+ * To test HTTP basic authentication
+ * Similar to testAuthHttpBasic
but it also returns the http response headers .
+ * To test HTTP basic authentication
+ * @return A ApiResponse that wraps the response boyd and the http headers.
+ */
+ @RequestLine("POST /auth/http/basic")
+ @Headers({
+ "Accept: text/plain",
+ })
+ ApiResponse testAuthHttpBasicWithHttpInfo();
+
+
+}
diff --git a/samples/client/echo_api/java/feign-gson/src/test/java/org/openapitools/client/api/AuthApiTest.java b/samples/client/echo_api/java/feign-gson/src/test/java/org/openapitools/client/api/AuthApiTest.java
new file mode 100644
index 00000000000..2c33d9c32dc
--- /dev/null
+++ b/samples/client/echo_api/java/feign-gson/src/test/java/org/openapitools/client/api/AuthApiTest.java
@@ -0,0 +1,40 @@
+package org.openapitools.client.api;
+
+import org.openapitools.client.ApiClient;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.BeforeEach;
+
+import java.time.LocalDate;
+import java.time.OffsetDateTime;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * API tests for AuthApi
+ */
+class AuthApiTest {
+
+ private AuthApi api;
+
+ @BeforeEach
+ public void setup() {
+ api = new ApiClient().buildClient(AuthApi.class);
+ }
+
+
+ /**
+ * To test HTTP basic authentication
+ *
+ * To test HTTP basic authentication
+ */
+ @Test
+ void testAuthHttpBasicTest() {
+ // String response = api.testAuthHttpBasic();
+
+ // TODO: test validations
+ }
+
+
+}
diff --git a/samples/client/echo_api/java/native/.openapi-generator/FILES b/samples/client/echo_api/java/native/.openapi-generator/FILES
index 84c51355f68..a8e8a3b8cc8 100644
--- a/samples/client/echo_api/java/native/.openapi-generator/FILES
+++ b/samples/client/echo_api/java/native/.openapi-generator/FILES
@@ -5,6 +5,7 @@ README.md
api/openapi.yaml
build.gradle
build.sbt
+docs/AuthApi.md
docs/Bird.md
docs/BodyApi.md
docs/Category.md
@@ -39,6 +40,7 @@ src/main/java/org/openapitools/client/Pair.java
src/main/java/org/openapitools/client/RFC3339DateFormat.java
src/main/java/org/openapitools/client/ServerConfiguration.java
src/main/java/org/openapitools/client/ServerVariable.java
+src/main/java/org/openapitools/client/api/AuthApi.java
src/main/java/org/openapitools/client/api/BodyApi.java
src/main/java/org/openapitools/client/api/FormApi.java
src/main/java/org/openapitools/client/api/HeaderApi.java
diff --git a/samples/client/echo_api/java/native/README.md b/samples/client/echo_api/java/native/README.md
index 1184f9f739c..9a5ce3e476c 100644
--- a/samples/client/echo_api/java/native/README.md
+++ b/samples/client/echo_api/java/native/README.md
@@ -74,20 +74,20 @@ Please follow the [installation](#installation) instruction and execute the foll
import org.openapitools.client.*;
import org.openapitools.client.model.*;
-import org.openapitools.client.api.BodyApi;
+import org.openapitools.client.api.AuthApi;
-public class BodyApiExample {
+public class AuthApiExample {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
// Configure clients using the `defaultClient` object, such as
// overriding the host and port, timeout, etc.
- BodyApi apiInstance = new BodyApi(defaultClient);
+ AuthApi apiInstance = new AuthApi(defaultClient);
try {
- File result = apiInstance.testBinaryGif();
+ String result = apiInstance.testAuthHttpBasic();
System.out.println(result);
} catch (ApiException e) {
- System.err.println("Exception when calling BodyApi#testBinaryGif");
+ System.err.println("Exception when calling AuthApi#testAuthHttpBasic");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
@@ -104,6 +104,8 @@ All URIs are relative to *http://localhost:3000*
Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
+*AuthApi* | [**testAuthHttpBasic**](docs/AuthApi.md#testAuthHttpBasic) | **POST** /auth/http/basic | To test HTTP basic authentication
+*AuthApi* | [**testAuthHttpBasicWithHttpInfo**](docs/AuthApi.md#testAuthHttpBasicWithHttpInfo) | **POST** /auth/http/basic | To test HTTP basic authentication
*BodyApi* | [**testBinaryGif**](docs/BodyApi.md#testBinaryGif) | **POST** /binary/gif | Test binary (gif) response body
*BodyApi* | [**testBinaryGifWithHttpInfo**](docs/BodyApi.md#testBinaryGifWithHttpInfo) | **POST** /binary/gif | Test binary (gif) response body
*BodyApi* | [**testBodyApplicationOctetstreamBinary**](docs/BodyApi.md#testBodyApplicationOctetstreamBinary) | **POST** /body/application/octetstream/binary | Test body parameter(s)
@@ -162,7 +164,13 @@ Class | Method | HTTP request | Description
## Documentation for Authorization
-Endpoints do not require authorization.
+
+Authentication schemes defined for the API:
+
+### http_auth
+
+
+- **Type**: HTTP basic authentication
## Recommendation
diff --git a/samples/client/echo_api/java/native/api/openapi.yaml b/samples/client/echo_api/java/native/api/openapi.yaml
index a32ee32bd49..36261c0bd77 100644
--- a/samples/client/echo_api/java/native/api/openapi.yaml
+++ b/samples/client/echo_api/java/native/api/openapi.yaml
@@ -469,6 +469,23 @@ paths:
- body
x-content-type: multipart/form-data
x-accepts: text/plain
+ /auth/http/basic:
+ post:
+ description: To test HTTP basic authentication
+ operationId: test/auth/http/basic
+ responses:
+ "200":
+ content:
+ text/plain:
+ schema:
+ type: string
+ description: Successful operation
+ security:
+ - http_auth: []
+ summary: To test HTTP basic authentication
+ tags:
+ - auth
+ x-accepts: text/plain
components:
requestBodies:
Pet:
@@ -729,4 +746,8 @@ components:
required:
- files
type: object
+ securitySchemes:
+ http_auth:
+ scheme: basic
+ type: http
diff --git a/samples/client/echo_api/java/native/docs/AuthApi.md b/samples/client/echo_api/java/native/docs/AuthApi.md
new file mode 100644
index 00000000000..6d679e7bf94
--- /dev/null
+++ b/samples/client/echo_api/java/native/docs/AuthApi.md
@@ -0,0 +1,148 @@
+# AuthApi
+
+All URIs are relative to *http://localhost:3000*
+
+| Method | HTTP request | Description |
+|------------- | ------------- | -------------|
+| [**testAuthHttpBasic**](AuthApi.md#testAuthHttpBasic) | **POST** /auth/http/basic | To test HTTP basic authentication |
+| [**testAuthHttpBasicWithHttpInfo**](AuthApi.md#testAuthHttpBasicWithHttpInfo) | **POST** /auth/http/basic | To test HTTP basic authentication |
+
+
+
+## testAuthHttpBasic
+
+> String testAuthHttpBasic()
+
+To test HTTP basic authentication
+
+To test HTTP basic authentication
+
+### Example
+
+```java
+// Import classes:
+import org.openapitools.client.ApiClient;
+import org.openapitools.client.ApiException;
+import org.openapitools.client.Configuration;
+import org.openapitools.client.auth.*;
+import org.openapitools.client.models.*;
+import org.openapitools.client.api.AuthApi;
+
+public class Example {
+ public static void main(String[] args) {
+ ApiClient defaultClient = Configuration.getDefaultApiClient();
+ defaultClient.setBasePath("http://localhost:3000");
+
+ // Configure HTTP basic authorization: http_auth
+ HttpBasicAuth http_auth = (HttpBasicAuth) defaultClient.getAuthentication("http_auth");
+ http_auth.setUsername("YOUR USERNAME");
+ http_auth.setPassword("YOUR PASSWORD");
+
+ AuthApi apiInstance = new AuthApi(defaultClient);
+ try {
+ String result = apiInstance.testAuthHttpBasic();
+ System.out.println(result);
+ } catch (ApiException e) {
+ System.err.println("Exception when calling AuthApi#testAuthHttpBasic");
+ System.err.println("Status code: " + e.getCode());
+ System.err.println("Reason: " + e.getResponseBody());
+ System.err.println("Response headers: " + e.getResponseHeaders());
+ e.printStackTrace();
+ }
+ }
+}
+```
+
+### Parameters
+
+This endpoint does not need any parameter.
+
+### Return type
+
+**String**
+
+
+### Authorization
+
+[http_auth](../README.md#http_auth)
+
+### HTTP request headers
+
+- **Content-Type**: Not defined
+- **Accept**: text/plain
+
+### HTTP response details
+| Status code | Description | Response headers |
+|-------------|-------------|------------------|
+| **200** | Successful operation | - |
+
+## testAuthHttpBasicWithHttpInfo
+
+> ApiResponse testAuthHttpBasic testAuthHttpBasicWithHttpInfo()
+
+To test HTTP basic authentication
+
+To test HTTP basic authentication
+
+### Example
+
+```java
+// Import classes:
+import org.openapitools.client.ApiClient;
+import org.openapitools.client.ApiException;
+import org.openapitools.client.ApiResponse;
+import org.openapitools.client.Configuration;
+import org.openapitools.client.auth.*;
+import org.openapitools.client.models.*;
+import org.openapitools.client.api.AuthApi;
+
+public class Example {
+ public static void main(String[] args) {
+ ApiClient defaultClient = Configuration.getDefaultApiClient();
+ defaultClient.setBasePath("http://localhost:3000");
+
+ // Configure HTTP basic authorization: http_auth
+ HttpBasicAuth http_auth = (HttpBasicAuth) defaultClient.getAuthentication("http_auth");
+ http_auth.setUsername("YOUR USERNAME");
+ http_auth.setPassword("YOUR PASSWORD");
+
+ AuthApi apiInstance = new AuthApi(defaultClient);
+ try {
+ ApiResponse response = apiInstance.testAuthHttpBasicWithHttpInfo();
+ System.out.println("Status code: " + response.getStatusCode());
+ System.out.println("Response headers: " + response.getHeaders());
+ System.out.println("Response body: " + response.getData());
+ } catch (ApiException e) {
+ System.err.println("Exception when calling AuthApi#testAuthHttpBasic");
+ System.err.println("Status code: " + e.getCode());
+ System.err.println("Response headers: " + e.getResponseHeaders());
+ System.err.println("Reason: " + e.getResponseBody());
+ e.printStackTrace();
+ }
+ }
+}
+```
+
+### Parameters
+
+This endpoint does not need any parameter.
+
+### Return type
+
+ApiResponse<**String**>
+
+
+### Authorization
+
+[http_auth](../README.md#http_auth)
+
+### HTTP request headers
+
+- **Content-Type**: Not defined
+- **Accept**: text/plain
+
+### HTTP response details
+| Status code | Description | Response headers |
+|-------------|-------------|------------------|
+| **200** | Successful operation | - |
+
diff --git a/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/api/AuthApi.java b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/api/AuthApi.java
new file mode 100644
index 00000000000..53087270472
--- /dev/null
+++ b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/api/AuthApi.java
@@ -0,0 +1,156 @@
+/*
+ * Echo Server API
+ * Echo Server API
+ *
+ * The version of the OpenAPI document: 0.1.0
+ * Contact: team@openapitools.org
+ *
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * https://openapi-generator.tech
+ * Do not edit the class manually.
+ */
+
+package org.openapitools.client.api;
+
+import org.openapitools.client.ApiClient;
+import org.openapitools.client.ApiException;
+import org.openapitools.client.ApiResponse;
+import org.openapitools.client.Pair;
+
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+import java.io.InputStream;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.net.http.HttpRequest;
+import java.nio.channels.Channels;
+import java.nio.channels.Pipe;
+import java.net.URI;
+import java.net.http.HttpClient;
+import java.net.http.HttpRequest;
+import java.net.http.HttpResponse;
+import java.time.Duration;
+
+import java.util.ArrayList;
+import java.util.StringJoiner;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.function.Consumer;
+
+@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
+public class AuthApi {
+ private final HttpClient memberVarHttpClient;
+ private final ObjectMapper memberVarObjectMapper;
+ private final String memberVarBaseUri;
+ private final Consumer memberVarInterceptor;
+ private final Duration memberVarReadTimeout;
+ private final Consumer> memberVarResponseInterceptor;
+ private final Consumer> memberVarAsyncResponseInterceptor;
+
+ public AuthApi() {
+ this(new ApiClient());
+ }
+
+ public AuthApi(ApiClient apiClient) {
+ memberVarHttpClient = apiClient.getHttpClient();
+ memberVarObjectMapper = apiClient.getObjectMapper();
+ memberVarBaseUri = apiClient.getBaseUri();
+ memberVarInterceptor = apiClient.getRequestInterceptor();
+ memberVarReadTimeout = apiClient.getReadTimeout();
+ memberVarResponseInterceptor = apiClient.getResponseInterceptor();
+ memberVarAsyncResponseInterceptor = apiClient.getAsyncResponseInterceptor();
+ }
+
+ protected ApiException getApiException(String operationId, HttpResponse response) throws IOException {
+ String body = response.body() == null ? null : new String(response.body().readAllBytes());
+ String message = formatExceptionMessage(operationId, response.statusCode(), body);
+ return new ApiException(response.statusCode(), message, response.headers(), body);
+ }
+
+ private String formatExceptionMessage(String operationId, int statusCode, String body) {
+ if (body == null || body.isEmpty()) {
+ body = "[no body]";
+ }
+ return operationId + " call failed with: " + statusCode + " - " + body;
+ }
+
+ /**
+ * To test HTTP basic authentication
+ * To test HTTP basic authentication
+ * @return String
+ * @throws ApiException if fails to make API call
+ */
+ public String testAuthHttpBasic() throws ApiException {
+ ApiResponse localVarResponse = testAuthHttpBasicWithHttpInfo();
+ return localVarResponse.getData();
+ }
+
+ /**
+ * To test HTTP basic authentication
+ * To test HTTP basic authentication
+ * @return ApiResponse<String>
+ * @throws ApiException if fails to make API call
+ */
+ public ApiResponse testAuthHttpBasicWithHttpInfo() throws ApiException {
+ HttpRequest.Builder localVarRequestBuilder = testAuthHttpBasicRequestBuilder();
+ try {
+ HttpResponse localVarResponse = memberVarHttpClient.send(
+ localVarRequestBuilder.build(),
+ HttpResponse.BodyHandlers.ofInputStream());
+ if (memberVarResponseInterceptor != null) {
+ memberVarResponseInterceptor.accept(localVarResponse);
+ }
+ try {
+ if (localVarResponse.statusCode()/ 100 != 2) {
+ throw getApiException("testAuthHttpBasic", localVarResponse);
+ }
+ // for plain text response
+ if (localVarResponse.headers().map().containsKey("Content-Type") &&
+ "text/plain".equalsIgnoreCase(localVarResponse.headers().map().get("Content-Type").get(0).split(";")[0].trim())) {
+ java.util.Scanner s = new java.util.Scanner(localVarResponse.body()).useDelimiter("\\A");
+ String responseBodyText = s.hasNext() ? s.next() : "";
+ return new ApiResponse(
+ localVarResponse.statusCode(),
+ localVarResponse.headers().map(),
+ responseBodyText
+ );
+ } else {
+ throw new RuntimeException("Error! The response Content-Type is supposed to be `text/plain` but it's not: " + localVarResponse);
+ }
+ } finally {
+ }
+ } catch (IOException e) {
+ throw new ApiException(e);
+ }
+ catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ throw new ApiException(e);
+ }
+ }
+
+ private HttpRequest.Builder testAuthHttpBasicRequestBuilder() throws ApiException {
+
+ HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder();
+
+ String localVarPath = "/auth/http/basic";
+
+ localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath));
+
+ localVarRequestBuilder.header("Accept", "text/plain");
+
+ localVarRequestBuilder.method("POST", HttpRequest.BodyPublishers.noBody());
+ if (memberVarReadTimeout != null) {
+ localVarRequestBuilder.timeout(memberVarReadTimeout);
+ }
+ if (memberVarInterceptor != null) {
+ memberVarInterceptor.accept(localVarRequestBuilder);
+ }
+ return localVarRequestBuilder;
+ }
+}
diff --git a/samples/client/echo_api/java/native/src/test/java/org/openapitools/client/api/AuthApiTest.java b/samples/client/echo_api/java/native/src/test/java/org/openapitools/client/api/AuthApiTest.java
new file mode 100644
index 00000000000..3e6f3a79b75
--- /dev/null
+++ b/samples/client/echo_api/java/native/src/test/java/org/openapitools/client/api/AuthApiTest.java
@@ -0,0 +1,52 @@
+/*
+ * Echo Server API
+ * Echo Server API
+ *
+ * The version of the OpenAPI document: 0.1.0
+ * Contact: team@openapitools.org
+ *
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * https://openapi-generator.tech
+ * Do not edit the class manually.
+ */
+
+
+package org.openapitools.client.api;
+
+import org.openapitools.client.ApiException;
+import org.junit.Test;
+import org.junit.Ignore;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+
+/**
+ * API tests for AuthApi
+ */
+@Ignore
+public class AuthApiTest {
+
+ private final AuthApi api = new AuthApi();
+
+
+ /**
+ * To test HTTP basic authentication
+ *
+ * To test HTTP basic authentication
+ *
+ * @throws ApiException
+ * if the Api call fails
+ */
+ @Test
+ public void testAuthHttpBasicTest() throws ApiException {
+ String response =
+ api.testAuthHttpBasic();
+
+ // TODO: test validations
+ }
+
+}
diff --git a/samples/client/echo_api/java/okhttp-gson/.openapi-generator/FILES b/samples/client/echo_api/java/okhttp-gson/.openapi-generator/FILES
index d42a72b3684..28fb8df54a4 100644
--- a/samples/client/echo_api/java/okhttp-gson/.openapi-generator/FILES
+++ b/samples/client/echo_api/java/okhttp-gson/.openapi-generator/FILES
@@ -5,6 +5,7 @@ README.md
api/openapi.yaml
build.gradle
build.sbt
+docs/AuthApi.md
docs/Bird.md
docs/BodyApi.md
docs/Category.md
@@ -43,6 +44,7 @@ src/main/java/org/openapitools/client/ProgressResponseBody.java
src/main/java/org/openapitools/client/ServerConfiguration.java
src/main/java/org/openapitools/client/ServerVariable.java
src/main/java/org/openapitools/client/StringUtil.java
+src/main/java/org/openapitools/client/api/AuthApi.java
src/main/java/org/openapitools/client/api/BodyApi.java
src/main/java/org/openapitools/client/api/FormApi.java
src/main/java/org/openapitools/client/api/HeaderApi.java
diff --git a/samples/client/echo_api/java/okhttp-gson/README.md b/samples/client/echo_api/java/okhttp-gson/README.md
index 5d9b02479ce..bde93828861 100644
--- a/samples/client/echo_api/java/okhttp-gson/README.md
+++ b/samples/client/echo_api/java/okhttp-gson/README.md
@@ -82,20 +82,26 @@ Please follow the [installation](#installation) instruction and execute the foll
import org.openapitools.client.ApiClient;
import org.openapitools.client.ApiException;
import org.openapitools.client.Configuration;
+import org.openapitools.client.auth.*;
import org.openapitools.client.models.*;
-import org.openapitools.client.api.BodyApi;
+import org.openapitools.client.api.AuthApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("http://localhost:3000");
+
+ // Configure HTTP basic authorization: http_auth
+ HttpBasicAuth http_auth = (HttpBasicAuth) defaultClient.getAuthentication("http_auth");
+ http_auth.setUsername("YOUR USERNAME");
+ http_auth.setPassword("YOUR PASSWORD");
- BodyApi apiInstance = new BodyApi(defaultClient);
+ AuthApi apiInstance = new AuthApi(defaultClient);
try {
- File result = apiInstance.testBinaryGif();
+ String result = apiInstance.testAuthHttpBasic();
System.out.println(result);
} catch (ApiException e) {
- System.err.println("Exception when calling BodyApi#testBinaryGif");
+ System.err.println("Exception when calling AuthApi#testAuthHttpBasic");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
@@ -112,6 +118,7 @@ All URIs are relative to *http://localhost:3000*
Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
+*AuthApi* | [**testAuthHttpBasic**](docs/AuthApi.md#testAuthHttpBasic) | **POST** /auth/http/basic | To test HTTP basic authentication
*BodyApi* | [**testBinaryGif**](docs/BodyApi.md#testBinaryGif) | **POST** /binary/gif | Test binary (gif) response body
*BodyApi* | [**testBodyApplicationOctetstreamBinary**](docs/BodyApi.md#testBodyApplicationOctetstreamBinary) | **POST** /body/application/octetstream/binary | Test body parameter(s)
*BodyApi* | [**testBodyMultipartFormdataArrayOfBinary**](docs/BodyApi.md#testBodyMultipartFormdataArrayOfBinary) | **POST** /body/application/octetstream/array_of_binary | Test array of binary in multipart mime
@@ -151,7 +158,12 @@ Class | Method | HTTP request | Description
## Documentation for Authorization
-Endpoints do not require authorization.
+
+Authentication schemes defined for the API:
+
+### http_auth
+
+- **Type**: HTTP basic authentication
## Recommendation
diff --git a/samples/client/echo_api/java/okhttp-gson/api/openapi.yaml b/samples/client/echo_api/java/okhttp-gson/api/openapi.yaml
index a32ee32bd49..36261c0bd77 100644
--- a/samples/client/echo_api/java/okhttp-gson/api/openapi.yaml
+++ b/samples/client/echo_api/java/okhttp-gson/api/openapi.yaml
@@ -469,6 +469,23 @@ paths:
- body
x-content-type: multipart/form-data
x-accepts: text/plain
+ /auth/http/basic:
+ post:
+ description: To test HTTP basic authentication
+ operationId: test/auth/http/basic
+ responses:
+ "200":
+ content:
+ text/plain:
+ schema:
+ type: string
+ description: Successful operation
+ security:
+ - http_auth: []
+ summary: To test HTTP basic authentication
+ tags:
+ - auth
+ x-accepts: text/plain
components:
requestBodies:
Pet:
@@ -729,4 +746,8 @@ components:
required:
- files
type: object
+ securitySchemes:
+ http_auth:
+ scheme: basic
+ type: http
diff --git a/samples/client/echo_api/java/okhttp-gson/docs/AuthApi.md b/samples/client/echo_api/java/okhttp-gson/docs/AuthApi.md
new file mode 100644
index 00000000000..5a691fcb6f4
--- /dev/null
+++ b/samples/client/echo_api/java/okhttp-gson/docs/AuthApi.md
@@ -0,0 +1,73 @@
+# AuthApi
+
+All URIs are relative to *http://localhost:3000*
+
+| Method | HTTP request | Description |
+|------------- | ------------- | -------------|
+| [**testAuthHttpBasic**](AuthApi.md#testAuthHttpBasic) | **POST** /auth/http/basic | To test HTTP basic authentication |
+
+
+
+# **testAuthHttpBasic**
+> String testAuthHttpBasic()
+
+To test HTTP basic authentication
+
+To test HTTP basic authentication
+
+### Example
+```java
+// Import classes:
+import org.openapitools.client.ApiClient;
+import org.openapitools.client.ApiException;
+import org.openapitools.client.Configuration;
+import org.openapitools.client.auth.*;
+import org.openapitools.client.models.*;
+import org.openapitools.client.api.AuthApi;
+
+public class Example {
+ public static void main(String[] args) {
+ ApiClient defaultClient = Configuration.getDefaultApiClient();
+ defaultClient.setBasePath("http://localhost:3000");
+
+ // Configure HTTP basic authorization: http_auth
+ HttpBasicAuth http_auth = (HttpBasicAuth) defaultClient.getAuthentication("http_auth");
+ http_auth.setUsername("YOUR USERNAME");
+ http_auth.setPassword("YOUR PASSWORD");
+
+ AuthApi apiInstance = new AuthApi(defaultClient);
+ try {
+ String result = apiInstance.testAuthHttpBasic();
+ System.out.println(result);
+ } catch (ApiException e) {
+ System.err.println("Exception when calling AuthApi#testAuthHttpBasic");
+ System.err.println("Status code: " + e.getCode());
+ System.err.println("Reason: " + e.getResponseBody());
+ System.err.println("Response headers: " + e.getResponseHeaders());
+ e.printStackTrace();
+ }
+ }
+}
+```
+
+### Parameters
+This endpoint does not need any parameter.
+
+### Return type
+
+**String**
+
+### Authorization
+
+[http_auth](../README.md#http_auth)
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: text/plain
+
+### HTTP response details
+| Status code | Description | Response headers |
+|-------------|-------------|------------------|
+| **200** | Successful operation | - |
+
diff --git a/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/ApiClient.java b/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/ApiClient.java
index 8f710611efb..3d952c96bf8 100644
--- a/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/ApiClient.java
+++ b/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/ApiClient.java
@@ -99,6 +99,7 @@ public class ApiClient {
initHttpClient();
// Setup authentications (key: authentication name, value: authentication).
+ authentications.put("http_auth", new HttpBasicAuth());
// Prevent the authentications from being modified.
authentications = Collections.unmodifiableMap(authentications);
}
@@ -114,6 +115,7 @@ public class ApiClient {
httpClient = client;
// Setup authentications (key: authentication name, value: authentication).
+ authentications.put("http_auth", new HttpBasicAuth());
// Prevent the authentications from being modified.
authentications = Collections.unmodifiableMap(authentications);
}
diff --git a/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/api/AuthApi.java b/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/api/AuthApi.java
new file mode 100644
index 00000000000..dc87a48f858
--- /dev/null
+++ b/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/api/AuthApi.java
@@ -0,0 +1,187 @@
+/*
+ * Echo Server API
+ * Echo Server API
+ *
+ * The version of the OpenAPI document: 0.1.0
+ * Contact: team@openapitools.org
+ *
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * https://openapi-generator.tech
+ * Do not edit the class manually.
+ */
+
+
+package org.openapitools.client.api;
+
+import org.openapitools.client.ApiCallback;
+import org.openapitools.client.ApiClient;
+import org.openapitools.client.ApiException;
+import org.openapitools.client.ApiResponse;
+import org.openapitools.client.Configuration;
+import org.openapitools.client.Pair;
+import org.openapitools.client.ProgressRequestBody;
+import org.openapitools.client.ProgressResponseBody;
+
+import com.google.gson.reflect.TypeToken;
+
+import java.io.IOException;
+
+
+
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class AuthApi {
+ private ApiClient localVarApiClient;
+ private int localHostIndex;
+ private String localCustomBaseUrl;
+
+ public AuthApi() {
+ this(Configuration.getDefaultApiClient());
+ }
+
+ public AuthApi(ApiClient apiClient) {
+ this.localVarApiClient = apiClient;
+ }
+
+ public ApiClient getApiClient() {
+ return localVarApiClient;
+ }
+
+ public void setApiClient(ApiClient apiClient) {
+ this.localVarApiClient = apiClient;
+ }
+
+ public int getHostIndex() {
+ return localHostIndex;
+ }
+
+ public void setHostIndex(int hostIndex) {
+ this.localHostIndex = hostIndex;
+ }
+
+ public String getCustomBaseUrl() {
+ return localCustomBaseUrl;
+ }
+
+ public void setCustomBaseUrl(String customBaseUrl) {
+ this.localCustomBaseUrl = customBaseUrl;
+ }
+
+ /**
+ * Build call for testAuthHttpBasic
+ * @param _callback Callback for upload/download progress
+ * @return Call to execute
+ * @throws ApiException If fail to serialize the request body object
+ * @http.response.details
+
+ Status Code | Description | Response Headers |
+ 200 | Successful operation | - |
+
+ */
+ public okhttp3.Call testAuthHttpBasicCall(final ApiCallback _callback) throws ApiException {
+ String basePath = null;
+ // Operation Servers
+ String[] localBasePaths = new String[] { };
+
+ // Determine Base Path to Use
+ if (localCustomBaseUrl != null){
+ basePath = localCustomBaseUrl;
+ } else if ( localBasePaths.length > 0 ) {
+ basePath = localBasePaths[localHostIndex];
+ } else {
+ basePath = null;
+ }
+
+ Object localVarPostBody = null;
+
+ // create path and map variables
+ String localVarPath = "/auth/http/basic";
+
+ List localVarQueryParams = new ArrayList();
+ List localVarCollectionQueryParams = new ArrayList();
+ Map localVarHeaderParams = new HashMap();
+ Map localVarCookieParams = new HashMap();
+ Map localVarFormParams = new HashMap();
+
+ final String[] localVarAccepts = {
+ "text/plain"
+ };
+ final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts);
+ if (localVarAccept != null) {
+ localVarHeaderParams.put("Accept", localVarAccept);
+ }
+
+ final String[] localVarContentTypes = {
+ };
+ final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes);
+ if (localVarContentType != null) {
+ localVarHeaderParams.put("Content-Type", localVarContentType);
+ }
+
+ String[] localVarAuthNames = new String[] { "http_auth" };
+ return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback);
+ }
+
+ @SuppressWarnings("rawtypes")
+ private okhttp3.Call testAuthHttpBasicValidateBeforeCall(final ApiCallback _callback) throws ApiException {
+ return testAuthHttpBasicCall(_callback);
+
+ }
+
+ /**
+ * To test HTTP basic authentication
+ * To test HTTP basic authentication
+ * @return String
+ * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
+ * @http.response.details
+
+ Status Code | Description | Response Headers |
+ 200 | Successful operation | - |
+
+ */
+ public String testAuthHttpBasic() throws ApiException {
+ ApiResponse localVarResp = testAuthHttpBasicWithHttpInfo();
+ return localVarResp.getData();
+ }
+
+ /**
+ * To test HTTP basic authentication
+ * To test HTTP basic authentication
+ * @return ApiResponse<String>
+ * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
+ * @http.response.details
+
+ Status Code | Description | Response Headers |
+ 200 | Successful operation | - |
+
+ */
+ public ApiResponse testAuthHttpBasicWithHttpInfo() throws ApiException {
+ okhttp3.Call localVarCall = testAuthHttpBasicValidateBeforeCall(null);
+ Type localVarReturnType = new TypeToken(){}.getType();
+ return localVarApiClient.execute(localVarCall, localVarReturnType);
+ }
+
+ /**
+ * To test HTTP basic authentication (asynchronously)
+ * To test HTTP basic authentication
+ * @param _callback The callback to be executed when the API call finishes
+ * @return The request call
+ * @throws ApiException If fail to process the API call, e.g. serializing the request body object
+ * @http.response.details
+
+ Status Code | Description | Response Headers |
+ 200 | Successful operation | - |
+
+ */
+ public okhttp3.Call testAuthHttpBasicAsync(final ApiCallback _callback) throws ApiException {
+
+ okhttp3.Call localVarCall = testAuthHttpBasicValidateBeforeCall(_callback);
+ Type localVarReturnType = new TypeToken(){}.getType();
+ localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
+ return localVarCall;
+ }
+}
diff --git a/samples/client/echo_api/java/okhttp-gson/src/test/java/org/openapitools/client/api/AuthApiTest.java b/samples/client/echo_api/java/okhttp-gson/src/test/java/org/openapitools/client/api/AuthApiTest.java
new file mode 100644
index 00000000000..7d5e92b75a5
--- /dev/null
+++ b/samples/client/echo_api/java/okhttp-gson/src/test/java/org/openapitools/client/api/AuthApiTest.java
@@ -0,0 +1,46 @@
+/*
+ * Echo Server API
+ * Echo Server API
+ *
+ * The version of the OpenAPI document: 0.1.0
+ * Contact: team@openapitools.org
+ *
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * https://openapi-generator.tech
+ * Do not edit the class manually.
+ */
+
+
+package org.openapitools.client.api;
+
+import org.openapitools.client.ApiException;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * API tests for AuthApi
+ */
+@Disabled
+public class AuthApiTest {
+
+ private final AuthApi api = new AuthApi();
+
+ /**
+ * To test HTTP basic authentication
+ *
+ * To test HTTP basic authentication
+ *
+ * @throws ApiException if the Api call fails
+ */
+ @Test
+ public void testAuthHttpBasicTest() throws ApiException {
+ String response = api.testAuthHttpBasic();
+ // TODO: test validations
+ }
+
+}
diff --git a/samples/client/echo_api/python/.openapi-generator/FILES b/samples/client/echo_api/python/.openapi-generator/FILES
index 58dbe77b172..0723c3ab0de 100644
--- a/samples/client/echo_api/python/.openapi-generator/FILES
+++ b/samples/client/echo_api/python/.openapi-generator/FILES
@@ -3,6 +3,7 @@
.gitlab-ci.yml
.travis.yml
README.md
+docs/AuthApi.md
docs/Bird.md
docs/BodyApi.md
docs/Category.md
@@ -22,6 +23,7 @@ docs/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.md
git_push.sh
openapi_client/__init__.py
openapi_client/api/__init__.py
+openapi_client/api/auth_api.py
openapi_client/api/body_api.py
openapi_client/api/form_api.py
openapi_client/api/header_api.py
diff --git a/samples/client/echo_api/python/README.md b/samples/client/echo_api/python/README.md
index 39f8162aecb..d9de36cb6e2 100644
--- a/samples/client/echo_api/python/README.md
+++ b/samples/client/echo_api/python/README.md
@@ -61,20 +61,30 @@ configuration = openapi_client.Configuration(
host = "http://localhost:3000"
)
+# The client must configure the authentication and authorization parameters
+# in accordance with the API server security policy.
+# Examples for each auth method are provided below, use the example that
+# satisfies your auth use case.
+
+# Configure HTTP basic authorization: http_auth
+configuration = openapi_client.Configuration(
+ username = os.environ["USERNAME"],
+ password = os.environ["PASSWORD"]
+)
# Enter a context with an instance of the API client
with openapi_client.ApiClient(configuration) as api_client:
# Create an instance of the API class
- api_instance = openapi_client.BodyApi(api_client)
+ api_instance = openapi_client.AuthApi(api_client)
try:
- # Test binary (gif) response body
- api_response = api_instance.test_binary_gif()
- print("The response of BodyApi->test_binary_gif:\n")
+ # To test HTTP basic authentication
+ api_response = api_instance.test_auth_http_basic()
+ print("The response of AuthApi->test_auth_http_basic:\n")
pprint(api_response)
except ApiException as e:
- print("Exception when calling BodyApi->test_binary_gif: %s\n" % e)
+ print("Exception when calling AuthApi->test_auth_http_basic: %s\n" % e)
```
@@ -84,6 +94,7 @@ All URIs are relative to *http://localhost:3000*
Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
+*AuthApi* | [**test_auth_http_basic**](docs/AuthApi.md#test_auth_http_basic) | **POST** /auth/http/basic | To test HTTP basic authentication
*BodyApi* | [**test_binary_gif**](docs/BodyApi.md#test_binary_gif) | **POST** /binary/gif | Test binary (gif) response body
*BodyApi* | [**test_body_application_octetstream_binary**](docs/BodyApi.md#test_body_application_octetstream_binary) | **POST** /body/application/octetstream/binary | Test body parameter(s)
*BodyApi* | [**test_body_multipart_formdata_array_of_binary**](docs/BodyApi.md#test_body_multipart_formdata_array_of_binary) | **POST** /body/application/octetstream/array_of_binary | Test array of binary in multipart mime
@@ -123,7 +134,12 @@ Class | Method | HTTP request | Description
## Documentation For Authorization
-Endpoints do not require authorization.
+
+Authentication schemes defined for the API:
+
+### http_auth
+
+- **Type**: HTTP basic authentication
## Author
diff --git a/samples/client/echo_api/python/docs/AuthApi.md b/samples/client/echo_api/python/docs/AuthApi.md
new file mode 100644
index 00000000000..98ce834c317
--- /dev/null
+++ b/samples/client/echo_api/python/docs/AuthApi.md
@@ -0,0 +1,82 @@
+# openapi_client.AuthApi
+
+All URIs are relative to *http://localhost:3000*
+
+Method | HTTP request | Description
+------------- | ------------- | -------------
+[**test_auth_http_basic**](AuthApi.md#test_auth_http_basic) | **POST** /auth/http/basic | To test HTTP basic authentication
+
+
+# **test_auth_http_basic**
+> str test_auth_http_basic()
+
+To test HTTP basic authentication
+
+To test HTTP basic authentication
+
+### Example
+
+* Basic Authentication (http_auth):
+```python
+import time
+import os
+import openapi_client
+from openapi_client.rest import ApiException
+from pprint import pprint
+
+# Defining the host is optional and defaults to http://localhost:3000
+# See configuration.py for a list of all supported configuration parameters.
+configuration = openapi_client.Configuration(
+ host = "http://localhost:3000"
+)
+
+# The client must configure the authentication and authorization parameters
+# in accordance with the API server security policy.
+# Examples for each auth method are provided below, use the example that
+# satisfies your auth use case.
+
+# Configure HTTP basic authorization: http_auth
+configuration = openapi_client.Configuration(
+ username = os.environ["USERNAME"],
+ password = os.environ["PASSWORD"]
+)
+
+# Enter a context with an instance of the API client
+with openapi_client.ApiClient(configuration) as api_client:
+ # Create an instance of the API class
+ api_instance = openapi_client.AuthApi(api_client)
+
+ try:
+ # To test HTTP basic authentication
+ api_response = api_instance.test_auth_http_basic()
+ print("The response of AuthApi->test_auth_http_basic:\n")
+ pprint(api_response)
+ except Exception as e:
+ print("Exception when calling AuthApi->test_auth_http_basic: %s\n" % e)
+```
+
+
+
+### Parameters
+This endpoint does not need any parameter.
+
+### Return type
+
+**str**
+
+### Authorization
+
+[http_auth](../README.md#http_auth)
+
+### HTTP request headers
+
+ - **Content-Type**: Not defined
+ - **Accept**: text/plain
+
+### HTTP response details
+| Status code | Description | Response headers |
+|-------------|-------------|------------------|
+**200** | Successful operation | - |
+
+[[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/echo_api/python/openapi_client/__init__.py b/samples/client/echo_api/python/openapi_client/__init__.py
index 030ef53842c..7b67f7c597f 100644
--- a/samples/client/echo_api/python/openapi_client/__init__.py
+++ b/samples/client/echo_api/python/openapi_client/__init__.py
@@ -18,6 +18,7 @@
__version__ = "1.0.0"
# import apis into sdk package
+from openapi_client.api.auth_api import AuthApi
from openapi_client.api.body_api import BodyApi
from openapi_client.api.form_api import FormApi
from openapi_client.api.header_api import HeaderApi
diff --git a/samples/client/echo_api/python/openapi_client/api/__init__.py b/samples/client/echo_api/python/openapi_client/api/__init__.py
index 411eed92583..9c9ae790c3b 100644
--- a/samples/client/echo_api/python/openapi_client/api/__init__.py
+++ b/samples/client/echo_api/python/openapi_client/api/__init__.py
@@ -1,6 +1,7 @@
# flake8: noqa
# import apis into api package
+from openapi_client.api.auth_api import AuthApi
from openapi_client.api.body_api import BodyApi
from openapi_client.api.form_api import FormApi
from openapi_client.api.header_api import HeaderApi
diff --git a/samples/client/echo_api/python/openapi_client/api/auth_api.py b/samples/client/echo_api/python/openapi_client/api/auth_api.py
new file mode 100644
index 00000000000..07cdda86f58
--- /dev/null
+++ b/samples/client/echo_api/python/openapi_client/api/auth_api.py
@@ -0,0 +1,174 @@
+# coding: utf-8
+
+"""
+ Echo Server API
+
+ Echo Server API
+
+ The version of the OpenAPI document: 0.1.0
+ Contact: team@openapitools.org
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
+
+ Do not edit the class manually.
+""" # noqa: E501
+
+
+import re # noqa: F401
+import io
+import warnings
+
+from pydantic import validate_arguments, ValidationError
+from typing_extensions import Annotated
+
+
+from openapi_client.api_client import ApiClient
+from openapi_client.api_response import ApiResponse
+from openapi_client.exceptions import ( # noqa: F401
+ ApiTypeError,
+ ApiValueError
+)
+
+
+class AuthApi:
+ """NOTE: This class is auto generated by OpenAPI Generator
+ Ref: https://openapi-generator.tech
+
+ Do not edit the class manually.
+ """
+
+ def __init__(self, api_client=None) -> None:
+ if api_client is None:
+ api_client = ApiClient.get_default()
+ self.api_client = api_client
+
+ @validate_arguments
+ def test_auth_http_basic(self, **kwargs) -> str: # noqa: E501
+ """To test HTTP basic authentication # noqa: E501
+
+ To test HTTP basic authentication # noqa: E501
+ This method makes a synchronous HTTP request by default. To make an
+ asynchronous HTTP request, please pass async_req=True
+
+ >>> thread = api.test_auth_http_basic(async_req=True)
+ >>> result = thread.get()
+
+ :param async_req: Whether to execute the request asynchronously.
+ :type async_req: bool, optional
+ :param _request_timeout: timeout setting for this request.
+ If one number provided, it will be total request
+ timeout. It can also be a pair (tuple) of
+ (connection, read) timeouts.
+ :return: Returns the result object.
+ If the method is called asynchronously,
+ returns the request thread.
+ :rtype: str
+ """
+ kwargs['_return_http_data_only'] = True
+ if '_preload_content' in kwargs:
+ message = "Error! Please call the test_auth_http_basic_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501
+ raise ValueError(message)
+ return self.test_auth_http_basic_with_http_info(**kwargs) # noqa: E501
+
+ @validate_arguments
+ def test_auth_http_basic_with_http_info(self, **kwargs) -> ApiResponse: # noqa: E501
+ """To test HTTP basic authentication # noqa: E501
+
+ To test HTTP basic authentication # noqa: E501
+ This method makes a synchronous HTTP request by default. To make an
+ asynchronous HTTP request, please pass async_req=True
+
+ >>> thread = api.test_auth_http_basic_with_http_info(async_req=True)
+ >>> result = thread.get()
+
+ :param async_req: Whether to execute the request asynchronously.
+ :type async_req: bool, optional
+ :param _preload_content: if False, the ApiResponse.data will
+ be set to none and raw_data will store the
+ HTTP response body without reading/decoding.
+ Default is True.
+ :type _preload_content: bool, optional
+ :param _return_http_data_only: response data instead of ApiResponse
+ object with status code, headers, etc
+ :type _return_http_data_only: bool, optional
+ :param _request_timeout: timeout setting for this request. If one
+ number provided, it will be total request
+ timeout. It can also be a pair (tuple) of
+ (connection, read) timeouts.
+ :param _request_auth: set to override the auth_settings for an a single
+ request; this effectively ignores the authentication
+ in the spec for a single request.
+ :type _request_auth: dict, optional
+ :type _content_type: string, optional: force content-type for the request
+ :return: Returns the result object.
+ If the method is called asynchronously,
+ returns the request thread.
+ :rtype: tuple(str, status_code(int), headers(HTTPHeaderDict))
+ """
+
+ _params = locals()
+
+ _all_params = [
+ ]
+ _all_params.extend(
+ [
+ 'async_req',
+ '_return_http_data_only',
+ '_preload_content',
+ '_request_timeout',
+ '_request_auth',
+ '_content_type',
+ '_headers'
+ ]
+ )
+
+ # validate the arguments
+ for _key, _val in _params['kwargs'].items():
+ if _key not in _all_params:
+ raise ApiTypeError(
+ "Got an unexpected keyword argument '%s'"
+ " to method test_auth_http_basic" % _key
+ )
+ _params[_key] = _val
+ del _params['kwargs']
+
+ _collection_formats = {}
+
+ # process the path parameters
+ _path_params = {}
+
+ # process the query parameters
+ _query_params = []
+ # process the header parameters
+ _header_params = dict(_params.get('_headers', {}))
+ # process the form parameters
+ _form_params = []
+ _files = {}
+ # process the body parameter
+ _body_params = None
+ # set the HTTP header `Accept`
+ _header_params['Accept'] = self.api_client.select_header_accept(
+ ['text/plain']) # noqa: E501
+
+ # authentication setting
+ _auth_settings = ['http_auth'] # noqa: E501
+
+ _response_types_map = {
+ '200': "str",
+ }
+
+ return self.api_client.call_api(
+ '/auth/http/basic', 'POST',
+ _path_params,
+ _query_params,
+ _header_params,
+ body=_body_params,
+ post_params=_form_params,
+ files=_files,
+ response_types_map=_response_types_map,
+ auth_settings=_auth_settings,
+ async_req=_params.get('async_req'),
+ _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501
+ _preload_content=_params.get('_preload_content', True),
+ _request_timeout=_params.get('_request_timeout'),
+ collection_formats=_collection_formats,
+ _request_auth=_params.get('_request_auth'))
diff --git a/samples/client/echo_api/python/openapi_client/configuration.py b/samples/client/echo_api/python/openapi_client/configuration.py
index 361ae879385..8ff03cff3b9 100644
--- a/samples/client/echo_api/python/openapi_client/configuration.py
+++ b/samples/client/echo_api/python/openapi_client/configuration.py
@@ -54,6 +54,23 @@ class Configuration:
:param ssl_ca_cert: str - the path to a file of concatenated CA certificates
in PEM format.
+ :Example:
+
+ HTTP Basic Authentication Example.
+ Given the following security scheme in the OpenAPI specification:
+ components:
+ securitySchemes:
+ http_basic_auth:
+ type: http
+ scheme: basic
+
+ Configure API client with HTTP basic authentication:
+
+conf = openapi_client.Configuration(
+ username='the-user',
+ password='the-password',
+)
+
"""
_default = None
@@ -358,6 +375,13 @@ class Configuration:
:return: The Auth Settings information dict.
"""
auth = {}
+ if self.username is not None and self.password is not None:
+ auth['http_auth'] = {
+ 'type': 'basic',
+ 'in': 'header',
+ 'key': 'Authorization',
+ 'value': self.get_basic_auth_token()
+ }
return auth
def to_debug_report(self):
diff --git a/samples/client/echo_api/python/test/test_auth_api.py b/samples/client/echo_api/python/test/test_auth_api.py
new file mode 100644
index 00000000000..bfd827933bd
--- /dev/null
+++ b/samples/client/echo_api/python/test/test_auth_api.py
@@ -0,0 +1,39 @@
+# coding: utf-8
+
+"""
+ Echo Server API
+
+ Echo Server API
+
+ The version of the OpenAPI document: 0.1.0
+ Contact: team@openapitools.org
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
+
+ Do not edit the class manually.
+""" # noqa: E501
+
+
+import unittest
+
+from openapi_client.api.auth_api import AuthApi # noqa: E501
+
+
+class TestAuthApi(unittest.TestCase):
+ """AuthApi unit test stubs"""
+
+ def setUp(self) -> None:
+ self.api = AuthApi() # noqa: E501
+
+ def tearDown(self) -> None:
+ pass
+
+ def test_test_auth_http_basic(self) -> None:
+ """Test case for test_auth_http_basic
+
+ To test HTTP basic authentication # noqa: E501
+ """
+ pass
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/samples/client/echo_api/python/test/test_manual.py b/samples/client/echo_api/python/test/test_manual.py
index 700c3323db9..61fbb13b923 100644
--- a/samples/client/echo_api/python/test/test_manual.py
+++ b/samples/client/echo_api/python/test/test_manual.py
@@ -130,6 +130,19 @@ class TestManual(unittest.TestCase):
api_response = api_instance.test_echo_body_free_form_object_response_string({})
self.assertEqual(api_response, "{}") # assertion to ensure {} is sent in the body
+ def testAuthHttpBasic(self):
+ api_instance = openapi_client.AuthApi()
+ api_response = api_instance.test_auth_http_basic()
+ e = EchoServerResponseParser(api_response)
+ self.assertFalse("Authorization" in e.headers)
+
+ api_instance.api_client.configuration.username = "test_username"
+ api_instance.api_client.configuration.password = "test_password"
+ api_response = api_instance.test_auth_http_basic()
+ e = EchoServerResponseParser(api_response)
+ self.assertTrue("Authorization" in e.headers)
+ self.assertEqual(e.headers["Authorization"], "Basic dGVzdF91c2VybmFtZTp0ZXN0X3Bhc3N3b3Jk")
+
def echoServerResponseParaserTest(self):
s = """POST /echo/body/Pet/response_string HTTP/1.1
Host: localhost:3000