Skip to content

Commit 2e90e10

Browse files
Cleanup unused
1 parent 2c4abbe commit 2e90e10

File tree

45 files changed

+47
-2787
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+47
-2787
lines changed

ReQuesty.Builder/CodeRenderers/CodeRenderer.cs

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using ReQuesty.Builder.CodeDOM;
2-
using ReQuesty.Builder.Configuration;
1+
using ReQuesty.Builder.CodeDOM;
32
using ReQuesty.Builder.OrderComparers;
43
using ReQuesty.Builder.Writers;
54

@@ -10,10 +9,8 @@ namespace ReQuesty.Builder.CodeRenderers;
109
/// </summary>
1110
public class CodeRenderer
1211
{
13-
public CodeRenderer(GenerationConfiguration configuration, CodeElementOrderComparer? elementComparer = null)
12+
public CodeRenderer(CodeElementOrderComparer? elementComparer = null)
1413
{
15-
ArgumentNullException.ThrowIfNull(configuration);
16-
Configuration = configuration;
1714
_rendererElementComparer = elementComparer ?? new CodeElementOrderComparer();
1815
}
1916

@@ -64,10 +61,6 @@ public async Task RenderCodeNamespaceToFilePerClassAsync(LanguageWriter writer,
6461
}
6562
}
6663
private readonly CodeElementOrderComparer _rendererElementComparer;
67-
protected GenerationConfiguration Configuration
68-
{
69-
get; private set;
70-
}
7164
private void RenderCode(LanguageWriter writer, CodeElement element)
7265
{
7366
writer.Write(element);
@@ -89,13 +82,11 @@ public virtual bool ShouldRenderNamespaceFile(CodeNamespace codeNamespace)
8982
}
9083
// if the module already has a class with the same name, it's going to be declared automatically
9184
string namespaceNameLastSegment = codeNamespace.Name.Split('.')[^1];
92-
return Configuration.ShouldWriteBarrelsIfClassExists || codeNamespace.FindChildByName<CodeClass>(namespaceNameLastSegment, false) is null;
85+
return codeNamespace.FindChildByName<CodeClass>(namespaceNameLastSegment, false) is null;
9386
}
9487

95-
public static CodeRenderer GetCodeRender(GenerationConfiguration config)
88+
public static CodeRenderer GetCodeRender()
9689
{
97-
ArgumentNullException.ThrowIfNull(config);
98-
return new CodeRenderer(config);
90+
return new CodeRenderer();
9991
}
100-
10192
}

ReQuesty.Builder/CodeRenderers/TypeScriptCodeRenderer.cs

Lines changed: 0 additions & 24 deletions
This file was deleted.

ReQuesty.Builder/Configuration/GenerationConfiguration.cs

Lines changed: 0 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
using System.Text.Json.Nodes;
21
using ReQuesty.Builder.CodeDOM;
32
using ReQuesty.Builder.Extensions;
43
using ReQuesty.Builder.Lock;
5-
using Microsoft.OpenApi.ApiManifest;
64
using ReQuesty.Core;
75

86
namespace ReQuesty.Builder.Configuration;
@@ -13,15 +11,6 @@ public static GenerationConfiguration DefaultConfiguration
1311
{
1412
get;
1513
} = new();
16-
public bool ShouldGetApiManifest
17-
{
18-
get
19-
{
20-
return (string.IsNullOrEmpty(OpenAPIFilePath) || OpenAPIFilePath.Equals(DefaultConfiguration.OpenAPIFilePath, StringComparison.OrdinalIgnoreCase)) &&
21-
(!string.IsNullOrEmpty(ApiManifestPath) || !ApiManifestPath.Equals(DefaultConfiguration.ApiManifestPath, StringComparison.OrdinalIgnoreCase)) &&
22-
(ApiManifestPath.StartsWith("http", StringComparison.OrdinalIgnoreCase) || File.Exists(ApiManifestPath));
23-
}
24-
}
2514
public bool SkipGeneration
2615
{
2716
get; set;
@@ -31,10 +20,6 @@ public ConsumerOperation? Operation
3120
get; set;
3221
}
3322
public string OpenAPIFilePath { get; set; } = "openapi.yaml";
34-
public string ApiManifestPath { get; set; } = "apimanifest.json";
35-
// Optional filename suffix to be used when generating multiple API plugins for the same OpenAPI file.
36-
// Note: It can not be set from the outside, it is only used internally when generating the plugin manifest.
37-
internal string FileNameSuffix { get; set; } = "";
3823

3924
public string OutputPath { get; set; } = "./output";
4025
public string ClientClassName { get; set; } = "ApiClient";
@@ -51,7 +36,6 @@ public string ModelsNamespaceName
5136
get => $"{ClientNamespaceName}{NamespaceNameSeparator}{ModelsNamespaceSegmentName}";
5237
}
5338
public GenerationLanguage Language { get; set; } = GenerationLanguage.CSharp;
54-
public HashSet<PluginType> PluginTypes { get; set; } = [];
5539
public string? ApiRootUrl
5640
{
5741
get; set;
@@ -78,14 +62,6 @@ public HashSet<string> Deserializers
7862
"ReQuesty.Runtime.Serialization.Text.TextParseNodeFactory",
7963
"ReQuesty.Runtime.Serialization.Form.FormParseNodeFactory",
8064
};
81-
public bool ShouldWriteBarrelsIfClassExists
82-
{
83-
get
84-
{
85-
return BarreledLanguagesWithConstantFileName.Contains(Language);
86-
}
87-
}
88-
private static readonly HashSet<GenerationLanguage> BarreledLanguagesWithConstantFileName = [];
8965
public bool CleanOutput
9066
{
9167
get; set;
@@ -101,10 +77,6 @@ public StructuredMimeTypesCollection StructuredMimeTypes
10177
];
10278
public HashSet<string> IncludePatterns { get; set; } = new(0, StringComparer.OrdinalIgnoreCase);
10379
public HashSet<string> ExcludePatterns { get; set; } = new(0, StringComparer.OrdinalIgnoreCase);
104-
/// <summary>
105-
/// The overrides loaded from the api manifest when refreshing a client, as opposed to the user provided ones.
106-
/// </summary>
107-
public HashSet<string> PatternsOverride { get; set; } = new(0, StringComparer.OrdinalIgnoreCase);
10880
public bool ClearCache
10981
{
11082
get; set;
@@ -115,13 +87,6 @@ public bool? IncludeReQuestyValidationRules
11587
get; set;
11688
}
11789

118-
// If set to true, this allows to parse extensions from manifest
119-
// to use in query operations for RPC requests
120-
public bool? IncludePluginExtensions
121-
{
122-
get; set;
123-
}
124-
12590
public bool NoWorkspace
12691
{
12792
get; set;
@@ -150,13 +115,10 @@ public object Clone()
150115
ClearCache = ClearCache,
151116
DisabledValidationRules = new(DisabledValidationRules ?? Enumerable.Empty<string>(), StringComparer.OrdinalIgnoreCase),
152117
IncludeReQuestyValidationRules = IncludeReQuestyValidationRules,
153-
IncludePluginExtensions = IncludePluginExtensions,
154118
MaxDegreeOfParallelism = MaxDegreeOfParallelism,
155119
SkipGeneration = SkipGeneration,
156120
NoWorkspace = NoWorkspace,
157121
Operation = Operation,
158-
PatternsOverride = new(PatternsOverride ?? Enumerable.Empty<string>(), StringComparer.OrdinalIgnoreCase),
159-
PluginTypes = new(PluginTypes ?? Enumerable.Empty<PluginType>()),
160122
DisableSSLValidation = DisableSSLValidation,
161123
ExportPublicApi = ExportPublicApi,
162124
};
@@ -193,37 +155,6 @@ internal void UpdateConfigurationFromLanguagesInformation(LanguagesInformation l
193155
}
194156
public const string ReQuestyHashManifestExtensionKey = "x-requesty-hash";
195157
public const string ReQuestyVersionManifestExtensionKey = "x-requesty-version";
196-
public ApiDependency ToApiDependency(string configurationHash, Dictionary<string, HashSet<string>> templatesWithOperations, string targetDirectory)
197-
{
198-
ApiDependency dependency = new()
199-
{
200-
ApiDescriptionUrl = NormalizeDescriptionLocation(targetDirectory),
201-
ApiDeploymentBaseUrl = ApiRootUrl?.EndsWith('/') ?? false ? ApiRootUrl : $"{ApiRootUrl}/",
202-
Extensions = [],
203-
Requests = templatesWithOperations.SelectMany(static x => x.Value.Select(y => new RequestInfo { Method = y.ToUpperInvariant(), UriTemplate = x.Key.DeSanitizeUrlTemplateParameter() })).ToList(),
204-
};
205-
206-
if (!string.IsNullOrEmpty(configurationHash))
207-
{
208-
dependency.Extensions.Add(ReQuestyHashManifestExtensionKey, JsonValue.Create(configurationHash));// only include non empty value.
209-
}
210-
dependency.Extensions.Add(ReQuestyVersionManifestExtensionKey, ReQuestyVersion.Current());
211-
return dependency;
212-
}
213-
private string NormalizeDescriptionLocation(string targetDirectory)
214-
{
215-
if (!string.IsNullOrEmpty(OpenAPIFilePath) &&
216-
!string.IsNullOrEmpty(targetDirectory) &&
217-
!OpenAPIFilePath.StartsWith("http", StringComparison.OrdinalIgnoreCase) &&
218-
Path.IsPathRooted(OpenAPIFilePath) &&
219-
Path.GetFullPath(OpenAPIFilePath).StartsWith(Path.GetFullPath(targetDirectory), StringComparison.Ordinal))
220-
{
221-
return "./" + Path.GetRelativePath(targetDirectory, OpenAPIFilePath).NormalizePathSeparators();
222-
}
223-
224-
return OpenAPIFilePath;
225-
}
226-
public bool IsPluginConfiguration => PluginTypes.Count != 0;
227158

228159
public bool DisableSSLValidation
229160
{
Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.Text.Json.Nodes;
1+
using System.Text.Json.Nodes;
22
using ReQuesty.Builder.OpenApiExtensions;
33
using Microsoft.OpenApi;
44
using Microsoft.OpenApi.Reader;
@@ -7,37 +7,11 @@ namespace ReQuesty.Builder.Extensions;
77

88
public static class OpenApiSettingsExtensions
99
{
10-
/// <summary>
11-
/// Adds the OpenAPI extensions used for plugins generation.
12-
/// </summary>
13-
public static void AddPluginsExtensions(this OpenApiReaderSettings settings)
14-
{
15-
ArgumentNullException.ThrowIfNull(settings);
16-
settings.ExtensionParsers ??= new Dictionary<string, Func<JsonNode, OpenApiSpecVersion, IOpenApiExtension>>(StringComparer.OrdinalIgnoreCase);
17-
settings.ExtensionParsers.TryAdd(OpenApiLogoExtension.Name, static (i, _) => OpenApiLogoExtension.Parse(i));
18-
settings.ExtensionParsers.TryAdd(OpenApiDescriptionForModelExtension.Name, static (i, _) => OpenApiDescriptionForModelExtension.Parse(i));
19-
settings.ExtensionParsers.TryAdd(OpenApiPrivacyPolicyUrlExtension.Name, static (i, _) => OpenApiPrivacyPolicyUrlExtension.Parse(i));
20-
settings.ExtensionParsers.TryAdd(OpenApiLegalInfoUrlExtension.Name, static (i, _) => OpenApiLegalInfoUrlExtension.Parse(i));
21-
}
22-
2310
public static void AddGenerationExtensions(this OpenApiReaderSettings settings)
2411
{
2512
ArgumentNullException.ThrowIfNull(settings);
2613
settings.AddMicrosoftExtensionParsers();
2714
settings.ExtensionParsers ??= new Dictionary<string, Func<JsonNode, OpenApiSpecVersion, IOpenApiExtension>>(StringComparer.OrdinalIgnoreCase);
2815
settings.ExtensionParsers.TryAdd(OpenApiReQuestyExtension.Name, static (i, _) => OpenApiReQuestyExtension.Parse(i));
2916
}
30-
31-
public static HashSet<string> ReQuestySupportedExtensions()
32-
{
33-
OpenApiReaderSettings dummySettings = new();
34-
dummySettings.AddGenerationExtensions();
35-
dummySettings.AddPluginsExtensions();
36-
37-
HashSet<string> supportedExtensions = dummySettings.ExtensionParsers?.Keys.ToHashSet(StringComparer.OrdinalIgnoreCase) ?? [];
38-
39-
supportedExtensions.Add("x-openai-isConsequential");// add extension we don't parse to the list
40-
41-
return supportedExtensions;
42-
}
4317
}

ReQuesty.Builder/Manifest/ApiDependencyComparer.cs

Lines changed: 0 additions & 81 deletions
This file was deleted.

ReQuesty.Builder/Manifest/ManifestManagementService.cs

Lines changed: 0 additions & 34 deletions
This file was deleted.

0 commit comments

Comments
 (0)