-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from databox/release/0.3.15-sdk.2/1720094676654
[SDK release] Generated SDK code based on data-link 0.3.15-sdk.2 API changes
- Loading branch information
Showing
2 changed files
with
165 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,160 @@ | ||
# Databox - the C# library for the Static OpenAPI document of Push API resource | ||
|
||
Push API resources Open API documentation | ||
|
||
This C# SDK is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project: | ||
|
||
- API version: 1.0 | ||
- SDK version: 0.0.2 | ||
- Generator version: 7.6.0 | ||
- Build package: org.openapitools.codegen.languages.CSharpClientCodegen | ||
|
||
<a id="frameworks-supported"></a> | ||
## Frameworks supported | ||
|
||
<a id="dependencies"></a> | ||
## Dependencies | ||
|
||
- [Json.NET](https://www.nuget.org/packages/Newtonsoft.Json/) - 13.0.2 or later | ||
- [JsonSubTypes](https://www.nuget.org/packages/JsonSubTypes/) - 1.8.0 or later | ||
- [System.ComponentModel.Annotations](https://www.nuget.org/packages/System.ComponentModel.Annotations) - 5.0.0 or later | ||
|
||
The DLLs included in the package may not be the latest version. We recommend using [NuGet](https://docs.nuget.org/consume/installing-nuget) to obtain the latest version of the packages: | ||
``` | ||
Install-Package Newtonsoft.Json | ||
Install-Package JsonSubTypes | ||
Install-Package System.ComponentModel.Annotations | ||
``` | ||
<a id="installation"></a> | ||
## Installation | ||
Run the following command to generate the DLL | ||
- [Mac/Linux] `/bin/sh build.sh` | ||
- [Windows] `build.bat` | ||
|
||
Then include the DLL (under the `bin` folder) in the C# project, and use the namespaces: | ||
```csharp | ||
using Databox.Api; | ||
using Databox.Client; | ||
using Databox.Model; | ||
``` | ||
<a id="packaging"></a> | ||
## Packaging | ||
|
||
A `.nuspec` is included with the project. You can follow the Nuget quickstart to [create](https://docs.microsoft.com/en-us/nuget/quickstart/create-and-publish-a-package#create-the-package) and [publish](https://docs.microsoft.com/en-us/nuget/quickstart/create-and-publish-a-package#publish-the-package) packages. | ||
|
||
This `.nuspec` uses placeholders from the `.csproj`, so build the `.csproj` directly: | ||
|
||
``` | ||
nuget pack -Build -OutputDirectory out Databox.csproj | ||
``` | ||
|
||
Then, publish to a [local feed](https://docs.microsoft.com/en-us/nuget/hosting-packages/local-feeds) or [other host](https://docs.microsoft.com/en-us/nuget/hosting-packages/overview) and consume the new package via Nuget as usual. | ||
|
||
<a id="usage"></a> | ||
## Usage | ||
|
||
To use the API client with a HTTP proxy, setup a `System.Net.WebProxy` | ||
```csharp | ||
Configuration c = new Configuration(); | ||
System.Net.WebProxy webProxy = new System.Net.WebProxy("http://myProxyUrl:80/"); | ||
webProxy.Credentials = System.Net.CredentialCache.DefaultCredentials; | ||
c.Proxy = webProxy; | ||
``` | ||
|
||
### Connections | ||
Each ApiClass (properly the ApiClient inside it) will create an instance of HttpClient. It will use that for the entire lifecycle and dispose it when called the Dispose method. | ||
|
||
To better manager the connections it's a common practice to reuse the HttpClient and HttpClientHandler (see [here](https://docs.microsoft.com/en-us/dotnet/architecture/microservices/implement-resilient-applications/use-httpclientfactory-to-implement-resilient-http-requests#issues-with-the-original-httpclient-class-available-in-net) for details). To use your own HttpClient instance just pass it to the ApiClass constructor. | ||
|
||
```csharp | ||
HttpClientHandler yourHandler = new HttpClientHandler(); | ||
HttpClient yourHttpClient = new HttpClient(yourHandler); | ||
var api = new YourApiClass(yourHttpClient, yourHandler); | ||
``` | ||
|
||
If you want to use an HttpClient and don't have access to the handler, for example in a DI context in Asp.net Core when using IHttpClientFactory. | ||
|
||
```csharp | ||
HttpClient yourHttpClient = new HttpClient(); | ||
var api = new YourApiClass(yourHttpClient); | ||
``` | ||
You'll loose some configuration settings, the features affected are: Setting and Retrieving Cookies, Client Certificates, Proxy settings. You need to either manually handle those in your setup of the HttpClient or they won't be available. | ||
|
||
Here an example of DI setup in a sample web project: | ||
|
||
```csharp | ||
services.AddHttpClient<YourApiClass>(httpClient => | ||
new PetApi(httpClient)); | ||
``` | ||
|
||
|
||
<a id="getting-started"></a> | ||
## Getting Started | ||
|
||
```csharp | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.Net.Http; | ||
using Databox.Api; | ||
using Databox.Client; | ||
using Databox.Model; | ||
|
||
namespace Example | ||
{ | ||
public class Example | ||
{ | ||
public static void Main() | ||
{ | ||
|
||
Configuration config = new Configuration(); | ||
config.BasePath = "http://localhost:8080/q/openapi"; | ||
// create instances of HttpClient, HttpClientHandler to be reused later with different Api classes | ||
HttpClient httpClient = new HttpClient(); | ||
HttpClientHandler httpClientHandler = new HttpClientHandler(); | ||
var apiInstance = new DefaultApi(httpClient, config, httpClientHandler); | ||
var payloadModel = new PayloadModel?(); // PayloadModel? | (optional) | ||
try | ||
{ | ||
apiInstance.RootPost(payloadModel); | ||
} | ||
catch (ApiException e) | ||
{ | ||
Debug.Print("Exception when calling DefaultApi.RootPost: " + e.Message ); | ||
Debug.Print("Status Code: "+ e.ErrorCode); | ||
Debug.Print(e.StackTrace); | ||
} | ||
|
||
} | ||
} | ||
} | ||
``` | ||
|
||
<a id="documentation-for-api-endpoints"></a> | ||
## Documentation for API Endpoints | ||
|
||
All URIs are relative to *http://localhost:8080/q/openapi* | ||
|
||
Class | Method | HTTP request | Description | ||
------------ | ------------- | ------------- | ------------- | ||
*DefaultApi* | [**RootPost**](docs/DefaultApi.md#rootpost) | **POST** / | | ||
|
||
|
||
<a id="documentation-for-models"></a> | ||
## Documentation for Models | ||
|
||
- [Model.ApiResponse](docs/ApiResponse.md) | ||
- [Model.PayloadDataModel](docs/PayloadDataModel.md) | ||
- [Model.PayloadModel](docs/PayloadModel.md) | ||
|
||
|
||
<a id="documentation-for-authorization"></a> | ||
## Documentation for Authorization | ||
|
||
|
||
Authentication schemes defined for the API: | ||
<a id="basicAuth"></a> | ||
### basicAuth | ||
|
||
- **Type**: HTTP basic authentication | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters