Skip to content

Commit 8bc3738

Browse files
committed
Attempt to adjust the behavior of the API Client on the generator and silence errors
1 parent 237e9bd commit 8bc3738

133 files changed

Lines changed: 18735 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
{{>partial_header}}
2+
3+
using System;
4+
using Newtonsoft.Json;
5+
using Newtonsoft.Json.Serialization;
6+
7+
namespace {{packageName}}.{{modelPackage}}
8+
{
9+
/// <summary>
10+
/// Abstract base class for oneOf, anyOf schemas in the OpenAPI specification
11+
/// </summary>
12+
{{>visibility}} abstract partial class AbstractOpenAPISchema
13+
{
14+
/// <summary>
15+
/// Custom JSON serializer
16+
/// </summary>
17+
static public readonly JsonSerializerSettings SerializerSettings = new JsonSerializerSettings
18+
{
19+
// OpenAPI generated types generally hide default constructors.
20+
ConstructorHandling = ConstructorHandling.AllowNonPublicDefaultConstructor,
21+
MissingMemberHandling = MissingMemberHandling.Error,
22+
ContractResolver = new DefaultContractResolver
23+
{
24+
NamingStrategy = new CamelCaseNamingStrategy
25+
{
26+
OverrideSpecifiedNames = false
27+
}
28+
}
29+
};
30+
31+
/// <summary>
32+
/// Custom JSON serializer for objects with additional properties
33+
/// </summary>
34+
static public readonly JsonSerializerSettings AdditionalPropertiesSerializerSettings = new JsonSerializerSettings
35+
{
36+
// OpenAPI generated types generally hide default constructors.
37+
ConstructorHandling = ConstructorHandling.AllowNonPublicDefaultConstructor,
38+
MissingMemberHandling = MissingMemberHandling.Ignore,
39+
ContractResolver = new DefaultContractResolver
40+
{
41+
NamingStrategy = new CamelCaseNamingStrategy
42+
{
43+
OverrideSpecifiedNames = false
44+
}
45+
}
46+
};
47+
48+
/// <summary>
49+
/// Gets or Sets the actual instance
50+
/// </summary>
51+
public abstract Object ActualInstance { get; set; }
52+
53+
/// <summary>
54+
/// Gets or Sets IsNullable to indicate whether the instance is nullable
55+
/// </summary>
56+
public bool IsNullable { get; protected set; }
57+
58+
/// <summary>
59+
/// Gets or Sets the schema type, which can be either `oneOf` or `anyOf`
60+
/// </summary>
61+
public string SchemaType { get; protected set; }
62+
63+
/// <summary>
64+
/// Converts the instance into JSON string.
65+
/// </summary>
66+
public abstract string ToJson();
67+
}
68+
}

0 commit comments

Comments
 (0)