[csharp] Making example code snippet compilable (#3019)

* fix(okhttp-gson): Updating example

* fix(csharp): Updating example

* fix(csharp): Updating pet project

* fix(csharp): Updating example
This commit is contained in:
Sai Giridhar P 2019-05-28 22:27:06 +05:30 committed by William Cheng
parent 499c8ac5c1
commit 0a037ae111
9 changed files with 234 additions and 156 deletions

View File

@ -102,7 +102,6 @@ Then, publish to a [local feed](https://docs.microsoft.com/en-us/nuget/hosting-p
## Getting Started ## Getting Started
```csharp ```csharp
using System;
using System.Diagnostics; using System.Diagnostics;
using {{packageName}}.{{apiPackage}}; using {{packageName}}.{{apiPackage}};
using {{packageName}}.Client; using {{packageName}}.Client;
@ -112,9 +111,10 @@ namespace Example
{ {
public class {{operationId}}Example public class {{operationId}}Example
{ {
public void main() public static void Main()
{ {
{{#apiInfo}}{{#apis}}{{#-first}}{{#operations}}{{#operation}}{{#-first}} {{#apiInfo}}{{#apis}}{{#-first}}{{#operations}}{{#operation}}{{#-first}}
Configuration.Default.BasePath = "{{{basePath}}}";
{{#hasAuthMethods}} {{#hasAuthMethods}}
{{#authMethods}} {{#authMethods}}
{{#isBasic}} {{#isBasic}}
@ -135,7 +135,7 @@ namespace Example
{{/authMethods}} {{/authMethods}}
{{/hasAuthMethods}} {{/hasAuthMethods}}
var apiInstance = new {{classname}}(); var apiInstance = new {{classname}}(Configuration.Default);
{{#allParams}} {{#allParams}}
{{#isPrimitiveType}} {{#isPrimitiveType}}
var {{paramName}} = {{{example}}}; // {{{dataType}}} | {{{description}}}{{^required}} (optional) {{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}} var {{paramName}} = {{{example}}}; // {{{dataType}}} | {{{description}}}{{^required}} (optional) {{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}}
@ -153,9 +153,11 @@ namespace Example
{{#returnType}}{{{.}}} result = {{/returnType}}apiInstance.{{{operationId}}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});{{#returnType}} {{#returnType}}{{{.}}} result = {{/returnType}}apiInstance.{{{operationId}}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});{{#returnType}}
Debug.WriteLine(result);{{/returnType}} Debug.WriteLine(result);{{/returnType}}
} }
catch (Exception e) catch (ApiException e)
{ {
Debug.Print("Exception when calling {{classname}}.{{operationId}}: " + e.Message ); Debug.Print("Exception when calling {{classname}}.{{operationId}}: " + e.Message );
Debug.Print("Status Code: "+ e.ErrorCode);
Debug.Print(e.StackTrace);
} }
{{/-first}}{{/operation}}{{/operations}}{{/-first}}{{/apis}}{{/apiInfo}} {{/-first}}{{/operation}}{{/operations}}{{/-first}}{{/apis}}{{/apiInfo}}
} }

View File

@ -23,7 +23,6 @@ Method | HTTP request | Description
### Example ### Example
```csharp ```csharp
using System;
using System.Diagnostics; using System.Diagnostics;
using {{packageName}}.{{apiPackage}}; using {{packageName}}.{{apiPackage}};
using {{packageName}}.Client; using {{packageName}}.Client;
@ -33,8 +32,9 @@ namespace Example
{ {
public class {{operationId}}Example public class {{operationId}}Example
{ {
public void main() public static void Main()
{ {
Configuration.Default.BasePath = "{{{basePath}}}";
{{#hasAuthMethods}} {{#hasAuthMethods}}
{{#authMethods}} {{#authMethods}}
{{#isBasic}} {{#isBasic}}
@ -55,7 +55,7 @@ namespace Example
{{/authMethods}} {{/authMethods}}
{{/hasAuthMethods}} {{/hasAuthMethods}}
var apiInstance = new {{classname}}(); var apiInstance = new {{classname}}(Configuration.Default);
{{#allParams}} {{#allParams}}
{{#isPrimitiveType}} {{#isPrimitiveType}}
var {{paramName}} = {{{example}}}; // {{{dataType}}} | {{{description}}}{{^required}} (optional) {{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}} var {{paramName}} = {{{example}}}; // {{{dataType}}} | {{{description}}}{{^required}} (optional) {{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}}
@ -73,9 +73,11 @@ namespace Example
{{#returnType}}{{returnType}} result = {{/returnType}}apiInstance.{{{operationId}}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});{{#returnType}} {{#returnType}}{{returnType}} result = {{/returnType}}apiInstance.{{{operationId}}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});{{#returnType}}
Debug.WriteLine(result);{{/returnType}} Debug.WriteLine(result);{{/returnType}}
} }
catch (Exception e) catch (ApiException e)
{ {
Debug.Print("Exception when calling {{classname}}.{{operationId}}: " + e.Message ); Debug.Print("Exception when calling {{classname}}.{{operationId}}: " + e.Message );
Debug.Print("Status Code: "+ e.ErrorCode);
Debug.Print(e.StackTrace);
} }
} }
} }

View File

@ -64,7 +64,6 @@ Then, publish to a [local feed](https://docs.microsoft.com/en-us/nuget/hosting-p
## Getting Started ## Getting Started
```csharp ```csharp
using System;
using System.Diagnostics; using System.Diagnostics;
using Org.OpenAPITools.Api; using Org.OpenAPITools.Api;
using Org.OpenAPITools.Client; using Org.OpenAPITools.Client;
@ -74,10 +73,11 @@ namespace Example
{ {
public class Example public class Example
{ {
public void main() public static void Main()
{ {
var apiInstance = new AnotherFakeApi(); Configuration.Default.BasePath = "http://petstore.swagger.io:80/v2";
var apiInstance = new AnotherFakeApi(Configuration.Default);
var body = new ModelClient(); // ModelClient | client model var body = new ModelClient(); // ModelClient | client model
try try
@ -86,9 +86,11 @@ namespace Example
ModelClient result = apiInstance.Call123TestSpecialTags(body); ModelClient result = apiInstance.Call123TestSpecialTags(body);
Debug.WriteLine(result); Debug.WriteLine(result);
} }
catch (Exception e) catch (ApiException e)
{ {
Debug.Print("Exception when calling AnotherFakeApi.Call123TestSpecialTags: " + e.Message ); Debug.Print("Exception when calling AnotherFakeApi.Call123TestSpecialTags: " + e.Message );
Debug.Print("Status Code: "+ e.ErrorCode);
Debug.Print(e.StackTrace);
} }
} }

View File

@ -19,7 +19,6 @@ To test special tags and operation ID starting with number
### Example ### Example
```csharp ```csharp
using System;
using System.Diagnostics; using System.Diagnostics;
using Org.OpenAPITools.Api; using Org.OpenAPITools.Api;
using Org.OpenAPITools.Client; using Org.OpenAPITools.Client;
@ -29,9 +28,10 @@ namespace Example
{ {
public class Call123TestSpecialTagsExample public class Call123TestSpecialTagsExample
{ {
public void main() public static void Main()
{ {
var apiInstance = new AnotherFakeApi(); Configuration.Default.BasePath = "http://petstore.swagger.io:80/v2";
var apiInstance = new AnotherFakeApi(Configuration.Default);
var body = new ModelClient(); // ModelClient | client model var body = new ModelClient(); // ModelClient | client model
try try
@ -40,9 +40,11 @@ namespace Example
ModelClient result = apiInstance.Call123TestSpecialTags(body); ModelClient result = apiInstance.Call123TestSpecialTags(body);
Debug.WriteLine(result); Debug.WriteLine(result);
} }
catch (Exception e) catch (ApiException e)
{ {
Debug.Print("Exception when calling AnotherFakeApi.Call123TestSpecialTags: " + e.Message ); Debug.Print("Exception when calling AnotherFakeApi.Call123TestSpecialTags: " + e.Message );
Debug.Print("Status Code: "+ e.ErrorCode);
Debug.Print(e.StackTrace);
} }
} }
} }

View File

@ -31,7 +31,6 @@ this route creates an XmlItem
### Example ### Example
```csharp ```csharp
using System;
using System.Diagnostics; using System.Diagnostics;
using Org.OpenAPITools.Api; using Org.OpenAPITools.Api;
using Org.OpenAPITools.Client; using Org.OpenAPITools.Client;
@ -41,9 +40,10 @@ namespace Example
{ {
public class CreateXmlItemExample public class CreateXmlItemExample
{ {
public void main() public static void Main()
{ {
var apiInstance = new FakeApi(); Configuration.Default.BasePath = "http://petstore.swagger.io:80/v2";
var apiInstance = new FakeApi(Configuration.Default);
var xmlItem = new XmlItem(); // XmlItem | XmlItem Body var xmlItem = new XmlItem(); // XmlItem | XmlItem Body
try try
@ -51,9 +51,11 @@ namespace Example
// creates an XmlItem // creates an XmlItem
apiInstance.CreateXmlItem(xmlItem); apiInstance.CreateXmlItem(xmlItem);
} }
catch (Exception e) catch (ApiException e)
{ {
Debug.Print("Exception when calling FakeApi.CreateXmlItem: " + e.Message ); Debug.Print("Exception when calling FakeApi.CreateXmlItem: " + e.Message );
Debug.Print("Status Code: "+ e.ErrorCode);
Debug.Print(e.StackTrace);
} }
} }
} }
@ -97,7 +99,6 @@ Test serialization of outer boolean types
### Example ### Example
```csharp ```csharp
using System;
using System.Diagnostics; using System.Diagnostics;
using Org.OpenAPITools.Api; using Org.OpenAPITools.Api;
using Org.OpenAPITools.Client; using Org.OpenAPITools.Client;
@ -107,9 +108,10 @@ namespace Example
{ {
public class FakeOuterBooleanSerializeExample public class FakeOuterBooleanSerializeExample
{ {
public void main() public static void Main()
{ {
var apiInstance = new FakeApi(); Configuration.Default.BasePath = "http://petstore.swagger.io:80/v2";
var apiInstance = new FakeApi(Configuration.Default);
var body = true; // bool? | Input boolean as post body (optional) var body = true; // bool? | Input boolean as post body (optional)
try try
@ -117,9 +119,11 @@ namespace Example
bool? result = apiInstance.FakeOuterBooleanSerialize(body); bool? result = apiInstance.FakeOuterBooleanSerialize(body);
Debug.WriteLine(result); Debug.WriteLine(result);
} }
catch (Exception e) catch (ApiException e)
{ {
Debug.Print("Exception when calling FakeApi.FakeOuterBooleanSerialize: " + e.Message ); Debug.Print("Exception when calling FakeApi.FakeOuterBooleanSerialize: " + e.Message );
Debug.Print("Status Code: "+ e.ErrorCode);
Debug.Print(e.StackTrace);
} }
} }
} }
@ -163,7 +167,6 @@ Test serialization of object with outer number type
### Example ### Example
```csharp ```csharp
using System;
using System.Diagnostics; using System.Diagnostics;
using Org.OpenAPITools.Api; using Org.OpenAPITools.Api;
using Org.OpenAPITools.Client; using Org.OpenAPITools.Client;
@ -173,9 +176,10 @@ namespace Example
{ {
public class FakeOuterCompositeSerializeExample public class FakeOuterCompositeSerializeExample
{ {
public void main() public static void Main()
{ {
var apiInstance = new FakeApi(); Configuration.Default.BasePath = "http://petstore.swagger.io:80/v2";
var apiInstance = new FakeApi(Configuration.Default);
var body = new OuterComposite(); // OuterComposite | Input composite as post body (optional) var body = new OuterComposite(); // OuterComposite | Input composite as post body (optional)
try try
@ -183,9 +187,11 @@ namespace Example
OuterComposite result = apiInstance.FakeOuterCompositeSerialize(body); OuterComposite result = apiInstance.FakeOuterCompositeSerialize(body);
Debug.WriteLine(result); Debug.WriteLine(result);
} }
catch (Exception e) catch (ApiException e)
{ {
Debug.Print("Exception when calling FakeApi.FakeOuterCompositeSerialize: " + e.Message ); Debug.Print("Exception when calling FakeApi.FakeOuterCompositeSerialize: " + e.Message );
Debug.Print("Status Code: "+ e.ErrorCode);
Debug.Print(e.StackTrace);
} }
} }
} }
@ -229,7 +235,6 @@ Test serialization of outer number types
### Example ### Example
```csharp ```csharp
using System;
using System.Diagnostics; using System.Diagnostics;
using Org.OpenAPITools.Api; using Org.OpenAPITools.Api;
using Org.OpenAPITools.Client; using Org.OpenAPITools.Client;
@ -239,9 +244,10 @@ namespace Example
{ {
public class FakeOuterNumberSerializeExample public class FakeOuterNumberSerializeExample
{ {
public void main() public static void Main()
{ {
var apiInstance = new FakeApi(); Configuration.Default.BasePath = "http://petstore.swagger.io:80/v2";
var apiInstance = new FakeApi(Configuration.Default);
var body = 8.14; // decimal? | Input number as post body (optional) var body = 8.14; // decimal? | Input number as post body (optional)
try try
@ -249,9 +255,11 @@ namespace Example
decimal? result = apiInstance.FakeOuterNumberSerialize(body); decimal? result = apiInstance.FakeOuterNumberSerialize(body);
Debug.WriteLine(result); Debug.WriteLine(result);
} }
catch (Exception e) catch (ApiException e)
{ {
Debug.Print("Exception when calling FakeApi.FakeOuterNumberSerialize: " + e.Message ); Debug.Print("Exception when calling FakeApi.FakeOuterNumberSerialize: " + e.Message );
Debug.Print("Status Code: "+ e.ErrorCode);
Debug.Print(e.StackTrace);
} }
} }
} }
@ -295,7 +303,6 @@ Test serialization of outer string types
### Example ### Example
```csharp ```csharp
using System;
using System.Diagnostics; using System.Diagnostics;
using Org.OpenAPITools.Api; using Org.OpenAPITools.Api;
using Org.OpenAPITools.Client; using Org.OpenAPITools.Client;
@ -305,9 +312,10 @@ namespace Example
{ {
public class FakeOuterStringSerializeExample public class FakeOuterStringSerializeExample
{ {
public void main() public static void Main()
{ {
var apiInstance = new FakeApi(); Configuration.Default.BasePath = "http://petstore.swagger.io:80/v2";
var apiInstance = new FakeApi(Configuration.Default);
var body = body_example; // string | Input string as post body (optional) var body = body_example; // string | Input string as post body (optional)
try try
@ -315,9 +323,11 @@ namespace Example
string result = apiInstance.FakeOuterStringSerialize(body); string result = apiInstance.FakeOuterStringSerialize(body);
Debug.WriteLine(result); Debug.WriteLine(result);
} }
catch (Exception e) catch (ApiException e)
{ {
Debug.Print("Exception when calling FakeApi.FakeOuterStringSerialize: " + e.Message ); Debug.Print("Exception when calling FakeApi.FakeOuterStringSerialize: " + e.Message );
Debug.Print("Status Code: "+ e.ErrorCode);
Debug.Print(e.StackTrace);
} }
} }
} }
@ -361,7 +371,6 @@ For this test, the body for this request much reference a schema named `File`.
### Example ### Example
```csharp ```csharp
using System;
using System.Diagnostics; using System.Diagnostics;
using Org.OpenAPITools.Api; using Org.OpenAPITools.Api;
using Org.OpenAPITools.Client; using Org.OpenAPITools.Client;
@ -371,18 +380,21 @@ namespace Example
{ {
public class TestBodyWithFileSchemaExample public class TestBodyWithFileSchemaExample
{ {
public void main() public static void Main()
{ {
var apiInstance = new FakeApi(); Configuration.Default.BasePath = "http://petstore.swagger.io:80/v2";
var apiInstance = new FakeApi(Configuration.Default);
var body = new FileSchemaTestClass(); // FileSchemaTestClass | var body = new FileSchemaTestClass(); // FileSchemaTestClass |
try try
{ {
apiInstance.TestBodyWithFileSchema(body); apiInstance.TestBodyWithFileSchema(body);
} }
catch (Exception e) catch (ApiException e)
{ {
Debug.Print("Exception when calling FakeApi.TestBodyWithFileSchema: " + e.Message ); Debug.Print("Exception when calling FakeApi.TestBodyWithFileSchema: " + e.Message );
Debug.Print("Status Code: "+ e.ErrorCode);
Debug.Print(e.StackTrace);
} }
} }
} }
@ -424,7 +436,6 @@ No authorization required
### Example ### Example
```csharp ```csharp
using System;
using System.Diagnostics; using System.Diagnostics;
using Org.OpenAPITools.Api; using Org.OpenAPITools.Api;
using Org.OpenAPITools.Client; using Org.OpenAPITools.Client;
@ -434,9 +445,10 @@ namespace Example
{ {
public class TestBodyWithQueryParamsExample public class TestBodyWithQueryParamsExample
{ {
public void main() public static void Main()
{ {
var apiInstance = new FakeApi(); Configuration.Default.BasePath = "http://petstore.swagger.io:80/v2";
var apiInstance = new FakeApi(Configuration.Default);
var query = query_example; // string | var query = query_example; // string |
var body = new User(); // User | var body = new User(); // User |
@ -444,9 +456,11 @@ namespace Example
{ {
apiInstance.TestBodyWithQueryParams(query, body); apiInstance.TestBodyWithQueryParams(query, body);
} }
catch (Exception e) catch (ApiException e)
{ {
Debug.Print("Exception when calling FakeApi.TestBodyWithQueryParams: " + e.Message ); Debug.Print("Exception when calling FakeApi.TestBodyWithQueryParams: " + e.Message );
Debug.Print("Status Code: "+ e.ErrorCode);
Debug.Print(e.StackTrace);
} }
} }
} }
@ -491,7 +505,6 @@ To test \"client\" model
### Example ### Example
```csharp ```csharp
using System;
using System.Diagnostics; using System.Diagnostics;
using Org.OpenAPITools.Api; using Org.OpenAPITools.Api;
using Org.OpenAPITools.Client; using Org.OpenAPITools.Client;
@ -501,9 +514,10 @@ namespace Example
{ {
public class TestClientModelExample public class TestClientModelExample
{ {
public void main() public static void Main()
{ {
var apiInstance = new FakeApi(); Configuration.Default.BasePath = "http://petstore.swagger.io:80/v2";
var apiInstance = new FakeApi(Configuration.Default);
var body = new ModelClient(); // ModelClient | client model var body = new ModelClient(); // ModelClient | client model
try try
@ -512,9 +526,11 @@ namespace Example
ModelClient result = apiInstance.TestClientModel(body); ModelClient result = apiInstance.TestClientModel(body);
Debug.WriteLine(result); Debug.WriteLine(result);
} }
catch (Exception e) catch (ApiException e)
{ {
Debug.Print("Exception when calling FakeApi.TestClientModel: " + e.Message ); Debug.Print("Exception when calling FakeApi.TestClientModel: " + e.Message );
Debug.Print("Status Code: "+ e.ErrorCode);
Debug.Print(e.StackTrace);
} }
} }
} }
@ -558,7 +574,6 @@ Fake endpoint for testing various parameters 假端點 偽のエンドポイン
### Example ### Example
```csharp ```csharp
using System;
using System.Diagnostics; using System.Diagnostics;
using Org.OpenAPITools.Api; using Org.OpenAPITools.Api;
using Org.OpenAPITools.Client; using Org.OpenAPITools.Client;
@ -568,13 +583,14 @@ namespace Example
{ {
public class TestEndpointParametersExample public class TestEndpointParametersExample
{ {
public void main() public static void Main()
{ {
Configuration.Default.BasePath = "http://petstore.swagger.io:80/v2";
// Configure HTTP basic authorization: http_basic_test // Configure HTTP basic authorization: http_basic_test
Configuration.Default.Username = "YOUR_USERNAME"; Configuration.Default.Username = "YOUR_USERNAME";
Configuration.Default.Password = "YOUR_PASSWORD"; Configuration.Default.Password = "YOUR_PASSWORD";
var apiInstance = new FakeApi(); var apiInstance = new FakeApi(Configuration.Default);
var number = 8.14; // decimal? | None var number = 8.14; // decimal? | None
var _double = 1.2D; // double? | None var _double = 1.2D; // double? | None
var patternWithoutDelimiter = patternWithoutDelimiter_example; // string | None var patternWithoutDelimiter = patternWithoutDelimiter_example; // string | None
@ -595,9 +611,11 @@ namespace Example
// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 // Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
apiInstance.TestEndpointParameters(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, _string, binary, date, dateTime, password, callback); apiInstance.TestEndpointParameters(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, _string, binary, date, dateTime, password, callback);
} }
catch (Exception e) catch (ApiException e)
{ {
Debug.Print("Exception when calling FakeApi.TestEndpointParameters: " + e.Message ); Debug.Print("Exception when calling FakeApi.TestEndpointParameters: " + e.Message );
Debug.Print("Status Code: "+ e.ErrorCode);
Debug.Print(e.StackTrace);
} }
} }
} }
@ -654,7 +672,6 @@ To test enum parameters
### Example ### Example
```csharp ```csharp
using System;
using System.Diagnostics; using System.Diagnostics;
using Org.OpenAPITools.Api; using Org.OpenAPITools.Api;
using Org.OpenAPITools.Client; using Org.OpenAPITools.Client;
@ -664,9 +681,10 @@ namespace Example
{ {
public class TestEnumParametersExample public class TestEnumParametersExample
{ {
public void main() public static void Main()
{ {
var apiInstance = new FakeApi(); Configuration.Default.BasePath = "http://petstore.swagger.io:80/v2";
var apiInstance = new FakeApi(Configuration.Default);
var enumHeaderStringArray = enumHeaderStringArray_example; // List<string> | Header parameter enum test (string array) (optional) var enumHeaderStringArray = enumHeaderStringArray_example; // List<string> | Header parameter enum test (string array) (optional)
var enumHeaderString = enumHeaderString_example; // string | Header parameter enum test (string) (optional) (default to -efg) var enumHeaderString = enumHeaderString_example; // string | Header parameter enum test (string) (optional) (default to -efg)
var enumQueryStringArray = enumQueryStringArray_example; // List<string> | Query parameter enum test (string array) (optional) var enumQueryStringArray = enumQueryStringArray_example; // List<string> | Query parameter enum test (string array) (optional)
@ -681,9 +699,11 @@ namespace Example
// To test enum parameters // To test enum parameters
apiInstance.TestEnumParameters(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString); apiInstance.TestEnumParameters(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString);
} }
catch (Exception e) catch (ApiException e)
{ {
Debug.Print("Exception when calling FakeApi.TestEnumParameters: " + e.Message ); Debug.Print("Exception when calling FakeApi.TestEnumParameters: " + e.Message );
Debug.Print("Status Code: "+ e.ErrorCode);
Debug.Print(e.StackTrace);
} }
} }
} }
@ -734,7 +754,6 @@ Fake endpoint to test group parameters (optional)
### Example ### Example
```csharp ```csharp
using System;
using System.Diagnostics; using System.Diagnostics;
using Org.OpenAPITools.Api; using Org.OpenAPITools.Api;
using Org.OpenAPITools.Client; using Org.OpenAPITools.Client;
@ -744,9 +763,10 @@ namespace Example
{ {
public class TestGroupParametersExample public class TestGroupParametersExample
{ {
public void main() public static void Main()
{ {
var apiInstance = new FakeApi(); Configuration.Default.BasePath = "http://petstore.swagger.io:80/v2";
var apiInstance = new FakeApi(Configuration.Default);
var requiredStringGroup = 56; // int? | Required String in group parameters var requiredStringGroup = 56; // int? | Required String in group parameters
var requiredBooleanGroup = true; // bool? | Required Boolean in group parameters var requiredBooleanGroup = true; // bool? | Required Boolean in group parameters
var requiredInt64Group = 789; // long? | Required Integer in group parameters var requiredInt64Group = 789; // long? | Required Integer in group parameters
@ -759,9 +779,11 @@ namespace Example
// Fake endpoint to test group parameters (optional) // Fake endpoint to test group parameters (optional)
apiInstance.TestGroupParameters(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, stringGroup, booleanGroup, int64Group); apiInstance.TestGroupParameters(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, stringGroup, booleanGroup, int64Group);
} }
catch (Exception e) catch (ApiException e)
{ {
Debug.Print("Exception when calling FakeApi.TestGroupParameters: " + e.Message ); Debug.Print("Exception when calling FakeApi.TestGroupParameters: " + e.Message );
Debug.Print("Status Code: "+ e.ErrorCode);
Debug.Print(e.StackTrace);
} }
} }
} }
@ -808,7 +830,6 @@ test inline additionalProperties
### Example ### Example
```csharp ```csharp
using System;
using System.Diagnostics; using System.Diagnostics;
using Org.OpenAPITools.Api; using Org.OpenAPITools.Api;
using Org.OpenAPITools.Client; using Org.OpenAPITools.Client;
@ -818,9 +839,10 @@ namespace Example
{ {
public class TestInlineAdditionalPropertiesExample public class TestInlineAdditionalPropertiesExample
{ {
public void main() public static void Main()
{ {
var apiInstance = new FakeApi(); Configuration.Default.BasePath = "http://petstore.swagger.io:80/v2";
var apiInstance = new FakeApi(Configuration.Default);
var param = new Dictionary<string, string>(); // Dictionary<string, string> | request body var param = new Dictionary<string, string>(); // Dictionary<string, string> | request body
try try
@ -828,9 +850,11 @@ namespace Example
// test inline additionalProperties // test inline additionalProperties
apiInstance.TestInlineAdditionalProperties(param); apiInstance.TestInlineAdditionalProperties(param);
} }
catch (Exception e) catch (ApiException e)
{ {
Debug.Print("Exception when calling FakeApi.TestInlineAdditionalProperties: " + e.Message ); Debug.Print("Exception when calling FakeApi.TestInlineAdditionalProperties: " + e.Message );
Debug.Print("Status Code: "+ e.ErrorCode);
Debug.Print(e.StackTrace);
} }
} }
} }
@ -872,7 +896,6 @@ test json serialization of form data
### Example ### Example
```csharp ```csharp
using System;
using System.Diagnostics; using System.Diagnostics;
using Org.OpenAPITools.Api; using Org.OpenAPITools.Api;
using Org.OpenAPITools.Client; using Org.OpenAPITools.Client;
@ -882,9 +905,10 @@ namespace Example
{ {
public class TestJsonFormDataExample public class TestJsonFormDataExample
{ {
public void main() public static void Main()
{ {
var apiInstance = new FakeApi(); Configuration.Default.BasePath = "http://petstore.swagger.io:80/v2";
var apiInstance = new FakeApi(Configuration.Default);
var param = param_example; // string | field1 var param = param_example; // string | field1
var param2 = param2_example; // string | field2 var param2 = param2_example; // string | field2
@ -893,9 +917,11 @@ namespace Example
// test json serialization of form data // test json serialization of form data
apiInstance.TestJsonFormData(param, param2); apiInstance.TestJsonFormData(param, param2);
} }
catch (Exception e) catch (ApiException e)
{ {
Debug.Print("Exception when calling FakeApi.TestJsonFormData: " + e.Message ); Debug.Print("Exception when calling FakeApi.TestJsonFormData: " + e.Message );
Debug.Print("Status Code: "+ e.ErrorCode);
Debug.Print(e.StackTrace);
} }
} }
} }

View File

@ -19,7 +19,6 @@ To test class name in snake case
### Example ### Example
```csharp ```csharp
using System;
using System.Diagnostics; using System.Diagnostics;
using Org.OpenAPITools.Api; using Org.OpenAPITools.Api;
using Org.OpenAPITools.Client; using Org.OpenAPITools.Client;
@ -29,14 +28,15 @@ namespace Example
{ {
public class TestClassnameExample public class TestClassnameExample
{ {
public void main() public static void Main()
{ {
Configuration.Default.BasePath = "http://petstore.swagger.io:80/v2";
// Configure API key authorization: api_key_query // Configure API key authorization: api_key_query
Configuration.Default.AddApiKey("api_key_query", "YOUR_API_KEY"); Configuration.Default.AddApiKey("api_key_query", "YOUR_API_KEY");
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// Configuration.Default.AddApiKeyPrefix("api_key_query", "Bearer"); // Configuration.Default.AddApiKeyPrefix("api_key_query", "Bearer");
var apiInstance = new FakeClassnameTags123Api(); var apiInstance = new FakeClassnameTags123Api(Configuration.Default);
var body = new ModelClient(); // ModelClient | client model var body = new ModelClient(); // ModelClient | client model
try try
@ -45,9 +45,11 @@ namespace Example
ModelClient result = apiInstance.TestClassname(body); ModelClient result = apiInstance.TestClassname(body);
Debug.WriteLine(result); Debug.WriteLine(result);
} }
catch (Exception e) catch (ApiException e)
{ {
Debug.Print("Exception when calling FakeClassnameTags123Api.TestClassname: " + e.Message ); Debug.Print("Exception when calling FakeClassnameTags123Api.TestClassname: " + e.Message );
Debug.Print("Status Code: "+ e.ErrorCode);
Debug.Print(e.StackTrace);
} }
} }
} }

View File

@ -25,7 +25,6 @@ Add a new pet to the store
### Example ### Example
```csharp ```csharp
using System;
using System.Diagnostics; using System.Diagnostics;
using Org.OpenAPITools.Api; using Org.OpenAPITools.Api;
using Org.OpenAPITools.Client; using Org.OpenAPITools.Client;
@ -35,12 +34,13 @@ namespace Example
{ {
public class AddPetExample public class AddPetExample
{ {
public void main() public static void Main()
{ {
Configuration.Default.BasePath = "http://petstore.swagger.io:80/v2";
// Configure OAuth2 access token for authorization: petstore_auth // Configure OAuth2 access token for authorization: petstore_auth
Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN"; Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN";
var apiInstance = new PetApi(); var apiInstance = new PetApi(Configuration.Default);
var body = new Pet(); // Pet | Pet object that needs to be added to the store var body = new Pet(); // Pet | Pet object that needs to be added to the store
try try
@ -48,9 +48,11 @@ namespace Example
// Add a new pet to the store // Add a new pet to the store
apiInstance.AddPet(body); apiInstance.AddPet(body);
} }
catch (Exception e) catch (ApiException e)
{ {
Debug.Print("Exception when calling PetApi.AddPet: " + e.Message ); Debug.Print("Exception when calling PetApi.AddPet: " + e.Message );
Debug.Print("Status Code: "+ e.ErrorCode);
Debug.Print(e.StackTrace);
} }
} }
} }
@ -92,7 +94,6 @@ Deletes a pet
### Example ### Example
```csharp ```csharp
using System;
using System.Diagnostics; using System.Diagnostics;
using Org.OpenAPITools.Api; using Org.OpenAPITools.Api;
using Org.OpenAPITools.Client; using Org.OpenAPITools.Client;
@ -102,12 +103,13 @@ namespace Example
{ {
public class DeletePetExample public class DeletePetExample
{ {
public void main() public static void Main()
{ {
Configuration.Default.BasePath = "http://petstore.swagger.io:80/v2";
// Configure OAuth2 access token for authorization: petstore_auth // Configure OAuth2 access token for authorization: petstore_auth
Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN"; Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN";
var apiInstance = new PetApi(); var apiInstance = new PetApi(Configuration.Default);
var petId = 789; // long? | Pet id to delete var petId = 789; // long? | Pet id to delete
var apiKey = apiKey_example; // string | (optional) var apiKey = apiKey_example; // string | (optional)
@ -116,9 +118,11 @@ namespace Example
// Deletes a pet // Deletes a pet
apiInstance.DeletePet(petId, apiKey); apiInstance.DeletePet(petId, apiKey);
} }
catch (Exception e) catch (ApiException e)
{ {
Debug.Print("Exception when calling PetApi.DeletePet: " + e.Message ); Debug.Print("Exception when calling PetApi.DeletePet: " + e.Message );
Debug.Print("Status Code: "+ e.ErrorCode);
Debug.Print(e.StackTrace);
} }
} }
} }
@ -163,7 +167,6 @@ Multiple status values can be provided with comma separated strings
### Example ### Example
```csharp ```csharp
using System;
using System.Diagnostics; using System.Diagnostics;
using Org.OpenAPITools.Api; using Org.OpenAPITools.Api;
using Org.OpenAPITools.Client; using Org.OpenAPITools.Client;
@ -173,12 +176,13 @@ namespace Example
{ {
public class FindPetsByStatusExample public class FindPetsByStatusExample
{ {
public void main() public static void Main()
{ {
Configuration.Default.BasePath = "http://petstore.swagger.io:80/v2";
// Configure OAuth2 access token for authorization: petstore_auth // Configure OAuth2 access token for authorization: petstore_auth
Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN"; Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN";
var apiInstance = new PetApi(); var apiInstance = new PetApi(Configuration.Default);
var status = status_example; // List<string> | Status values that need to be considered for filter var status = status_example; // List<string> | Status values that need to be considered for filter
try try
@ -187,9 +191,11 @@ namespace Example
List&lt;Pet&gt; result = apiInstance.FindPetsByStatus(status); List&lt;Pet&gt; result = apiInstance.FindPetsByStatus(status);
Debug.WriteLine(result); Debug.WriteLine(result);
} }
catch (Exception e) catch (ApiException e)
{ {
Debug.Print("Exception when calling PetApi.FindPetsByStatus: " + e.Message ); Debug.Print("Exception when calling PetApi.FindPetsByStatus: " + e.Message );
Debug.Print("Status Code: "+ e.ErrorCode);
Debug.Print(e.StackTrace);
} }
} }
} }
@ -233,7 +239,6 @@ Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3
### Example ### Example
```csharp ```csharp
using System;
using System.Diagnostics; using System.Diagnostics;
using Org.OpenAPITools.Api; using Org.OpenAPITools.Api;
using Org.OpenAPITools.Client; using Org.OpenAPITools.Client;
@ -243,12 +248,13 @@ namespace Example
{ {
public class FindPetsByTagsExample public class FindPetsByTagsExample
{ {
public void main() public static void Main()
{ {
Configuration.Default.BasePath = "http://petstore.swagger.io:80/v2";
// Configure OAuth2 access token for authorization: petstore_auth // Configure OAuth2 access token for authorization: petstore_auth
Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN"; Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN";
var apiInstance = new PetApi(); var apiInstance = new PetApi(Configuration.Default);
var tags = new List<string>(); // List<string> | Tags to filter by var tags = new List<string>(); // List<string> | Tags to filter by
try try
@ -257,9 +263,11 @@ namespace Example
List&lt;Pet&gt; result = apiInstance.FindPetsByTags(tags); List&lt;Pet&gt; result = apiInstance.FindPetsByTags(tags);
Debug.WriteLine(result); Debug.WriteLine(result);
} }
catch (Exception e) catch (ApiException e)
{ {
Debug.Print("Exception when calling PetApi.FindPetsByTags: " + e.Message ); Debug.Print("Exception when calling PetApi.FindPetsByTags: " + e.Message );
Debug.Print("Status Code: "+ e.ErrorCode);
Debug.Print(e.StackTrace);
} }
} }
} }
@ -303,7 +311,6 @@ Returns a single pet
### Example ### Example
```csharp ```csharp
using System;
using System.Diagnostics; using System.Diagnostics;
using Org.OpenAPITools.Api; using Org.OpenAPITools.Api;
using Org.OpenAPITools.Client; using Org.OpenAPITools.Client;
@ -313,14 +320,15 @@ namespace Example
{ {
public class GetPetByIdExample public class GetPetByIdExample
{ {
public void main() public static void Main()
{ {
Configuration.Default.BasePath = "http://petstore.swagger.io:80/v2";
// Configure API key authorization: api_key // Configure API key authorization: api_key
Configuration.Default.AddApiKey("api_key", "YOUR_API_KEY"); Configuration.Default.AddApiKey("api_key", "YOUR_API_KEY");
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// Configuration.Default.AddApiKeyPrefix("api_key", "Bearer"); // Configuration.Default.AddApiKeyPrefix("api_key", "Bearer");
var apiInstance = new PetApi(); var apiInstance = new PetApi(Configuration.Default);
var petId = 789; // long? | ID of pet to return var petId = 789; // long? | ID of pet to return
try try
@ -329,9 +337,11 @@ namespace Example
Pet result = apiInstance.GetPetById(petId); Pet result = apiInstance.GetPetById(petId);
Debug.WriteLine(result); Debug.WriteLine(result);
} }
catch (Exception e) catch (ApiException e)
{ {
Debug.Print("Exception when calling PetApi.GetPetById: " + e.Message ); Debug.Print("Exception when calling PetApi.GetPetById: " + e.Message );
Debug.Print("Status Code: "+ e.ErrorCode);
Debug.Print(e.StackTrace);
} }
} }
} }
@ -373,7 +383,6 @@ Update an existing pet
### Example ### Example
```csharp ```csharp
using System;
using System.Diagnostics; using System.Diagnostics;
using Org.OpenAPITools.Api; using Org.OpenAPITools.Api;
using Org.OpenAPITools.Client; using Org.OpenAPITools.Client;
@ -383,12 +392,13 @@ namespace Example
{ {
public class UpdatePetExample public class UpdatePetExample
{ {
public void main() public static void Main()
{ {
Configuration.Default.BasePath = "http://petstore.swagger.io:80/v2";
// Configure OAuth2 access token for authorization: petstore_auth // Configure OAuth2 access token for authorization: petstore_auth
Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN"; Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN";
var apiInstance = new PetApi(); var apiInstance = new PetApi(Configuration.Default);
var body = new Pet(); // Pet | Pet object that needs to be added to the store var body = new Pet(); // Pet | Pet object that needs to be added to the store
try try
@ -396,9 +406,11 @@ namespace Example
// Update an existing pet // Update an existing pet
apiInstance.UpdatePet(body); apiInstance.UpdatePet(body);
} }
catch (Exception e) catch (ApiException e)
{ {
Debug.Print("Exception when calling PetApi.UpdatePet: " + e.Message ); Debug.Print("Exception when calling PetApi.UpdatePet: " + e.Message );
Debug.Print("Status Code: "+ e.ErrorCode);
Debug.Print(e.StackTrace);
} }
} }
} }
@ -440,7 +452,6 @@ Updates a pet in the store with form data
### Example ### Example
```csharp ```csharp
using System;
using System.Diagnostics; using System.Diagnostics;
using Org.OpenAPITools.Api; using Org.OpenAPITools.Api;
using Org.OpenAPITools.Client; using Org.OpenAPITools.Client;
@ -450,12 +461,13 @@ namespace Example
{ {
public class UpdatePetWithFormExample public class UpdatePetWithFormExample
{ {
public void main() public static void Main()
{ {
Configuration.Default.BasePath = "http://petstore.swagger.io:80/v2";
// Configure OAuth2 access token for authorization: petstore_auth // Configure OAuth2 access token for authorization: petstore_auth
Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN"; Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN";
var apiInstance = new PetApi(); var apiInstance = new PetApi(Configuration.Default);
var petId = 789; // long? | ID of pet that needs to be updated var petId = 789; // long? | ID of pet that needs to be updated
var name = name_example; // string | Updated name of the pet (optional) var name = name_example; // string | Updated name of the pet (optional)
var status = status_example; // string | Updated status of the pet (optional) var status = status_example; // string | Updated status of the pet (optional)
@ -465,9 +477,11 @@ namespace Example
// Updates a pet in the store with form data // Updates a pet in the store with form data
apiInstance.UpdatePetWithForm(petId, name, status); apiInstance.UpdatePetWithForm(petId, name, status);
} }
catch (Exception e) catch (ApiException e)
{ {
Debug.Print("Exception when calling PetApi.UpdatePetWithForm: " + e.Message ); Debug.Print("Exception when calling PetApi.UpdatePetWithForm: " + e.Message );
Debug.Print("Status Code: "+ e.ErrorCode);
Debug.Print(e.StackTrace);
} }
} }
} }
@ -511,7 +525,6 @@ uploads an image
### Example ### Example
```csharp ```csharp
using System;
using System.Diagnostics; using System.Diagnostics;
using Org.OpenAPITools.Api; using Org.OpenAPITools.Api;
using Org.OpenAPITools.Client; using Org.OpenAPITools.Client;
@ -521,12 +534,13 @@ namespace Example
{ {
public class UploadFileExample public class UploadFileExample
{ {
public void main() public static void Main()
{ {
Configuration.Default.BasePath = "http://petstore.swagger.io:80/v2";
// Configure OAuth2 access token for authorization: petstore_auth // Configure OAuth2 access token for authorization: petstore_auth
Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN"; Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN";
var apiInstance = new PetApi(); var apiInstance = new PetApi(Configuration.Default);
var petId = 789; // long? | ID of pet to update var petId = 789; // long? | ID of pet to update
var additionalMetadata = additionalMetadata_example; // string | Additional data to pass to server (optional) var additionalMetadata = additionalMetadata_example; // string | Additional data to pass to server (optional)
var file = BINARY_DATA_HERE; // System.IO.Stream | file to upload (optional) var file = BINARY_DATA_HERE; // System.IO.Stream | file to upload (optional)
@ -537,9 +551,11 @@ namespace Example
ApiResponse result = apiInstance.UploadFile(petId, additionalMetadata, file); ApiResponse result = apiInstance.UploadFile(petId, additionalMetadata, file);
Debug.WriteLine(result); Debug.WriteLine(result);
} }
catch (Exception e) catch (ApiException e)
{ {
Debug.Print("Exception when calling PetApi.UploadFile: " + e.Message ); Debug.Print("Exception when calling PetApi.UploadFile: " + e.Message );
Debug.Print("Status Code: "+ e.ErrorCode);
Debug.Print(e.StackTrace);
} }
} }
} }
@ -583,7 +599,6 @@ uploads an image (required)
### Example ### Example
```csharp ```csharp
using System;
using System.Diagnostics; using System.Diagnostics;
using Org.OpenAPITools.Api; using Org.OpenAPITools.Api;
using Org.OpenAPITools.Client; using Org.OpenAPITools.Client;
@ -593,12 +608,13 @@ namespace Example
{ {
public class UploadFileWithRequiredFileExample public class UploadFileWithRequiredFileExample
{ {
public void main() public static void Main()
{ {
Configuration.Default.BasePath = "http://petstore.swagger.io:80/v2";
// Configure OAuth2 access token for authorization: petstore_auth // Configure OAuth2 access token for authorization: petstore_auth
Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN"; Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN";
var apiInstance = new PetApi(); var apiInstance = new PetApi(Configuration.Default);
var petId = 789; // long? | ID of pet to update var petId = 789; // long? | ID of pet to update
var requiredFile = BINARY_DATA_HERE; // System.IO.Stream | file to upload var requiredFile = BINARY_DATA_HERE; // System.IO.Stream | file to upload
var additionalMetadata = additionalMetadata_example; // string | Additional data to pass to server (optional) var additionalMetadata = additionalMetadata_example; // string | Additional data to pass to server (optional)
@ -609,9 +625,11 @@ namespace Example
ApiResponse result = apiInstance.UploadFileWithRequiredFile(petId, requiredFile, additionalMetadata); ApiResponse result = apiInstance.UploadFileWithRequiredFile(petId, requiredFile, additionalMetadata);
Debug.WriteLine(result); Debug.WriteLine(result);
} }
catch (Exception e) catch (ApiException e)
{ {
Debug.Print("Exception when calling PetApi.UploadFileWithRequiredFile: " + e.Message ); Debug.Print("Exception when calling PetApi.UploadFileWithRequiredFile: " + e.Message );
Debug.Print("Status Code: "+ e.ErrorCode);
Debug.Print(e.StackTrace);
} }
} }
} }

View File

@ -22,7 +22,6 @@ For valid response try integer IDs with value < 1000. Anything above 1000 or non
### Example ### Example
```csharp ```csharp
using System;
using System.Diagnostics; using System.Diagnostics;
using Org.OpenAPITools.Api; using Org.OpenAPITools.Api;
using Org.OpenAPITools.Client; using Org.OpenAPITools.Client;
@ -32,9 +31,10 @@ namespace Example
{ {
public class DeleteOrderExample public class DeleteOrderExample
{ {
public void main() public static void Main()
{ {
var apiInstance = new StoreApi(); Configuration.Default.BasePath = "http://petstore.swagger.io:80/v2";
var apiInstance = new StoreApi(Configuration.Default);
var orderId = orderId_example; // string | ID of the order that needs to be deleted var orderId = orderId_example; // string | ID of the order that needs to be deleted
try try
@ -42,9 +42,11 @@ namespace Example
// Delete purchase order by ID // Delete purchase order by ID
apiInstance.DeleteOrder(orderId); apiInstance.DeleteOrder(orderId);
} }
catch (Exception e) catch (ApiException e)
{ {
Debug.Print("Exception when calling StoreApi.DeleteOrder: " + e.Message ); Debug.Print("Exception when calling StoreApi.DeleteOrder: " + e.Message );
Debug.Print("Status Code: "+ e.ErrorCode);
Debug.Print(e.StackTrace);
} }
} }
} }
@ -88,7 +90,6 @@ Returns a map of status codes to quantities
### Example ### Example
```csharp ```csharp
using System;
using System.Diagnostics; using System.Diagnostics;
using Org.OpenAPITools.Api; using Org.OpenAPITools.Api;
using Org.OpenAPITools.Client; using Org.OpenAPITools.Client;
@ -98,14 +99,15 @@ namespace Example
{ {
public class GetInventoryExample public class GetInventoryExample
{ {
public void main() public static void Main()
{ {
Configuration.Default.BasePath = "http://petstore.swagger.io:80/v2";
// Configure API key authorization: api_key // Configure API key authorization: api_key
Configuration.Default.AddApiKey("api_key", "YOUR_API_KEY"); Configuration.Default.AddApiKey("api_key", "YOUR_API_KEY");
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// Configuration.Default.AddApiKeyPrefix("api_key", "Bearer"); // Configuration.Default.AddApiKeyPrefix("api_key", "Bearer");
var apiInstance = new StoreApi(); var apiInstance = new StoreApi(Configuration.Default);
try try
{ {
@ -113,9 +115,11 @@ namespace Example
Dictionary&lt;string, int?&gt; result = apiInstance.GetInventory(); Dictionary&lt;string, int?&gt; result = apiInstance.GetInventory();
Debug.WriteLine(result); Debug.WriteLine(result);
} }
catch (Exception e) catch (ApiException e)
{ {
Debug.Print("Exception when calling StoreApi.GetInventory: " + e.Message ); Debug.Print("Exception when calling StoreApi.GetInventory: " + e.Message );
Debug.Print("Status Code: "+ e.ErrorCode);
Debug.Print(e.StackTrace);
} }
} }
} }
@ -156,7 +160,6 @@ For valid response try integer IDs with value <= 5 or > 10. Other values will ge
### Example ### Example
```csharp ```csharp
using System;
using System.Diagnostics; using System.Diagnostics;
using Org.OpenAPITools.Api; using Org.OpenAPITools.Api;
using Org.OpenAPITools.Client; using Org.OpenAPITools.Client;
@ -166,9 +169,10 @@ namespace Example
{ {
public class GetOrderByIdExample public class GetOrderByIdExample
{ {
public void main() public static void Main()
{ {
var apiInstance = new StoreApi(); Configuration.Default.BasePath = "http://petstore.swagger.io:80/v2";
var apiInstance = new StoreApi(Configuration.Default);
var orderId = 789; // long? | ID of pet that needs to be fetched var orderId = 789; // long? | ID of pet that needs to be fetched
try try
@ -177,9 +181,11 @@ namespace Example
Order result = apiInstance.GetOrderById(orderId); Order result = apiInstance.GetOrderById(orderId);
Debug.WriteLine(result); Debug.WriteLine(result);
} }
catch (Exception e) catch (ApiException e)
{ {
Debug.Print("Exception when calling StoreApi.GetOrderById: " + e.Message ); Debug.Print("Exception when calling StoreApi.GetOrderById: " + e.Message );
Debug.Print("Status Code: "+ e.ErrorCode);
Debug.Print(e.StackTrace);
} }
} }
} }
@ -221,7 +227,6 @@ Place an order for a pet
### Example ### Example
```csharp ```csharp
using System;
using System.Diagnostics; using System.Diagnostics;
using Org.OpenAPITools.Api; using Org.OpenAPITools.Api;
using Org.OpenAPITools.Client; using Org.OpenAPITools.Client;
@ -231,9 +236,10 @@ namespace Example
{ {
public class PlaceOrderExample public class PlaceOrderExample
{ {
public void main() public static void Main()
{ {
var apiInstance = new StoreApi(); Configuration.Default.BasePath = "http://petstore.swagger.io:80/v2";
var apiInstance = new StoreApi(Configuration.Default);
var body = new Order(); // Order | order placed for purchasing the pet var body = new Order(); // Order | order placed for purchasing the pet
try try
@ -242,9 +248,11 @@ namespace Example
Order result = apiInstance.PlaceOrder(body); Order result = apiInstance.PlaceOrder(body);
Debug.WriteLine(result); Debug.WriteLine(result);
} }
catch (Exception e) catch (ApiException e)
{ {
Debug.Print("Exception when calling StoreApi.PlaceOrder: " + e.Message ); Debug.Print("Exception when calling StoreApi.PlaceOrder: " + e.Message );
Debug.Print("Status Code: "+ e.ErrorCode);
Debug.Print(e.StackTrace);
} }
} }
} }

View File

@ -26,7 +26,6 @@ This can only be done by the logged in user.
### Example ### Example
```csharp ```csharp
using System;
using System.Diagnostics; using System.Diagnostics;
using Org.OpenAPITools.Api; using Org.OpenAPITools.Api;
using Org.OpenAPITools.Client; using Org.OpenAPITools.Client;
@ -36,9 +35,10 @@ namespace Example
{ {
public class CreateUserExample public class CreateUserExample
{ {
public void main() public static void Main()
{ {
var apiInstance = new UserApi(); Configuration.Default.BasePath = "http://petstore.swagger.io:80/v2";
var apiInstance = new UserApi(Configuration.Default);
var body = new User(); // User | Created user object var body = new User(); // User | Created user object
try try
@ -46,9 +46,11 @@ namespace Example
// Create user // Create user
apiInstance.CreateUser(body); apiInstance.CreateUser(body);
} }
catch (Exception e) catch (ApiException e)
{ {
Debug.Print("Exception when calling UserApi.CreateUser: " + e.Message ); Debug.Print("Exception when calling UserApi.CreateUser: " + e.Message );
Debug.Print("Status Code: "+ e.ErrorCode);
Debug.Print(e.StackTrace);
} }
} }
} }
@ -90,7 +92,6 @@ Creates list of users with given input array
### Example ### Example
```csharp ```csharp
using System;
using System.Diagnostics; using System.Diagnostics;
using Org.OpenAPITools.Api; using Org.OpenAPITools.Api;
using Org.OpenAPITools.Client; using Org.OpenAPITools.Client;
@ -100,9 +101,10 @@ namespace Example
{ {
public class CreateUsersWithArrayInputExample public class CreateUsersWithArrayInputExample
{ {
public void main() public static void Main()
{ {
var apiInstance = new UserApi(); Configuration.Default.BasePath = "http://petstore.swagger.io:80/v2";
var apiInstance = new UserApi(Configuration.Default);
var body = new List<User>(); // List<User> | List of user object var body = new List<User>(); // List<User> | List of user object
try try
@ -110,9 +112,11 @@ namespace Example
// Creates list of users with given input array // Creates list of users with given input array
apiInstance.CreateUsersWithArrayInput(body); apiInstance.CreateUsersWithArrayInput(body);
} }
catch (Exception e) catch (ApiException e)
{ {
Debug.Print("Exception when calling UserApi.CreateUsersWithArrayInput: " + e.Message ); Debug.Print("Exception when calling UserApi.CreateUsersWithArrayInput: " + e.Message );
Debug.Print("Status Code: "+ e.ErrorCode);
Debug.Print(e.StackTrace);
} }
} }
} }
@ -154,7 +158,6 @@ Creates list of users with given input array
### Example ### Example
```csharp ```csharp
using System;
using System.Diagnostics; using System.Diagnostics;
using Org.OpenAPITools.Api; using Org.OpenAPITools.Api;
using Org.OpenAPITools.Client; using Org.OpenAPITools.Client;
@ -164,9 +167,10 @@ namespace Example
{ {
public class CreateUsersWithListInputExample public class CreateUsersWithListInputExample
{ {
public void main() public static void Main()
{ {
var apiInstance = new UserApi(); Configuration.Default.BasePath = "http://petstore.swagger.io:80/v2";
var apiInstance = new UserApi(Configuration.Default);
var body = new List<User>(); // List<User> | List of user object var body = new List<User>(); // List<User> | List of user object
try try
@ -174,9 +178,11 @@ namespace Example
// Creates list of users with given input array // Creates list of users with given input array
apiInstance.CreateUsersWithListInput(body); apiInstance.CreateUsersWithListInput(body);
} }
catch (Exception e) catch (ApiException e)
{ {
Debug.Print("Exception when calling UserApi.CreateUsersWithListInput: " + e.Message ); Debug.Print("Exception when calling UserApi.CreateUsersWithListInput: " + e.Message );
Debug.Print("Status Code: "+ e.ErrorCode);
Debug.Print(e.StackTrace);
} }
} }
} }
@ -220,7 +226,6 @@ This can only be done by the logged in user.
### Example ### Example
```csharp ```csharp
using System;
using System.Diagnostics; using System.Diagnostics;
using Org.OpenAPITools.Api; using Org.OpenAPITools.Api;
using Org.OpenAPITools.Client; using Org.OpenAPITools.Client;
@ -230,9 +235,10 @@ namespace Example
{ {
public class DeleteUserExample public class DeleteUserExample
{ {
public void main() public static void Main()
{ {
var apiInstance = new UserApi(); Configuration.Default.BasePath = "http://petstore.swagger.io:80/v2";
var apiInstance = new UserApi(Configuration.Default);
var username = username_example; // string | The name that needs to be deleted var username = username_example; // string | The name that needs to be deleted
try try
@ -240,9 +246,11 @@ namespace Example
// Delete user // Delete user
apiInstance.DeleteUser(username); apiInstance.DeleteUser(username);
} }
catch (Exception e) catch (ApiException e)
{ {
Debug.Print("Exception when calling UserApi.DeleteUser: " + e.Message ); Debug.Print("Exception when calling UserApi.DeleteUser: " + e.Message );
Debug.Print("Status Code: "+ e.ErrorCode);
Debug.Print(e.StackTrace);
} }
} }
} }
@ -284,7 +292,6 @@ Get user by user name
### Example ### Example
```csharp ```csharp
using System;
using System.Diagnostics; using System.Diagnostics;
using Org.OpenAPITools.Api; using Org.OpenAPITools.Api;
using Org.OpenAPITools.Client; using Org.OpenAPITools.Client;
@ -294,9 +301,10 @@ namespace Example
{ {
public class GetUserByNameExample public class GetUserByNameExample
{ {
public void main() public static void Main()
{ {
var apiInstance = new UserApi(); Configuration.Default.BasePath = "http://petstore.swagger.io:80/v2";
var apiInstance = new UserApi(Configuration.Default);
var username = username_example; // string | The name that needs to be fetched. Use user1 for testing. var username = username_example; // string | The name that needs to be fetched. Use user1 for testing.
try try
@ -305,9 +313,11 @@ namespace Example
User result = apiInstance.GetUserByName(username); User result = apiInstance.GetUserByName(username);
Debug.WriteLine(result); Debug.WriteLine(result);
} }
catch (Exception e) catch (ApiException e)
{ {
Debug.Print("Exception when calling UserApi.GetUserByName: " + e.Message ); Debug.Print("Exception when calling UserApi.GetUserByName: " + e.Message );
Debug.Print("Status Code: "+ e.ErrorCode);
Debug.Print(e.StackTrace);
} }
} }
} }
@ -349,7 +359,6 @@ Logs user into the system
### Example ### Example
```csharp ```csharp
using System;
using System.Diagnostics; using System.Diagnostics;
using Org.OpenAPITools.Api; using Org.OpenAPITools.Api;
using Org.OpenAPITools.Client; using Org.OpenAPITools.Client;
@ -359,9 +368,10 @@ namespace Example
{ {
public class LoginUserExample public class LoginUserExample
{ {
public void main() public static void Main()
{ {
var apiInstance = new UserApi(); Configuration.Default.BasePath = "http://petstore.swagger.io:80/v2";
var apiInstance = new UserApi(Configuration.Default);
var username = username_example; // string | The user name for login var username = username_example; // string | The user name for login
var password = password_example; // string | The password for login in clear text var password = password_example; // string | The password for login in clear text
@ -371,9 +381,11 @@ namespace Example
string result = apiInstance.LoginUser(username, password); string result = apiInstance.LoginUser(username, password);
Debug.WriteLine(result); Debug.WriteLine(result);
} }
catch (Exception e) catch (ApiException e)
{ {
Debug.Print("Exception when calling UserApi.LoginUser: " + e.Message ); Debug.Print("Exception when calling UserApi.LoginUser: " + e.Message );
Debug.Print("Status Code: "+ e.ErrorCode);
Debug.Print(e.StackTrace);
} }
} }
} }
@ -416,7 +428,6 @@ Logs out current logged in user session
### Example ### Example
```csharp ```csharp
using System;
using System.Diagnostics; using System.Diagnostics;
using Org.OpenAPITools.Api; using Org.OpenAPITools.Api;
using Org.OpenAPITools.Client; using Org.OpenAPITools.Client;
@ -426,18 +437,21 @@ namespace Example
{ {
public class LogoutUserExample public class LogoutUserExample
{ {
public void main() public static void Main()
{ {
var apiInstance = new UserApi(); Configuration.Default.BasePath = "http://petstore.swagger.io:80/v2";
var apiInstance = new UserApi(Configuration.Default);
try try
{ {
// Logs out current logged in user session // Logs out current logged in user session
apiInstance.LogoutUser(); apiInstance.LogoutUser();
} }
catch (Exception e) catch (ApiException e)
{ {
Debug.Print("Exception when calling UserApi.LogoutUser: " + e.Message ); Debug.Print("Exception when calling UserApi.LogoutUser: " + e.Message );
Debug.Print("Status Code: "+ e.ErrorCode);
Debug.Print(e.StackTrace);
} }
} }
} }
@ -478,7 +492,6 @@ This can only be done by the logged in user.
### Example ### Example
```csharp ```csharp
using System;
using System.Diagnostics; using System.Diagnostics;
using Org.OpenAPITools.Api; using Org.OpenAPITools.Api;
using Org.OpenAPITools.Client; using Org.OpenAPITools.Client;
@ -488,9 +501,10 @@ namespace Example
{ {
public class UpdateUserExample public class UpdateUserExample
{ {
public void main() public static void Main()
{ {
var apiInstance = new UserApi(); Configuration.Default.BasePath = "http://petstore.swagger.io:80/v2";
var apiInstance = new UserApi(Configuration.Default);
var username = username_example; // string | name that need to be deleted var username = username_example; // string | name that need to be deleted
var body = new User(); // User | Updated user object var body = new User(); // User | Updated user object
@ -499,9 +513,11 @@ namespace Example
// Updated user // Updated user
apiInstance.UpdateUser(username, body); apiInstance.UpdateUser(username, body);
} }
catch (Exception e) catch (ApiException e)
{ {
Debug.Print("Exception when calling UserApi.UpdateUser: " + e.Message ); Debug.Print("Exception when calling UserApi.UpdateUser: " + e.Message );
Debug.Print("Status Code: "+ e.ErrorCode);
Debug.Print(e.StackTrace);
} }
} }
} }