-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Copy pathCSharpGeneratorBaseSettings.cs
69 lines (55 loc) · 3.02 KB
/
CSharpGeneratorBaseSettings.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
//-----------------------------------------------------------------------
// <copyright file="SwaggerToCSharpGeneratorSettings.cs" company="NSwag">
// Copyright (c) Rico Suter. All rights reserved.
// </copyright>
// <license>https://github.com/RicoSuter/NSwag/blob/master/LICENSE.md</license>
// <author>Rico Suter, [email protected]</author>
//-----------------------------------------------------------------------
using Newtonsoft.Json;
using NJsonSchema;
using NJsonSchema.CodeGeneration;
using NJsonSchema.CodeGeneration.CSharp;
using System.Reflection;
namespace NSwag.CodeGeneration.CSharp
{
/// <summary>Settings for the <see cref="CSharpGeneratorBase"/>.</summary>
public abstract class CSharpGeneratorBaseSettings : ClientGeneratorBaseSettings
{
/// <summary>Initializes a new instance of the <see cref="CSharpClientGeneratorSettings"/> class.</summary>
protected CSharpGeneratorBaseSettings()
{
CSharpGeneratorSettings = new CSharpGeneratorSettings
{
Namespace = "MyNamespace",
SchemaType = SchemaType.Swagger2
};
CSharpGeneratorSettings.TemplateFactory = new DefaultTemplateFactory(CSharpGeneratorSettings, [
typeof(CSharpGeneratorSettings).GetTypeInfo().Assembly,
typeof(CSharpGeneratorBaseSettings).GetTypeInfo().Assembly
]);
ResponseArrayType = "System.Collections.Generic.ICollection";
ResponseDictionaryType = "System.Collections.Generic.IDictionary";
ParameterArrayType = "System.Collections.Generic.IEnumerable";
ParameterDictionaryType = "System.Collections.Generic.IDictionary";
AdditionalNamespaceUsages = [];
AdditionalContractNamespaceUsages = [];
}
/// <summary>Gets the CSharp generator settings.</summary>
public CSharpGeneratorSettings CSharpGeneratorSettings { get; }
/// <summary>Gets the code generator settings.</summary>
[JsonIgnore]
public override CodeGeneratorSettingsBase CodeGeneratorSettings => CSharpGeneratorSettings;
/// <summary>Gets or sets the additional namespace usages.</summary>
public string[] AdditionalNamespaceUsages { get; set; }
/// <summary>Gets or sets the additional contract namespace usages.</summary>
public string[] AdditionalContractNamespaceUsages { get; set; }
/// <summary>Gets or sets the array type of operation responses (i.e. the method return type).</summary>
public string ResponseArrayType { get; set; }
/// <summary>Gets or sets the dictionary type of operation responses (i.e. the method return type).</summary>
public string ResponseDictionaryType { get; set; }
/// <summary>Gets or sets the array type of operation parameters.</summary>
public string ParameterArrayType { get; set; }
/// <summary>Gets or sets the dictionary type of operation parameters.</summary>
public string ParameterDictionaryType { get; set; }
}
}