mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-07-04 22:50:53 +00:00
Add tests for http basic authentication in python client (#16488)
* add tests for http basic auth in python client * add new files
This commit is contained in:
parent
b59719a6ea
commit
47a85e880b
@ -485,8 +485,28 @@ paths:
|
|||||||
text/plain:
|
text/plain:
|
||||||
schema:
|
schema:
|
||||||
type: string
|
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:
|
components:
|
||||||
|
securitySchemes:
|
||||||
|
http_auth:
|
||||||
|
type: http
|
||||||
|
scheme: basic
|
||||||
requestBodies:
|
requestBodies:
|
||||||
Pet:
|
Pet:
|
||||||
content:
|
content:
|
||||||
|
@ -3,6 +3,7 @@ Org.OpenAPITools.sln
|
|||||||
README.md
|
README.md
|
||||||
api/openapi.yaml
|
api/openapi.yaml
|
||||||
appveyor.yml
|
appveyor.yml
|
||||||
|
docs/AuthApi.md
|
||||||
docs/Bird.md
|
docs/Bird.md
|
||||||
docs/BodyApi.md
|
docs/BodyApi.md
|
||||||
docs/Category.md
|
docs/Category.md
|
||||||
@ -21,6 +22,7 @@ docs/TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.md
|
|||||||
docs/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.md
|
docs/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.md
|
||||||
git_push.sh
|
git_push.sh
|
||||||
src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj
|
src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj
|
||||||
|
src/Org.OpenAPITools/Api/AuthApi.cs
|
||||||
src/Org.OpenAPITools/Api/BodyApi.cs
|
src/Org.OpenAPITools/Api/BodyApi.cs
|
||||||
src/Org.OpenAPITools/Api/FormApi.cs
|
src/Org.OpenAPITools/Api/FormApi.cs
|
||||||
src/Org.OpenAPITools/Api/HeaderApi.cs
|
src/Org.OpenAPITools/Api/HeaderApi.cs
|
||||||
|
@ -85,17 +85,21 @@ namespace Example
|
|||||||
|
|
||||||
Configuration config = new Configuration();
|
Configuration config = new Configuration();
|
||||||
config.BasePath = "http://localhost:3000";
|
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
|
try
|
||||||
{
|
{
|
||||||
// Test binary (gif) response body
|
// To test HTTP basic authentication
|
||||||
System.IO.Stream result = apiInstance.TestBinaryGif();
|
string result = apiInstance.TestAuthHttpBasic();
|
||||||
Debug.WriteLine(result);
|
Debug.WriteLine(result);
|
||||||
}
|
}
|
||||||
catch (ApiException e)
|
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("Status Code: "+ e.ErrorCode);
|
||||||
Debug.Print(e.StackTrace);
|
Debug.Print(e.StackTrace);
|
||||||
}
|
}
|
||||||
@ -112,6 +116,7 @@ All URIs are relative to *http://localhost:3000*
|
|||||||
|
|
||||||
Class | Method | HTTP request | Description
|
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* | [**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* | [**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
|
*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
|
|||||||
<a id="documentation-for-authorization"></a>
|
<a id="documentation-for-authorization"></a>
|
||||||
## Documentation for Authorization
|
## Documentation for Authorization
|
||||||
|
|
||||||
Endpoints do not require authorization.
|
|
||||||
|
Authentication schemes defined for the API:
|
||||||
|
<a id="http_auth"></a>
|
||||||
|
### http_auth
|
||||||
|
|
||||||
|
- **Type**: HTTP basic authentication
|
||||||
|
|
||||||
|
@ -442,6 +442,22 @@ paths:
|
|||||||
summary: Test array of binary in multipart mime
|
summary: Test array of binary in multipart mime
|
||||||
tags:
|
tags:
|
||||||
- body
|
- 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:
|
components:
|
||||||
requestBodies:
|
requestBodies:
|
||||||
Pet:
|
Pet:
|
||||||
@ -702,4 +718,8 @@ components:
|
|||||||
required:
|
required:
|
||||||
- files
|
- files
|
||||||
type: object
|
type: object
|
||||||
|
securitySchemes:
|
||||||
|
http_auth:
|
||||||
|
scheme: basic
|
||||||
|
type: http
|
||||||
|
|
||||||
|
98
samples/client/echo_api/csharp-restsharp/docs/AuthApi.md
Normal file
98
samples/client/echo_api/csharp-restsharp/docs/AuthApi.md
Normal file
@ -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 |
|
||||||
|
|
||||||
|
<a id="testauthhttpbasic"></a>
|
||||||
|
# **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<string> 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)
|
||||||
|
|
@ -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
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Class for testing AuthApi
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
/// Please update the test case below to test the API endpoint.
|
||||||
|
/// </remarks>
|
||||||
|
public class AuthApiTests : IDisposable
|
||||||
|
{
|
||||||
|
private AuthApi instance;
|
||||||
|
|
||||||
|
public AuthApiTests()
|
||||||
|
{
|
||||||
|
instance = new AuthApi();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
// Cleanup when everything is done.
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Test an instance of AuthApi
|
||||||
|
/// </summary>
|
||||||
|
[Fact]
|
||||||
|
public void InstanceTest()
|
||||||
|
{
|
||||||
|
// TODO uncomment below to test 'IsType' AuthApi
|
||||||
|
//Assert.IsType<AuthApi>(instance);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Test TestAuthHttpBasic
|
||||||
|
/// </summary>
|
||||||
|
[Fact]
|
||||||
|
public void TestAuthHttpBasicTest()
|
||||||
|
{
|
||||||
|
// TODO uncomment below to test the method and replace null with proper value
|
||||||
|
//var response = instance.TestAuthHttpBasic();
|
||||||
|
//Assert.IsType<string>(response);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -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
|
||||||
|
{
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents a collection of functions to interact with the API endpoints
|
||||||
|
/// </summary>
|
||||||
|
public interface IAuthApiSync : IApiAccessor
|
||||||
|
{
|
||||||
|
#region Synchronous Operations
|
||||||
|
/// <summary>
|
||||||
|
/// To test HTTP basic authentication
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// To test HTTP basic authentication
|
||||||
|
/// </remarks>
|
||||||
|
/// <exception cref="Org.OpenAPITools.Client.ApiException">Thrown when fails to make API call</exception>
|
||||||
|
/// <param name="operationIndex">Index associated with the operation.</param>
|
||||||
|
/// <returns>string</returns>
|
||||||
|
string TestAuthHttpBasic(int operationIndex = 0);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// To test HTTP basic authentication
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// To test HTTP basic authentication
|
||||||
|
/// </remarks>
|
||||||
|
/// <exception cref="Org.OpenAPITools.Client.ApiException">Thrown when fails to make API call</exception>
|
||||||
|
/// <param name="operationIndex">Index associated with the operation.</param>
|
||||||
|
/// <returns>ApiResponse of string</returns>
|
||||||
|
ApiResponse<string> TestAuthHttpBasicWithHttpInfo(int operationIndex = 0);
|
||||||
|
#endregion Synchronous Operations
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents a collection of functions to interact with the API endpoints
|
||||||
|
/// </summary>
|
||||||
|
public interface IAuthApiAsync : IApiAccessor
|
||||||
|
{
|
||||||
|
#region Asynchronous Operations
|
||||||
|
/// <summary>
|
||||||
|
/// To test HTTP basic authentication
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// To test HTTP basic authentication
|
||||||
|
/// </remarks>
|
||||||
|
/// <exception cref="Org.OpenAPITools.Client.ApiException">Thrown when fails to make API call</exception>
|
||||||
|
/// <param name="operationIndex">Index associated with the operation.</param>
|
||||||
|
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||||
|
/// <returns>Task of string</returns>
|
||||||
|
System.Threading.Tasks.Task<string> TestAuthHttpBasicAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken));
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// To test HTTP basic authentication
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// To test HTTP basic authentication
|
||||||
|
/// </remarks>
|
||||||
|
/// <exception cref="Org.OpenAPITools.Client.ApiException">Thrown when fails to make API call</exception>
|
||||||
|
/// <param name="operationIndex">Index associated with the operation.</param>
|
||||||
|
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||||
|
/// <returns>Task of ApiResponse (string)</returns>
|
||||||
|
System.Threading.Tasks.Task<ApiResponse<string>> TestAuthHttpBasicWithHttpInfoAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken));
|
||||||
|
#endregion Asynchronous Operations
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents a collection of functions to interact with the API endpoints
|
||||||
|
/// </summary>
|
||||||
|
public interface IAuthApi : IAuthApiSync, IAuthApiAsync
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents a collection of functions to interact with the API endpoints
|
||||||
|
/// </summary>
|
||||||
|
public partial class AuthApi : IAuthApi
|
||||||
|
{
|
||||||
|
private Org.OpenAPITools.Client.ExceptionFactory _exceptionFactory = (name, response) => null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="AuthApi"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public AuthApi() : this((string)null)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="AuthApi"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="AuthApi"/> class
|
||||||
|
/// using Configuration object
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="configuration">An instance of Configuration</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="AuthApi"/> class
|
||||||
|
/// using a Configuration object and client instance.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="client">The client interface for synchronous API access.</param>
|
||||||
|
/// <param name="asyncClient">The client interface for asynchronous API access.</param>
|
||||||
|
/// <param name="configuration">The configuration object.</param>
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The client for accessing this underlying API asynchronously.
|
||||||
|
/// </summary>
|
||||||
|
public Org.OpenAPITools.Client.IAsynchronousClient AsynchronousClient { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The client for accessing this underlying API synchronously.
|
||||||
|
/// </summary>
|
||||||
|
public Org.OpenAPITools.Client.ISynchronousClient Client { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the base path of the API client.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The base path</value>
|
||||||
|
public string GetBasePath()
|
||||||
|
{
|
||||||
|
return this.Configuration.BasePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the configuration object
|
||||||
|
/// </summary>
|
||||||
|
/// <value>An instance of the Configuration</value>
|
||||||
|
public Org.OpenAPITools.Client.IReadableConfiguration Configuration { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Provides a factory method hook for the creation of exceptions.
|
||||||
|
/// </summary>
|
||||||
|
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; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// To test HTTP basic authentication To test HTTP basic authentication
|
||||||
|
/// </summary>
|
||||||
|
/// <exception cref="Org.OpenAPITools.Client.ApiException">Thrown when fails to make API call</exception>
|
||||||
|
/// <param name="operationIndex">Index associated with the operation.</param>
|
||||||
|
/// <returns>string</returns>
|
||||||
|
public string TestAuthHttpBasic(int operationIndex = 0)
|
||||||
|
{
|
||||||
|
Org.OpenAPITools.Client.ApiResponse<string> localVarResponse = TestAuthHttpBasicWithHttpInfo();
|
||||||
|
return localVarResponse.Data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// To test HTTP basic authentication To test HTTP basic authentication
|
||||||
|
/// </summary>
|
||||||
|
/// <exception cref="Org.OpenAPITools.Client.ApiException">Thrown when fails to make API call</exception>
|
||||||
|
/// <param name="operationIndex">Index associated with the operation.</param>
|
||||||
|
/// <returns>ApiResponse of string</returns>
|
||||||
|
public Org.OpenAPITools.Client.ApiResponse<string> 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<string>("/auth/http/basic", localVarRequestOptions, this.Configuration);
|
||||||
|
if (this.ExceptionFactory != null)
|
||||||
|
{
|
||||||
|
Exception _exception = this.ExceptionFactory("TestAuthHttpBasic", localVarResponse);
|
||||||
|
if (_exception != null)
|
||||||
|
{
|
||||||
|
throw _exception;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return localVarResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// To test HTTP basic authentication To test HTTP basic authentication
|
||||||
|
/// </summary>
|
||||||
|
/// <exception cref="Org.OpenAPITools.Client.ApiException">Thrown when fails to make API call</exception>
|
||||||
|
/// <param name="operationIndex">Index associated with the operation.</param>
|
||||||
|
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||||
|
/// <returns>Task of string</returns>
|
||||||
|
public async System.Threading.Tasks.Task<string> TestAuthHttpBasicAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
|
||||||
|
{
|
||||||
|
Org.OpenAPITools.Client.ApiResponse<string> localVarResponse = await TestAuthHttpBasicWithHttpInfoAsync(operationIndex, cancellationToken).ConfigureAwait(false);
|
||||||
|
return localVarResponse.Data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// To test HTTP basic authentication To test HTTP basic authentication
|
||||||
|
/// </summary>
|
||||||
|
/// <exception cref="Org.OpenAPITools.Client.ApiException">Thrown when fails to make API call</exception>
|
||||||
|
/// <param name="operationIndex">Index associated with the operation.</param>
|
||||||
|
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||||
|
/// <returns>Task of ApiResponse (string)</returns>
|
||||||
|
public async System.Threading.Tasks.Task<Org.OpenAPITools.Client.ApiResponse<string>> 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<string>("/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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -5,6 +5,7 @@ README.md
|
|||||||
api/openapi.yaml
|
api/openapi.yaml
|
||||||
build.gradle
|
build.gradle
|
||||||
build.sbt
|
build.sbt
|
||||||
|
docs/AuthApi.md
|
||||||
docs/Bird.md
|
docs/Bird.md
|
||||||
docs/BodyApi.md
|
docs/BodyApi.md
|
||||||
docs/Category.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/ServerConfiguration.java
|
||||||
src/main/java/org/openapitools/client/ServerVariable.java
|
src/main/java/org/openapitools/client/ServerVariable.java
|
||||||
src/main/java/org/openapitools/client/StringUtil.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/BodyApi.java
|
||||||
src/main/java/org/openapitools/client/api/FormApi.java
|
src/main/java/org/openapitools/client/api/FormApi.java
|
||||||
src/main/java/org/openapitools/client/api/HeaderApi.java
|
src/main/java/org/openapitools/client/api/HeaderApi.java
|
||||||
|
@ -75,20 +75,25 @@ Please follow the [installation](#installation) instruction and execute the foll
|
|||||||
import org.openapitools.client.*;
|
import org.openapitools.client.*;
|
||||||
import org.openapitools.client.auth.*;
|
import org.openapitools.client.auth.*;
|
||||||
import org.openapitools.client.model.*;
|
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) {
|
public static void main(String[] args) {
|
||||||
ApiClient defaultClient = Configuration.getDefaultApiClient();
|
ApiClient defaultClient = Configuration.getDefaultApiClient();
|
||||||
defaultClient.setBasePath("http://localhost:3000");
|
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 {
|
try {
|
||||||
File result = apiInstance.testBinaryGif();
|
String result = apiInstance.testAuthHttpBasic();
|
||||||
System.out.println(result);
|
System.out.println(result);
|
||||||
} catch (ApiException e) {
|
} 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("Status code: " + e.getCode());
|
||||||
System.err.println("Reason: " + e.getResponseBody());
|
System.err.println("Reason: " + e.getResponseBody());
|
||||||
System.err.println("Response headers: " + e.getResponseHeaders());
|
System.err.println("Response headers: " + e.getResponseHeaders());
|
||||||
@ -105,6 +110,7 @@ All URIs are relative to *http://localhost:3000*
|
|||||||
|
|
||||||
Class | Method | HTTP request | Description
|
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* | [**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* | [**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
|
*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
|
|||||||
<a id="documentation-for-authorization"></a>
|
<a id="documentation-for-authorization"></a>
|
||||||
## Documentation for Authorization
|
## Documentation for Authorization
|
||||||
|
|
||||||
Endpoints do not require authorization.
|
|
||||||
|
Authentication schemes defined for the API:
|
||||||
|
<a id="http_auth"></a>
|
||||||
|
### http_auth
|
||||||
|
|
||||||
|
|
||||||
|
- **Type**: HTTP basic authentication
|
||||||
|
|
||||||
|
|
||||||
## Recommendation
|
## Recommendation
|
||||||
|
@ -469,6 +469,23 @@ paths:
|
|||||||
- body
|
- body
|
||||||
x-content-type: multipart/form-data
|
x-content-type: multipart/form-data
|
||||||
x-accepts: text/plain
|
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:
|
components:
|
||||||
requestBodies:
|
requestBodies:
|
||||||
Pet:
|
Pet:
|
||||||
@ -729,4 +746,8 @@ components:
|
|||||||
required:
|
required:
|
||||||
- files
|
- files
|
||||||
type: object
|
type: object
|
||||||
|
securitySchemes:
|
||||||
|
http_auth:
|
||||||
|
scheme: basic
|
||||||
|
type: http
|
||||||
|
|
||||||
|
@ -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 | - |
|
||||||
|
|
@ -76,6 +76,7 @@ import java.net.URI;
|
|||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
|
|
||||||
import org.openapitools.client.auth.Authentication;
|
import org.openapitools.client.auth.Authentication;
|
||||||
|
import org.openapitools.client.auth.HttpBasicAuth;
|
||||||
|
|
||||||
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
|
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
|
||||||
public class ApiClient extends JavaTimeFormatter {
|
public class ApiClient extends JavaTimeFormatter {
|
||||||
@ -127,6 +128,7 @@ public class ApiClient extends JavaTimeFormatter {
|
|||||||
|
|
||||||
// Setup authentications (key: authentication name, value: authentication).
|
// Setup authentications (key: authentication name, value: authentication).
|
||||||
authentications = new HashMap<String, Authentication>();
|
authentications = new HashMap<String, Authentication>();
|
||||||
|
authentications.put("http_auth", new HttpBasicAuth());
|
||||||
// Prevent the authentications from being modified.
|
// Prevent the authentications from being modified.
|
||||||
authentications = Collections.unmodifiableMap(authentications);
|
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!");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -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<String, String> additionalHeaders) throws ApiException {
|
||||||
|
Object localVarPostBody = null;
|
||||||
|
|
||||||
|
// create path and map variables
|
||||||
|
String localVarPath = "/auth/http/basic";
|
||||||
|
|
||||||
|
StringJoiner localVarQueryStringJoiner = new StringJoiner("&");
|
||||||
|
String localVarQueryParameterBaseName;
|
||||||
|
List<Pair> localVarQueryParams = new ArrayList<Pair>();
|
||||||
|
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
|
||||||
|
Map<String, String> localVarHeaderParams = new HashMap<String, String>();
|
||||||
|
Map<String, String> localVarCookieParams = new HashMap<String, String>();
|
||||||
|
Map<String, Object> localVarFormParams = new HashMap<String, Object>();
|
||||||
|
|
||||||
|
|
||||||
|
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<String> localVarReturnType = new TypeReference<String>() {};
|
||||||
|
return apiClient.invokeAPI(
|
||||||
|
localVarPath,
|
||||||
|
"POST",
|
||||||
|
localVarQueryParams,
|
||||||
|
localVarCollectionQueryParams,
|
||||||
|
localVarQueryStringJoiner.toString(),
|
||||||
|
localVarPostBody,
|
||||||
|
localVarHeaderParams,
|
||||||
|
localVarCookieParams,
|
||||||
|
localVarFormParams,
|
||||||
|
localVarAccept,
|
||||||
|
localVarContentType,
|
||||||
|
localVarAuthNames,
|
||||||
|
localVarReturnType
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -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
|
||||||
|
}
|
||||||
|
}
|
@ -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/ServerConfiguration.java
|
||||||
src/main/java/org/openapitools/client/ServerVariable.java
|
src/main/java/org/openapitools/client/ServerVariable.java
|
||||||
src/main/java/org/openapitools/client/StringUtil.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/BodyApi.java
|
||||||
src/main/java/org/openapitools/client/api/FormApi.java
|
src/main/java/org/openapitools/client/api/FormApi.java
|
||||||
src/main/java/org/openapitools/client/api/HeaderApi.java
|
src/main/java/org/openapitools/client/api/HeaderApi.java
|
||||||
|
@ -469,6 +469,23 @@ paths:
|
|||||||
- body
|
- body
|
||||||
x-content-type: multipart/form-data
|
x-content-type: multipart/form-data
|
||||||
x-accepts: text/plain
|
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:
|
components:
|
||||||
requestBodies:
|
requestBodies:
|
||||||
Pet:
|
Pet:
|
||||||
@ -729,4 +746,8 @@ components:
|
|||||||
required:
|
required:
|
||||||
- files
|
- files
|
||||||
type: object
|
type: object
|
||||||
|
securitySchemes:
|
||||||
|
http_auth:
|
||||||
|
scheme: basic
|
||||||
|
type: http
|
||||||
|
|
||||||
|
@ -39,7 +39,15 @@ public class ApiClient {
|
|||||||
this();
|
this();
|
||||||
for(String authName : authNames) {
|
for(String authName : authNames) {
|
||||||
log.log(Level.FINE, "Creating authentication {0}", authName);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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 <code>testAuthHttpBasic</code> 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<String> testAuthHttpBasicWithHttpInfo();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -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
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -5,6 +5,7 @@ README.md
|
|||||||
api/openapi.yaml
|
api/openapi.yaml
|
||||||
build.gradle
|
build.gradle
|
||||||
build.sbt
|
build.sbt
|
||||||
|
docs/AuthApi.md
|
||||||
docs/Bird.md
|
docs/Bird.md
|
||||||
docs/BodyApi.md
|
docs/BodyApi.md
|
||||||
docs/Category.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/RFC3339DateFormat.java
|
||||||
src/main/java/org/openapitools/client/ServerConfiguration.java
|
src/main/java/org/openapitools/client/ServerConfiguration.java
|
||||||
src/main/java/org/openapitools/client/ServerVariable.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/BodyApi.java
|
||||||
src/main/java/org/openapitools/client/api/FormApi.java
|
src/main/java/org/openapitools/client/api/FormApi.java
|
||||||
src/main/java/org/openapitools/client/api/HeaderApi.java
|
src/main/java/org/openapitools/client/api/HeaderApi.java
|
||||||
|
@ -74,20 +74,20 @@ Please follow the [installation](#installation) instruction and execute the foll
|
|||||||
|
|
||||||
import org.openapitools.client.*;
|
import org.openapitools.client.*;
|
||||||
import org.openapitools.client.model.*;
|
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) {
|
public static void main(String[] args) {
|
||||||
ApiClient defaultClient = Configuration.getDefaultApiClient();
|
ApiClient defaultClient = Configuration.getDefaultApiClient();
|
||||||
// Configure clients using the `defaultClient` object, such as
|
// Configure clients using the `defaultClient` object, such as
|
||||||
// overriding the host and port, timeout, etc.
|
// overriding the host and port, timeout, etc.
|
||||||
BodyApi apiInstance = new BodyApi(defaultClient);
|
AuthApi apiInstance = new AuthApi(defaultClient);
|
||||||
try {
|
try {
|
||||||
File result = apiInstance.testBinaryGif();
|
String result = apiInstance.testAuthHttpBasic();
|
||||||
System.out.println(result);
|
System.out.println(result);
|
||||||
} catch (ApiException e) {
|
} 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("Status code: " + e.getCode());
|
||||||
System.err.println("Reason: " + e.getResponseBody());
|
System.err.println("Reason: " + e.getResponseBody());
|
||||||
System.err.println("Response headers: " + e.getResponseHeaders());
|
System.err.println("Response headers: " + e.getResponseHeaders());
|
||||||
@ -104,6 +104,8 @@ All URIs are relative to *http://localhost:3000*
|
|||||||
|
|
||||||
Class | Method | HTTP request | Description
|
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* | [**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* | [**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)
|
*BodyApi* | [**testBodyApplicationOctetstreamBinary**](docs/BodyApi.md#testBodyApplicationOctetstreamBinary) | **POST** /body/application/octetstream/binary | Test body parameter(s)
|
||||||
@ -162,7 +164,13 @@ Class | Method | HTTP request | Description
|
|||||||
<a id="documentation-for-authorization"></a>
|
<a id="documentation-for-authorization"></a>
|
||||||
## Documentation for Authorization
|
## Documentation for Authorization
|
||||||
|
|
||||||
Endpoints do not require authorization.
|
|
||||||
|
Authentication schemes defined for the API:
|
||||||
|
<a id="http_auth"></a>
|
||||||
|
### http_auth
|
||||||
|
|
||||||
|
|
||||||
|
- **Type**: HTTP basic authentication
|
||||||
|
|
||||||
|
|
||||||
## Recommendation
|
## Recommendation
|
||||||
|
@ -469,6 +469,23 @@ paths:
|
|||||||
- body
|
- body
|
||||||
x-content-type: multipart/form-data
|
x-content-type: multipart/form-data
|
||||||
x-accepts: text/plain
|
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:
|
components:
|
||||||
requestBodies:
|
requestBodies:
|
||||||
Pet:
|
Pet:
|
||||||
@ -729,4 +746,8 @@ components:
|
|||||||
required:
|
required:
|
||||||
- files
|
- files
|
||||||
type: object
|
type: object
|
||||||
|
securitySchemes:
|
||||||
|
http_auth:
|
||||||
|
scheme: basic
|
||||||
|
type: http
|
||||||
|
|
||||||
|
148
samples/client/echo_api/java/native/docs/AuthApi.md
Normal file
148
samples/client/echo_api/java/native/docs/AuthApi.md
Normal file
@ -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<String> 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<String> 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 | - |
|
||||||
|
|
@ -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<HttpRequest.Builder> memberVarInterceptor;
|
||||||
|
private final Duration memberVarReadTimeout;
|
||||||
|
private final Consumer<HttpResponse<InputStream>> memberVarResponseInterceptor;
|
||||||
|
private final Consumer<HttpResponse<String>> 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<InputStream> 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<String> 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<String> testAuthHttpBasicWithHttpInfo() throws ApiException {
|
||||||
|
HttpRequest.Builder localVarRequestBuilder = testAuthHttpBasicRequestBuilder();
|
||||||
|
try {
|
||||||
|
HttpResponse<InputStream> 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<String>(
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
@ -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
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -5,6 +5,7 @@ README.md
|
|||||||
api/openapi.yaml
|
api/openapi.yaml
|
||||||
build.gradle
|
build.gradle
|
||||||
build.sbt
|
build.sbt
|
||||||
|
docs/AuthApi.md
|
||||||
docs/Bird.md
|
docs/Bird.md
|
||||||
docs/BodyApi.md
|
docs/BodyApi.md
|
||||||
docs/Category.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/ServerConfiguration.java
|
||||||
src/main/java/org/openapitools/client/ServerVariable.java
|
src/main/java/org/openapitools/client/ServerVariable.java
|
||||||
src/main/java/org/openapitools/client/StringUtil.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/BodyApi.java
|
||||||
src/main/java/org/openapitools/client/api/FormApi.java
|
src/main/java/org/openapitools/client/api/FormApi.java
|
||||||
src/main/java/org/openapitools/client/api/HeaderApi.java
|
src/main/java/org/openapitools/client/api/HeaderApi.java
|
||||||
|
@ -82,20 +82,26 @@ Please follow the [installation](#installation) instruction and execute the foll
|
|||||||
import org.openapitools.client.ApiClient;
|
import org.openapitools.client.ApiClient;
|
||||||
import org.openapitools.client.ApiException;
|
import org.openapitools.client.ApiException;
|
||||||
import org.openapitools.client.Configuration;
|
import org.openapitools.client.Configuration;
|
||||||
|
import org.openapitools.client.auth.*;
|
||||||
import org.openapitools.client.models.*;
|
import org.openapitools.client.models.*;
|
||||||
import org.openapitools.client.api.BodyApi;
|
import org.openapitools.client.api.AuthApi;
|
||||||
|
|
||||||
public class Example {
|
public class Example {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
ApiClient defaultClient = Configuration.getDefaultApiClient();
|
ApiClient defaultClient = Configuration.getDefaultApiClient();
|
||||||
defaultClient.setBasePath("http://localhost:3000");
|
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 {
|
try {
|
||||||
File result = apiInstance.testBinaryGif();
|
String result = apiInstance.testAuthHttpBasic();
|
||||||
System.out.println(result);
|
System.out.println(result);
|
||||||
} catch (ApiException e) {
|
} 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("Status code: " + e.getCode());
|
||||||
System.err.println("Reason: " + e.getResponseBody());
|
System.err.println("Reason: " + e.getResponseBody());
|
||||||
System.err.println("Response headers: " + e.getResponseHeaders());
|
System.err.println("Response headers: " + e.getResponseHeaders());
|
||||||
@ -112,6 +118,7 @@ All URIs are relative to *http://localhost:3000*
|
|||||||
|
|
||||||
Class | Method | HTTP request | Description
|
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* | [**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* | [**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
|
*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
|
|||||||
<a id="documentation-for-authorization"></a>
|
<a id="documentation-for-authorization"></a>
|
||||||
## Documentation for Authorization
|
## Documentation for Authorization
|
||||||
|
|
||||||
Endpoints do not require authorization.
|
|
||||||
|
Authentication schemes defined for the API:
|
||||||
|
<a id="http_auth"></a>
|
||||||
|
### http_auth
|
||||||
|
|
||||||
|
- **Type**: HTTP basic authentication
|
||||||
|
|
||||||
|
|
||||||
## Recommendation
|
## Recommendation
|
||||||
|
@ -469,6 +469,23 @@ paths:
|
|||||||
- body
|
- body
|
||||||
x-content-type: multipart/form-data
|
x-content-type: multipart/form-data
|
||||||
x-accepts: text/plain
|
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:
|
components:
|
||||||
requestBodies:
|
requestBodies:
|
||||||
Pet:
|
Pet:
|
||||||
@ -729,4 +746,8 @@ components:
|
|||||||
required:
|
required:
|
||||||
- files
|
- files
|
||||||
type: object
|
type: object
|
||||||
|
securitySchemes:
|
||||||
|
http_auth:
|
||||||
|
scheme: basic
|
||||||
|
type: http
|
||||||
|
|
||||||
|
73
samples/client/echo_api/java/okhttp-gson/docs/AuthApi.md
Normal file
73
samples/client/echo_api/java/okhttp-gson/docs/AuthApi.md
Normal file
@ -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 |
|
||||||
|
|
||||||
|
|
||||||
|
<a id="testAuthHttpBasic"></a>
|
||||||
|
# **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 | - |
|
||||||
|
|
@ -99,6 +99,7 @@ public class ApiClient {
|
|||||||
initHttpClient();
|
initHttpClient();
|
||||||
|
|
||||||
// Setup authentications (key: authentication name, value: authentication).
|
// Setup authentications (key: authentication name, value: authentication).
|
||||||
|
authentications.put("http_auth", new HttpBasicAuth());
|
||||||
// Prevent the authentications from being modified.
|
// Prevent the authentications from being modified.
|
||||||
authentications = Collections.unmodifiableMap(authentications);
|
authentications = Collections.unmodifiableMap(authentications);
|
||||||
}
|
}
|
||||||
@ -114,6 +115,7 @@ public class ApiClient {
|
|||||||
httpClient = client;
|
httpClient = client;
|
||||||
|
|
||||||
// Setup authentications (key: authentication name, value: authentication).
|
// Setup authentications (key: authentication name, value: authentication).
|
||||||
|
authentications.put("http_auth", new HttpBasicAuth());
|
||||||
// Prevent the authentications from being modified.
|
// Prevent the authentications from being modified.
|
||||||
authentications = Collections.unmodifiableMap(authentications);
|
authentications = Collections.unmodifiableMap(authentications);
|
||||||
}
|
}
|
||||||
|
@ -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
|
||||||
|
<table summary="Response Details" border="1">
|
||||||
|
<tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
|
||||||
|
<tr><td> 200 </td><td> Successful operation </td><td> - </td></tr>
|
||||||
|
</table>
|
||||||
|
*/
|
||||||
|
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<Pair> localVarQueryParams = new ArrayList<Pair>();
|
||||||
|
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
|
||||||
|
Map<String, String> localVarHeaderParams = new HashMap<String, String>();
|
||||||
|
Map<String, String> localVarCookieParams = new HashMap<String, String>();
|
||||||
|
Map<String, Object> localVarFormParams = new HashMap<String, Object>();
|
||||||
|
|
||||||
|
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
|
||||||
|
<table summary="Response Details" border="1">
|
||||||
|
<tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
|
||||||
|
<tr><td> 200 </td><td> Successful operation </td><td> - </td></tr>
|
||||||
|
</table>
|
||||||
|
*/
|
||||||
|
public String testAuthHttpBasic() throws ApiException {
|
||||||
|
ApiResponse<String> 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
|
||||||
|
<table summary="Response Details" border="1">
|
||||||
|
<tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
|
||||||
|
<tr><td> 200 </td><td> Successful operation </td><td> - </td></tr>
|
||||||
|
</table>
|
||||||
|
*/
|
||||||
|
public ApiResponse<String> testAuthHttpBasicWithHttpInfo() throws ApiException {
|
||||||
|
okhttp3.Call localVarCall = testAuthHttpBasicValidateBeforeCall(null);
|
||||||
|
Type localVarReturnType = new TypeToken<String>(){}.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
|
||||||
|
<table summary="Response Details" border="1">
|
||||||
|
<tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
|
||||||
|
<tr><td> 200 </td><td> Successful operation </td><td> - </td></tr>
|
||||||
|
</table>
|
||||||
|
*/
|
||||||
|
public okhttp3.Call testAuthHttpBasicAsync(final ApiCallback<String> _callback) throws ApiException {
|
||||||
|
|
||||||
|
okhttp3.Call localVarCall = testAuthHttpBasicValidateBeforeCall(_callback);
|
||||||
|
Type localVarReturnType = new TypeToken<String>(){}.getType();
|
||||||
|
localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
|
||||||
|
return localVarCall;
|
||||||
|
}
|
||||||
|
}
|
@ -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
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -3,6 +3,7 @@
|
|||||||
.gitlab-ci.yml
|
.gitlab-ci.yml
|
||||||
.travis.yml
|
.travis.yml
|
||||||
README.md
|
README.md
|
||||||
|
docs/AuthApi.md
|
||||||
docs/Bird.md
|
docs/Bird.md
|
||||||
docs/BodyApi.md
|
docs/BodyApi.md
|
||||||
docs/Category.md
|
docs/Category.md
|
||||||
@ -22,6 +23,7 @@ docs/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.md
|
|||||||
git_push.sh
|
git_push.sh
|
||||||
openapi_client/__init__.py
|
openapi_client/__init__.py
|
||||||
openapi_client/api/__init__.py
|
openapi_client/api/__init__.py
|
||||||
|
openapi_client/api/auth_api.py
|
||||||
openapi_client/api/body_api.py
|
openapi_client/api/body_api.py
|
||||||
openapi_client/api/form_api.py
|
openapi_client/api/form_api.py
|
||||||
openapi_client/api/header_api.py
|
openapi_client/api/header_api.py
|
||||||
|
@ -61,20 +61,30 @@ configuration = openapi_client.Configuration(
|
|||||||
host = "http://localhost:3000"
|
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
|
# Enter a context with an instance of the API client
|
||||||
with openapi_client.ApiClient(configuration) as api_client:
|
with openapi_client.ApiClient(configuration) as api_client:
|
||||||
# Create an instance of the API class
|
# Create an instance of the API class
|
||||||
api_instance = openapi_client.BodyApi(api_client)
|
api_instance = openapi_client.AuthApi(api_client)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Test binary (gif) response body
|
# To test HTTP basic authentication
|
||||||
api_response = api_instance.test_binary_gif()
|
api_response = api_instance.test_auth_http_basic()
|
||||||
print("The response of BodyApi->test_binary_gif:\n")
|
print("The response of AuthApi->test_auth_http_basic:\n")
|
||||||
pprint(api_response)
|
pprint(api_response)
|
||||||
except ApiException as e:
|
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
|
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_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_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
|
*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
|
|||||||
<a id="documentation-for-authorization"></a>
|
<a id="documentation-for-authorization"></a>
|
||||||
## Documentation For Authorization
|
## Documentation For Authorization
|
||||||
|
|
||||||
Endpoints do not require authorization.
|
|
||||||
|
Authentication schemes defined for the API:
|
||||||
|
<a id="http_auth"></a>
|
||||||
|
### http_auth
|
||||||
|
|
||||||
|
- **Type**: HTTP basic authentication
|
||||||
|
|
||||||
|
|
||||||
## Author
|
## Author
|
||||||
|
82
samples/client/echo_api/python/docs/AuthApi.md
Normal file
82
samples/client/echo_api/python/docs/AuthApi.md
Normal file
@ -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)
|
||||||
|
|
@ -18,6 +18,7 @@
|
|||||||
__version__ = "1.0.0"
|
__version__ = "1.0.0"
|
||||||
|
|
||||||
# import apis into sdk package
|
# 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.body_api import BodyApi
|
||||||
from openapi_client.api.form_api import FormApi
|
from openapi_client.api.form_api import FormApi
|
||||||
from openapi_client.api.header_api import HeaderApi
|
from openapi_client.api.header_api import HeaderApi
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
# flake8: noqa
|
# flake8: noqa
|
||||||
|
|
||||||
# import apis into api package
|
# 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.body_api import BodyApi
|
||||||
from openapi_client.api.form_api import FormApi
|
from openapi_client.api.form_api import FormApi
|
||||||
from openapi_client.api.header_api import HeaderApi
|
from openapi_client.api.header_api import HeaderApi
|
||||||
|
174
samples/client/echo_api/python/openapi_client/api/auth_api.py
Normal file
174
samples/client/echo_api/python/openapi_client/api/auth_api.py
Normal file
@ -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'))
|
@ -54,6 +54,23 @@ class Configuration:
|
|||||||
:param ssl_ca_cert: str - the path to a file of concatenated CA certificates
|
:param ssl_ca_cert: str - the path to a file of concatenated CA certificates
|
||||||
in PEM format.
|
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
|
_default = None
|
||||||
@ -358,6 +375,13 @@ class Configuration:
|
|||||||
:return: The Auth Settings information dict.
|
:return: The Auth Settings information dict.
|
||||||
"""
|
"""
|
||||||
auth = {}
|
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
|
return auth
|
||||||
|
|
||||||
def to_debug_report(self):
|
def to_debug_report(self):
|
||||||
|
39
samples/client/echo_api/python/test/test_auth_api.py
Normal file
39
samples/client/echo_api/python/test/test_auth_api.py
Normal file
@ -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()
|
@ -130,6 +130,19 @@ class TestManual(unittest.TestCase):
|
|||||||
api_response = api_instance.test_echo_body_free_form_object_response_string({})
|
api_response = api_instance.test_echo_body_free_form_object_response_string({})
|
||||||
self.assertEqual(api_response, "{}") # assertion to ensure {} is sent in the body
|
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):
|
def echoServerResponseParaserTest(self):
|
||||||
s = """POST /echo/body/Pet/response_string HTTP/1.1
|
s = """POST /echo/body/Pet/response_string HTTP/1.1
|
||||||
Host: localhost:3000
|
Host: localhost:3000
|
||||||
|
Loading…
x
Reference in New Issue
Block a user