mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-19 08:17:06 +00:00
[C#] fix validate (#16097)
* fix validation with discriminator using parent instead * add new files * add new workflow * fix
This commit is contained in:
154
samples/client/echo_api/csharp-restsharp/README.md
Normal file
154
samples/client/echo_api/csharp-restsharp/README.md
Normal file
@@ -0,0 +1,154 @@
|
||||
# Org.OpenAPITools - the C# library for the Echo Server API
|
||||
|
||||
Echo Server API
|
||||
|
||||
This C# SDK is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:
|
||||
|
||||
- API version: 0.1.0
|
||||
- SDK version: 1.0.0
|
||||
- Build package: org.openapitools.codegen.languages.CSharpClientCodegen
|
||||
|
||||
<a id="frameworks-supported"></a>
|
||||
## Frameworks supported
|
||||
|
||||
<a id="dependencies"></a>
|
||||
## Dependencies
|
||||
|
||||
- [RestSharp](https://www.nuget.org/packages/RestSharp) - 106.13.0 or later
|
||||
- [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 RestSharp
|
||||
Install-Package Newtonsoft.Json
|
||||
Install-Package JsonSubTypes
|
||||
Install-Package System.ComponentModel.Annotations
|
||||
```
|
||||
|
||||
NOTE: RestSharp versions greater than 105.1.0 have a bug which causes file uploads to fail. See [RestSharp#742](https://github.com/restsharp/RestSharp/issues/742).
|
||||
NOTE: RestSharp for .Net Core creates a new socket for each api call, which can lead to a socket exhaustion problem. See [RestSharp#1406](https://github.com/restsharp/RestSharp/issues/1406).
|
||||
|
||||
<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 Org.OpenAPITools.Api;
|
||||
using Org.OpenAPITools.Client;
|
||||
using Org.OpenAPITools.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 Org.OpenAPITools.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;
|
||||
```
|
||||
|
||||
<a id="getting-started"></a>
|
||||
## Getting Started
|
||||
|
||||
```csharp
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using Org.OpenAPITools.Api;
|
||||
using Org.OpenAPITools.Client;
|
||||
using Org.OpenAPITools.Model;
|
||||
|
||||
namespace Example
|
||||
{
|
||||
public class Example
|
||||
{
|
||||
public static void Main()
|
||||
{
|
||||
|
||||
Configuration config = new Configuration();
|
||||
config.BasePath = "http://localhost:3000";
|
||||
var apiInstance = new BodyApi(config);
|
||||
|
||||
try
|
||||
{
|
||||
// Test binary (gif) response body
|
||||
System.IO.Stream result = apiInstance.TestBinaryGif();
|
||||
Debug.WriteLine(result);
|
||||
}
|
||||
catch (ApiException e)
|
||||
{
|
||||
Debug.Print("Exception when calling BodyApi.TestBinaryGif: " + 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:3000*
|
||||
|
||||
Class | Method | HTTP request | Description
|
||||
------------ | ------------- | ------------- | -------------
|
||||
*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* | [**TestEchoBodyFreeFormObjectResponseString**](docs/BodyApi.md#testechobodyfreeformobjectresponsestring) | **POST** /echo/body/FreeFormObject/response_string | Test free form object
|
||||
*BodyApi* | [**TestEchoBodyPet**](docs/BodyApi.md#testechobodypet) | **POST** /echo/body/Pet | Test body parameter(s)
|
||||
*BodyApi* | [**TestEchoBodyPetResponseString**](docs/BodyApi.md#testechobodypetresponsestring) | **POST** /echo/body/Pet/response_string | Test empty response body
|
||||
*BodyApi* | [**TestEchoBodyTagResponseString**](docs/BodyApi.md#testechobodytagresponsestring) | **POST** /echo/body/Tag/response_string | Test empty json (request body)
|
||||
*FormApi* | [**TestFormIntegerBooleanString**](docs/FormApi.md#testformintegerbooleanstring) | **POST** /form/integer/boolean/string | Test form parameter(s)
|
||||
*HeaderApi* | [**TestHeaderIntegerBooleanString**](docs/HeaderApi.md#testheaderintegerbooleanstring) | **GET** /header/integer/boolean/string | Test header parameter(s)
|
||||
*PathApi* | [**TestsPathStringPathStringIntegerPathInteger**](docs/PathApi.md#testspathstringpathstringintegerpathinteger) | **GET** /path/string/{path_string}/integer/{path_integer} | Test path parameter(s)
|
||||
*QueryApi* | [**TestEnumRefString**](docs/QueryApi.md#testenumrefstring) | **GET** /query/enum_ref_string | Test query parameter(s)
|
||||
*QueryApi* | [**TestQueryDatetimeDateString**](docs/QueryApi.md#testquerydatetimedatestring) | **GET** /query/datetime/date/string | Test query parameter(s)
|
||||
*QueryApi* | [**TestQueryIntegerBooleanString**](docs/QueryApi.md#testqueryintegerbooleanstring) | **GET** /query/integer/boolean/string | Test query parameter(s)
|
||||
*QueryApi* | [**TestQueryStyleDeepObjectExplodeTrueObject**](docs/QueryApi.md#testquerystyledeepobjectexplodetrueobject) | **GET** /query/style_deepObject/explode_true/object | Test query parameter(s)
|
||||
*QueryApi* | [**TestQueryStyleDeepObjectExplodeTrueObjectAllOf**](docs/QueryApi.md#testquerystyledeepobjectexplodetrueobjectallof) | **GET** /query/style_deepObject/explode_true/object/allOf | Test query parameter(s)
|
||||
*QueryApi* | [**TestQueryStyleFormExplodeTrueArrayString**](docs/QueryApi.md#testquerystyleformexplodetruearraystring) | **GET** /query/style_form/explode_true/array_string | Test query parameter(s)
|
||||
*QueryApi* | [**TestQueryStyleFormExplodeTrueObject**](docs/QueryApi.md#testquerystyleformexplodetrueobject) | **GET** /query/style_form/explode_true/object | Test query parameter(s)
|
||||
*QueryApi* | [**TestQueryStyleFormExplodeTrueObjectAllOf**](docs/QueryApi.md#testquerystyleformexplodetrueobjectallof) | **GET** /query/style_form/explode_true/object/allOf | Test query parameter(s)
|
||||
|
||||
|
||||
<a id="documentation-for-models"></a>
|
||||
## Documentation for Models
|
||||
|
||||
- [Model.Bird](docs/Bird.md)
|
||||
- [Model.Category](docs/Category.md)
|
||||
- [Model.DataQuery](docs/DataQuery.md)
|
||||
- [Model.DefaultValue](docs/DefaultValue.md)
|
||||
- [Model.NumberPropertiesOnly](docs/NumberPropertiesOnly.md)
|
||||
- [Model.Pet](docs/Pet.md)
|
||||
- [Model.Query](docs/Query.md)
|
||||
- [Model.StringEnumRef](docs/StringEnumRef.md)
|
||||
- [Model.Tag](docs/Tag.md)
|
||||
- [Model.TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter](docs/TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.md)
|
||||
- [Model.TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter](docs/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.md)
|
||||
|
||||
|
||||
<a id="documentation-for-authorization"></a>
|
||||
## Documentation for Authorization
|
||||
|
||||
Endpoints do not require authorization.
|
||||
|
||||
Reference in New Issue
Block a user