Skip to content

Commit a7a79fd

Browse files
authored
Merge pull request #5 from MobileTeleSystems/fix_ca_issue
Fix CA issues
2 parents 6454f40 + d1add16 commit a7a79fd

File tree

21 files changed

+68
-19
lines changed

21 files changed

+68
-19
lines changed

.editorconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,6 @@ dotnet_diagnostic.SA1200.severity = none
276276
dotnet_diagnostic.SA1309.severity = none
277277
dotnet_diagnostic.SA1310.severity = none
278278
dotnet_diagnostic.SA1311.severity = none
279-
dotnet_diagnostic.SA1503.severity = none
280279
dotnet_diagnostic.SA1600.severity = none
281280
dotnet_diagnostic.SA1623.severity = none
282281
dotnet_diagnostic.SA1633.severity = silent

ApiCodeGenerator.ruleset

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@
8080
<Rule Id="SA1309" Action="None" />
8181
<Rule Id="SA1310" Action="None" />
8282
<Rule Id="SA1311" Action="None" />
83-
<Rule Id="SA1503" Action="None" />
8483
<Rule Id="SA1600" Action="None" />
8584
<Rule Id="SA1623" Action="None" />
8685
<Rule Id="SA1633" Action="Hidden" />

src/ApiCodeGenerator.Abstraction/AssemblyResolver.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,18 @@ public static void Unregister()
113113
{
114114
var thisAsm = Assembly.GetCallingAssembly();
115115
if (assemblyName == thisAsm.GetName())
116+
{
116117
return null;
118+
}
117119

118120
var path = _resolvers.Select(r => r.Invoke(assemblyName)).FirstOrDefault(p => p != null);
119121

120122
var key = assemblyName.Name;
121123

122124
if (path == null && _asmPaths.TryGetValue(key, out var item))
125+
{
123126
path = item.Path;
127+
}
124128

125129
return path == null
126130
? null

src/ApiCodeGenerator.Abstraction/GeneratorContext.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ internal GeneratorContext(
3131

3232
public ILogger? Logger { get; internal set; }
3333

34-
public T? GetSettings<T>(JsonSerializer? jsonSerializer = null, IReadOnlyDictionary<string, string>? additionalVariables = null)
34+
public T? GetSettings<T>(JsonSerializer? jsonSerializer, IReadOnlyDictionary<string, string>? additionalVariables)
3535
where T : class
3636
=> (T?)_settingsFactory(typeof(T), jsonSerializer, additionalVariables);
3737
}

src/ApiCodeGenerator.AsyncApi/CSharp/CSharpGeneratorBaseSettings.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ protected CSharpGeneratorBaseSettings()
1818

1919
CSharpGeneratorSettings.TemplateFactory = new DefaultTemplateFactory(CSharpGeneratorSettings, new[]
2020
{
21-
typeof(CSharpGeneratorBaseSettings).GetType().Assembly,
22-
typeof(CSharpGeneratorSettings).GetType().Assembly,
21+
GetType().Assembly,
22+
typeof(CSharpGeneratorSettings).Assembly,
2323
});
2424

2525
ResponseArrayType = "System.Collections.Generic.ICollection";

src/ApiCodeGenerator.AsyncApi/CSharp/Models/CSharpOperationModel.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@ public CSharpOperationModel(
5252

5353
public CSharpParameterModel[] Parameters { get; }
5454

55-
public string PayloadType => _payloadType ??= ResolvePayloadType(Operation.Message.ActualObject.Payload.ActualSchema);
55+
public string PayloadType => _payloadType ??= ResolvePayloadType(Operation.Message.ActualObject.Payload.ActualSchema, hint: null);
5656

5757
protected Channel Channel { get; }
5858

5959
protected Operation Operation { get; }
6060

61-
protected virtual string ResolvePayloadType(JsonSchema jsonSchema, string? hint = null)
61+
protected virtual string ResolvePayloadType(JsonSchema jsonSchema, string? hint)
6262
{
6363
if (!jsonSchema.HasTypeNameTitle && string.IsNullOrEmpty(hint))
6464
{

src/ApiCodeGenerator.AsyncApi/DOM/Serialization/InheritanceConverter.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ public override object ReadJson(JsonReader reader, Type objectType, object? exis
5757
/// <inheritdoc/>
5858
public override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer)
5959
{
60+
throw new NotSupportedException();
6061
}
6162

6263
private static Dictionary<string, Func<T>> GetFactories()

src/ApiCodeGenerator.Core/ApiDocumentProvider.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,29 +43,41 @@ public ApiDocumentProvider(IFileProvider fileProvider, HttpClient httpClient)
4343
else
4444
{
4545
if (Uri.TryCreate(documentSource.FromDocument.Url, UriKind.Absolute, out var url))
46+
{
4647
return await FromUrlAsync(url);
48+
}
4749
else
50+
{
4851
return Failed("Invalid url format", null);
52+
}
4953
}
5054
}
5155
else
5256
{
5357
var json = documentSource.FromDocument.Json!;
5458
if (IsPath(json))
59+
{
5560
return await FromFileAsync(json);
61+
}
5662
else
63+
{
5764
return FromContent(json, null);
65+
}
5866
}
5967
}
6068

6169
if (documentSource.JsonSchemaToOpenApi != null)
6270
{
6371
var data = documentSource.JsonSchemaToOpenApi;
6472
if (string.IsNullOrEmpty(data.Name))
73+
{
6574
return Failed("jsonSchemaToOpenApi.name must be not null or empty", null);
75+
}
6676

6777
if (string.IsNullOrEmpty(data.Schema))
78+
{
6879
return Failed("jsonSchemaToOpenApi.schema must be not null or empty", null);
80+
}
6981

7082
if (IsPath(data.Schema))
7183
{

src/ApiCodeGenerator.Core/ExtensionManager/ExtensionLoader.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,15 @@ private static void GetAndMergeDict<T>(Type type, string propName, Dictionary<st
6666
if (propInfo != null)
6767
{
6868
if (!typeof(IDictionary<string, T>).IsAssignableFrom(propInfo.PropertyType))
69+
{
6970
throw new InvalidOperationException($"Property {propName} in assembly {type.Assembly.FullName} must return type IDictionary<string, {typeof(T)}>");
71+
}
7072

7173
var value = (IDictionary<string, T>)propInfo.GetValue(type, null);
7274
foreach (var kv in value)
75+
{
7376
dict.Add(kv.Key, kv.Value);
77+
}
7478
}
7579
}
7680

@@ -80,7 +84,9 @@ private static void GetAndMergeDictOfList<T>(Type type, string propName, Diction
8084
if (propInfo != null)
8185
{
8286
if (!typeof(IDictionary<string, T>).IsAssignableFrom(propInfo.PropertyType))
87+
{
8388
throw new InvalidOperationException($"Property {propName} in assembly {type.Assembly.FullName} must return type IDictionary<string, {typeof(T)}>");
89+
}
8490

8591
var value = (IDictionary<string, T>)propInfo.GetValue(type, null);
8692
if (value.Any())

src/ApiCodeGenerator.Core/ExtensionManager/Extensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace ApiCodeGenerator.Core.ExtensionManager
1010
/// <summary>
1111
/// Информация о расширениях.
1212
/// </summary>
13-
public class Extensions : IExtensions
13+
internal class Extensions : IExtensions
1414
{
1515
public Extensions(
1616
IReadOnlyDictionary<string, ContentGeneratorFactory>? codeGenerators = null,

0 commit comments

Comments
 (0)