Skip to content

Commit e6c883a

Browse files
committed
moved restsharp and httpclient to new generator
1 parent c4417e5 commit e6c883a

File tree

8 files changed

+468
-730
lines changed
  • samples/client/petstore/csharp/generichost

8 files changed

+468
-730
lines changed
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# Org.OpenAPITools.Api.APIKEYSApi
2+
3+
All URIs are relative to *http://app.files.com/api/rest/v1*
4+
5+
| Method | HTTP request | Description |
6+
|--------|--------------|-------------|
7+
| [**GetApiKeysId**](APIKEYSApi.md#getapikeysid) | **GET** /api_keys/{id} | Show API Key |
8+
9+
<a id="getapikeysid"></a>
10+
# **GetApiKeysId**
11+
> void GetApiKeysId (int id)
12+
13+
Show API Key
14+
15+
Show API Key
16+
17+
### Example
18+
```csharp
19+
using System.Collections.Generic;
20+
using System.Diagnostics;
21+
using Org.OpenAPITools.Api;
22+
using Org.OpenAPITools.Client;
23+
using Org.OpenAPITools.Model;
24+
25+
namespace Example
26+
{
27+
public class GetApiKeysIdExample
28+
{
29+
public static void Main()
30+
{
31+
Configuration config = new Configuration();
32+
config.BasePath = "http://app.files.com/api/rest/v1";
33+
var apiInstance = new APIKEYSApi(config);
34+
var id = 56; // int | Api Key ID.
35+
36+
try
37+
{
38+
// Show API Key
39+
apiInstance.GetApiKeysId(id);
40+
}
41+
catch (ApiException e)
42+
{
43+
Debug.Print("Exception when calling APIKEYSApi.GetApiKeysId: " + e.Message);
44+
Debug.Print("Status Code: " + e.ErrorCode);
45+
Debug.Print(e.StackTrace);
46+
}
47+
}
48+
}
49+
}
50+
```
51+
52+
#### Using the GetApiKeysIdWithHttpInfo variant
53+
This returns an ApiResponse object which contains the response data, status code and headers.
54+
55+
```csharp
56+
try
57+
{
58+
// Show API Key
59+
apiInstance.GetApiKeysIdWithHttpInfo(id);
60+
}
61+
catch (ApiException e)
62+
{
63+
Debug.Print("Exception when calling APIKEYSApi.GetApiKeysIdWithHttpInfo: " + e.Message);
64+
Debug.Print("Status Code: " + e.ErrorCode);
65+
Debug.Print(e.StackTrace);
66+
}
67+
```
68+
69+
### Parameters
70+
71+
| Name | Type | Description | Notes |
72+
|------|------|-------------|-------|
73+
| **id** | **int** | Api Key ID. | |
74+
75+
### Return type
76+
77+
void (empty response body)
78+
79+
### Authorization
80+
81+
No authorization required
82+
83+
### HTTP request headers
84+
85+
- **Content-Type**: Not defined
86+
- **Accept**: Not defined
87+
88+
89+
### HTTP response details
90+
| Status code | Description | Response headers |
91+
|-------------|-------------|------------------|
92+
| **400** | Bad Request | - |
93+
94+
[[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)
95+

samples/client/petstore/csharp/generichost/net4.7/AllOf/src/Org.OpenAPITools/Model/Adult.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,4 @@ public void WriteProperties(Utf8JsonWriter writer, Adult adult, JsonSerializerOp
192192
if (adult.LastNameOption.IsSet)
193193
writer.WriteString("lastName", adult.LastName);
194194

195-
writer.WriteString("$_type", adult.Type);
196-
}
197-
}
198-
}
195+
writer.WriteStr
Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
// <auto-generated>
2+
/*
3+
* fruity
4+
*
5+
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
6+
*
7+
* The version of the OpenAPI document: 0.0.1
8+
* Generated by: https://github.com/openapitools/openapi-generator.git
9+
*/
10+
11+
using System;
12+
using System.Collections;
13+
using System.Collections.Generic;
14+
using System.Collections.ObjectModel;
15+
using System.Linq;
16+
using System.IO;
17+
using System.Text;
18+
using System.Text.RegularExpressions;
19+
using System.Text.Json;
20+
using System.Text.Json.Serialization;
21+
using System.ComponentModel.DataAnnotations;
22+
using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils;
23+
using Org.OpenAPITools.Client;
24+
25+
namespace Org.OpenAPITools.Model
26+
{
27+
/// <summary>
28+
/// Apple
29+
/// </summary>
30+
public partial class Apple : IValidatableObject
31+
{
32+
/// <summary>
33+
/// Initializes a new instance of the <see cref="Apple" /> class.
34+
/// </summary>
35+
/// <param name="kind">kind</param>
36+
[JsonConstructor]
37+
public Apple(Option<string> kind = default)
38+
{
39+
KindOption = kind;
40+
OnCreated();
41+
}
42+
43+
partial void OnCreated();
44+
45+
/// <summary>
46+
/// Used to track the state of Kind
47+
/// </summary>
48+
[JsonIgnore]
49+
[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
50+
public Option<string> KindOption { get; private set; }
51+
52+
/// <summary>
53+
/// Gets or Sets Kind
54+
/// </summary>
55+
[JsonPropertyName("kind")]
56+
public string Kind { get { return this.KindOption; } set { this.KindOption = new Option<string>(value); } }
57+
58+
/// <summary>
59+
/// Gets or Sets additional properties
60+
/// </summary>
61+
[JsonExtensionData]
62+
public Dictionary<string, JsonElement> AdditionalProperties { get; } = new Dictionary<string, JsonElement>();
63+
64+
/// <summary>
65+
/// Returns the string presentation of the object
66+
/// </summary>
67+
/// <returns>String presentation of the object</returns>
68+
public override string ToString()
69+
{
70+
StringBuilder sb = new StringBuilder();
71+
sb.Append("class Apple {\n");
72+
sb.Append(" Kind: ").Append(Kind).Append("\n");
73+
sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n");
74+
sb.Append("}\n");
75+
return sb.ToString();
76+
}
77+
78+
/// <summary>
79+
/// To validate all properties of the instance
80+
/// </summary>
81+
/// <param name="validationContext">Validation context</param>
82+
/// <returns>Validation Result</returns>
83+
IEnumerable<ValidationResult> IValidatableObject.Validate(ValidationContext validationContext)
84+
{
85+
yield break;
86+
}
87+
}
88+
89+
/// <summary>
90+
/// A Json converter for type <see cref="Apple" />
91+
/// </summary>
92+
public class AppleJsonConverter : JsonConverter<Apple>
93+
{
94+
/// <summary>
95+
/// Deserializes json to <see cref="Apple" />
96+
/// </summary>
97+
/// <param name="utf8JsonReader"></param>
98+
/// <param name="typeToConvert"></param>
99+
/// <param name="jsonSerializerOptions"></param>
100+
/// <returns></returns>
101+
/// <exception cref="JsonException"></exception>
102+
public override Apple Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions)
103+
{
104+
int currentDepth = utf8JsonReader.CurrentDepth;
105+
106+
if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray)
107+
throw new JsonException();
108+
109+
JsonTokenType startingTokenType = utf8JsonReader.TokenType;
110+
111+
Option<string> kind = default;
112+
113+
while (utf8JsonReader.Read())
114+
{
115+
if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth)
116+
break;
117+
118+
if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth)
119+
break;
120+
121+
if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1)
122+
{
123+
string localVarJsonPropertyName = utf8JsonReader.GetString();
124+
utf8JsonReader.Read();
125+
126+
switch (localVarJsonPropertyName)
127+
{
128+
case "kind":
129+
kind = new Option<string>(utf8JsonReader.GetString());
130+
break;
131+
default:
132+
break;
133+
}
134+
}
135+
}
136+
137+
if (kind.IsSet && kind.Value == null)
138+
throw new ArgumentNullException(nameof(kind), "Property is not nullable for class Apple.");
139+
140+
return new Apple(kind);
141+
}
142+
143+
/// <summary>
144+
/// Serializes a <see cref="Apple" />
145+
/// </summary>
146+
/// <param name="writer"></param>
147+
/// <param name="apple"></param>
148+
/// <param name="jsonSerializerOptions"></param>
149+
/// <exception cref="NotImplementedException"></exception>
150+
public override void Write(Utf8JsonWriter writer, Apple apple, JsonSerializerOptions jsonSerializerOptions)
151+
{
152+
writer.WriteStartObject();
153+
154+
WriteProperties(writer, apple, jsonSerializerOptions);
155+
writer.WriteEndObject();
156+
}
157+
158+
/// <summary>
159+
/// Serializes the properties of <see cref="Apple" />
160+
/// </summary>
161+
/// <param name="writer"></param>
162+
/// <param name="apple"></param>
163+
/// <param name="jsonSerializerOptions"></param>
164+
/// <exception cref="NotImplementedException"></exception>
165+
public void WriteProperties(Utf8JsonWriter writer, Apple apple, JsonSerializerOptions jsonSerializerOptions)
166+
{
167+
if (apple.KindOption.IsSet && apple.Kind == null)
168+
throw new ArgumentNullException(nameof(apple.Kind), "Property is required for class Apple.");
169+
170+
if (apple.KindOption.IsSet)
171+
writer.WriteString("kind", apple.Kind);
172+
}
173+
}
174+
}

0 commit comments

Comments
 (0)