forked from loafle/openapi-generator-original
* add auto-generated doc for c# 2.0 generator * update readme for c# 2.0 * update readme * update namespace in the doc
154 lines
5.1 KiB
Plaintext
154 lines
5.1 KiB
Plaintext
# {{packageName}} - the C# library for the {{appName}}
|
|
|
|
{{#appDescription}}
|
|
{{{appDescription}}}
|
|
{{/appDescription}}
|
|
|
|
This C# SDK is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project:
|
|
|
|
- API version: {{appVersion}}
|
|
- SDK version: {{packageVersion}}
|
|
{{^hideGenerationTimestamp}}
|
|
- Build date: {{generatedDate}}
|
|
{{/hideGenerationTimestamp}}
|
|
- Build package: {{generatorClass}}
|
|
{{#infoUrl}}
|
|
For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}})
|
|
{{/infoUrl}}
|
|
|
|
<a name="frameworks-supported"></a>
|
|
## Frameworks supported
|
|
{{^supportUWP}}
|
|
- .NET 2.0
|
|
{{/supportUWP}}
|
|
{{#supportUWP}}
|
|
- UWP
|
|
{{/supportUWP}}
|
|
|
|
<a name="dependencies"></a>
|
|
## Dependencies
|
|
- Mono compiler
|
|
- Newtonsoft.Json.7.0.1
|
|
- RestSharp.Net2.1.1.11
|
|
|
|
Note: NuGet is downloaded by the mono compilation script and packages are installed with it. No dependency DLLs are bundled with this generator
|
|
|
|
<a name="installation"></a>
|
|
## Installation
|
|
Run the following command to generate the DLL
|
|
- [Mac/Linux] `/bin/sh compile-mono.sh`
|
|
- [Windows] TODO
|
|
|
|
Then include the DLL (under the `bin` folder) in the C# project, and use the namespaces:
|
|
```csharp
|
|
using {{packageName}}.{{apiPackage}};
|
|
using {{packageName}}.Client;
|
|
using {{packageName}}.{{modelPackage}};
|
|
```
|
|
<a name="getting-started"></a>
|
|
## Getting Started
|
|
|
|
```csharp
|
|
using System;
|
|
using System.Diagnostics;
|
|
using {{apiPackage}};
|
|
using {{packageName}}.Client;
|
|
using {{modelPackage}};
|
|
|
|
namespace Example
|
|
{
|
|
public class {{operationId}}Example
|
|
{
|
|
public void main()
|
|
{
|
|
{{#apiInfo}}{{#apis}}{{#-first}}{{#operations}}{{#operation}}{{#-first}}{{#hasAuthMethods}}{{#authMethods}}{{#isBasic}}
|
|
// Configure HTTP basic authorization: {{{name}}}
|
|
Configuration.Default.Username = "YOUR_USERNAME";
|
|
Configuration.Default.Password = "YOUR_PASSWORD";{{/isBasic}}{{#isApiKey}}
|
|
// Configure API key authorization: {{{name}}}
|
|
Configuration.Default.ApiKey.Add("{{{keyParamName}}}", "YOUR_API_KEY");
|
|
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
|
|
// Configuration.Default.ApiKeyPrefix.Add("{{{keyParamName}}}", "Bearer");{{/isApiKey}}{{#isOAuth}}
|
|
// Configure OAuth2 access token for authorization: {{{name}}}
|
|
Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN";{{/isOAuth}}{{/authMethods}}
|
|
{{/hasAuthMethods}}
|
|
|
|
var apiInstance = new {{classname}}();
|
|
{{#allParams}}
|
|
{{#isPrimitiveType}}
|
|
var {{paramName}} = {{example}}; // {{{dataType}}} | {{{description}}}{{^required}} (optional) {{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}}
|
|
{{/isPrimitiveType}}
|
|
{{^isPrimitiveType}}
|
|
var {{paramName}} = new {{{dataType}}}(); // {{{dataType}}} | {{{description}}}{{^required}} (optional) {{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}}
|
|
{{/isPrimitiveType}}
|
|
{{/allParams}}
|
|
|
|
try
|
|
{
|
|
{{#summary}}
|
|
// {{{.}}}
|
|
{{/summary}}
|
|
{{#returnType}}{{{.}}} result = {{/returnType}}apiInstance.{{{operationId}}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});{{#returnType}}
|
|
Debug.WriteLine(result);{{/returnType}}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Debug.Print("Exception when calling {{classname}}.{{operationId}}: " + e.Message );
|
|
}
|
|
}
|
|
}
|
|
}{{/-first}}{{/operation}}{{/operations}}{{/-first}}{{/apis}}{{/apiInfo}}
|
|
```
|
|
|
|
<a name="documentation-for-api-endpoints"></a>
|
|
## Documentation for API Endpoints
|
|
|
|
All URIs are relative to *{{{basePath}}}*
|
|
|
|
Class | Method | HTTP request | Description
|
|
------------ | ------------- | ------------- | -------------
|
|
{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}*{{classname}}* | [**{{operationId}}**]({{apiDocPath}}{{classname}}.md#{{operationIdLowerCase}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{{summary}}}{{/summary}}
|
|
{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}}
|
|
|
|
<a name="documentation-for-models"></a>
|
|
## Documentation for Models
|
|
|
|
{{#modelPackage}}
|
|
{{#models}}{{#model}} - [{{{modelPackage}}}.{{{classname}}}]({{modelDocPath}}{{{classname}}}.md)
|
|
{{/model}}{{/models}}
|
|
{{/modelPackage}}
|
|
{{^modelPackage}}
|
|
No model defined in this package
|
|
{{/modelPackage}}
|
|
|
|
<a name="documentation-for-authorization"></a>
|
|
## Documentation for Authorization
|
|
|
|
{{^authMethods}}
|
|
All endpoints do not require authorization.
|
|
{{/authMethods}}
|
|
{{#authMethods}}
|
|
{{#last}}
|
|
Authentication schemes defined for the API:
|
|
{{/last}}
|
|
{{/authMethods}}
|
|
{{#authMethods}}
|
|
<a name="{{name}}"></a>
|
|
### {{name}}
|
|
|
|
{{#isApiKey}}- **Type**: API key
|
|
- **API key parameter name**: {{keyParamName}}
|
|
- **Location**: {{#isKeyInQuery}}URL query string{{/isKeyInQuery}}{{#isKeyInHeader}}HTTP header{{/isKeyInHeader}}
|
|
{{/isApiKey}}
|
|
{{#isBasic}}- **Type**: HTTP basic authentication
|
|
{{/isBasic}}
|
|
{{#isOAuth}}- **Type**: OAuth
|
|
- **Flow**: {{flow}}
|
|
- **Authorization URL**: {{authorizationUrl}}
|
|
- **Scopes**: {{^scopes}}N/A{{/scopes}}
|
|
{{#scopes}} - {{scope}}: {{description}}
|
|
{{/scopes}}
|
|
{{/isOAuth}}
|
|
|
|
{{/authMethods}}
|