Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 1 addition & 27 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -47,41 +47,15 @@
<AnalysisLevel>latest-Recommended</AnalysisLevel>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<!--
[IDE0005] Using directive is unnecessary
[IDE0008] Use explicit type instead of 'var'
[IDE0017] Object initialization can be simplified
[IDE0021] Use block body for constructor
[IDE0022] Use block body for method
[IDE0029] Null check can be simplified
[IDE0032] Use auto property
[IDE0039] Use local function
[IDE0045] 'if' statement can be simplified
[IDE0046] 'if' statement can be simplified
[IDE0056] Indexing can be simplified
[IDE0057] Substring can be simplified
[IDE0060] Remove unused parameter
[IDE0090] 'new' expression can be simplified
[IDE0130] Namespace does not match folder structure
[IDE0160] Convert to block scoped namespace
[IDE0200] Lambda expression can be removed
[IDE0270] Null check can be simplified
[IDE0290] Use primary constructor
[IDE0330] Use 'System.Threading.Lock'
[CA1200] Avoid using cref tags with a prefix
[CA1510] Use 'ArgumentNullException.ThrowIfNull' instead of explicitly throwing a new exception instance
[CA1514] 'System.ReadOnlySpan<char>.Slice(int, int)' uses a redundant length calculation that can be removed
[CA1710] Rename to end in either 'Dictionary' or 'Collection'
[CA1716] rename parameter property so that it no longer conflicts with the reserved language keyword
[CA1720] Identifier 'xxx' contains type name
[CA1725] Overriden parameter name mismatch
[CA1845] Use span-based 'string.Concat' and 'AsSpan' instead of 'Substring'
[CA1870] Use a cached 'SearchValues' instance for improved searching performance
[CA2263] Prefer the generic overload 'System.Enum.GetValues<TEnum>()'

[SYSLIB0012] 'Assembly.CodeBase' is obsolete
-->
<NoWarn>$(NoWarn);IDE0005;IDE0008;IDE0017;IDE0021;IDE0022;IDE0029;IDE0032;IDE0039;IDE0045;IDE0046;IDE0056;IDE0057;IDE0060;IDE0090;IDE0130;IDE0160;IDE0200;IDE0270;IDE0290;IDE0330</NoWarn>
<NoWarn>$(NoWarn);CA1200;CA1510;CA1514;CA1710;CA1716;CA1720;CA1725;CA1845;CA1870;CA2263;SYSLIB0012</NoWarn>
<NoWarn>$(NoWarn);CA1200;CA1510;CA1716;CA1720;CA1725;CA1845;SYSLIB0012</NoWarn>
</PropertyGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ private static OpenApiDocument GetOpenApiDocument()
complexTypeReponseSchema.Properties["Prop3"] = new JsonSchemaProperty { Type = JsonObjectType.Boolean, IsRequired = true };
complexTypeReponseSchema.Properties["Prop4"] = new JsonSchemaProperty { Type = JsonObjectType.Object, Reference = complexTypeSchema, IsRequired = true };

var typeString = NewtonsoftJsonSchemaGenerator.FromType(typeof(string));
var typeString = NewtonsoftJsonSchemaGenerator.FromType<string>();

var document = new OpenApiDocument();
document.Paths["Foo"] = new OpenApiPathItem
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ private static ReadOnlySpan<char> GetClientName(OpenApiOperation operation)
operationIdSpan = operationIdSpan.Slice(0, idxLast);
int idxSecondLast = operationIdSpan.LastIndexOf(underscoreSeparator);

return operationIdSpan.Slice(idxSecondLast + 1, operationIdSpan.Length - idxSecondLast - 1);
return operationIdSpan.Slice(idxSecondLast + 1);
}

private static ReadOnlySpan<char> GetOperationName(OpenApiOperation operation)
Expand Down
4 changes: 3 additions & 1 deletion src/NSwag.Commands/Commands/InputOutputCommandBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ protected async Task<OpenApiDocument> GetInputSwaggerDocument()

if (ServiceSchemes != null && ServiceSchemes.Length > 0)
{
document.Schemes = ServiceSchemes.Select(s => (OpenApiSchema)Enum.Parse(typeof(OpenApiSchema), s, true)).ToList();
#pragma warning disable CA2263
document.Schemes = ServiceSchemes.Select(s => (OpenApiSchema) Enum.Parse(typeof(OpenApiSchema), s, ignoreCase: true)).ToList();
#pragma warning restore CA2263
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/NSwag.Core/OpenApiCallback.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
namespace NSwag
{
/// <summary>Describes an OpenAPI callback.</summary>
#pragma warning disable CA1710
public class OpenApiCallback : JsonReferenceBase<OpenApiCallback>, IJsonReference, IDictionary<string, OpenApiPathItem>
#pragma warning restore CA1710
{
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member

Expand Down
10 changes: 5 additions & 5 deletions src/NSwag.Core/OpenApiPathItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,19 +165,19 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist

if (propertyName == "summary")
{
operations.Summary = (string)serializer.Deserialize(reader, typeof(string));
operations.Summary = serializer.Deserialize<string>(reader);
}
else if (propertyName == "description")
{
operations.Description = (string)serializer.Deserialize(reader, typeof(string));
operations.Description = serializer.Deserialize<string>(reader);
}
else if (propertyName == "parameters")
{
operations.Parameters = (Collection<OpenApiParameter>)serializer.Deserialize(reader, typeof(Collection<OpenApiParameter>));
operations.Parameters = serializer.Deserialize<Collection<OpenApiParameter>>(reader);
}
else if (propertyName == "servers")
{
operations.Servers = (Collection<OpenApiServer>)serializer.Deserialize(reader, typeof(Collection<OpenApiServer>));
operations.Servers = serializer.Deserialize<Collection<OpenApiServer>>(reader);
}
else if (propertyName.StartsWith("x-", StringComparison.OrdinalIgnoreCase))
{
Expand All @@ -191,7 +191,7 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist
}
else
{
var value = (OpenApiOperation)serializer.Deserialize(reader, typeof(OpenApiOperation));
var value = serializer.Deserialize<OpenApiOperation>(reader);
operations.Add(propertyName, value);
}
}
Expand Down
Loading