Skip to content

Commit c3f6708

Browse files
committed
Process review feedback
1 parent f6c01f2 commit c3f6708

34 files changed

+793
-636
lines changed

Diff for: JsonApiDotNetCore.sln.DotSettings

+3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ JsonApiDotNetCore.ArgumentGuard.NotNull($EXPR$, $NAME$);</s:String>
1515
<s:Int64 x:Key="/Default/CodeEditing/NullCheckPatterns/PatternTypeNamesToPriority/=JetBrains_002EReSharper_002EFeature_002EServices_002ECSharp_002ENullChecking_002ETraceAssertPattern/@EntryIndexedValue">50</s:Int64>
1616
<s:Boolean x:Key="/Default/CodeInspection/CodeAnnotations/PropagateAnnotations/@EntryValue">False</s:Boolean>
1717
<s:Boolean x:Key="/Default/CodeInspection/ExcludedFiles/FileMasksToSkip/=swagger_002Ejson/@EntryIndexedValue">True</s:Boolean>
18+
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=B693DE14_002DBB28_002D496F_002DAB39_002DB4E674ABCA80_002Fd_003ANamingConventions_002Fd_003ACamelCase_002Ff_003Aswagger_002Ejson/@EntryIndexedValue">ExplicitlyExcluded</s:String>
19+
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=B693DE14_002DBB28_002D496F_002DAB39_002DB4E674ABCA80_002Fd_003ANamingConventions_002Fd_003AKebabCase_002Ff_003Aswagger_002Ejson/@EntryIndexedValue">ExplicitlyExcluded</s:String>
20+
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=B693DE14_002DBB28_002D496F_002DAB39_002DB4E674ABCA80_002Fd_003ANamingConventions_002Fd_003APascalCase_002Ff_003Aswagger_002Ejson/@EntryIndexedValue">ExplicitlyExcluded</s:String>
1821
<s:String x:Key="/Default/CodeInspection/Highlighting/AnalysisEnabled/@EntryValue">SOLUTION</s:String>
1922
<s:Boolean x:Key="/Default/CodeInspection/Highlighting/IdentifierHighlightingEnabled/@EntryValue">True</s:Boolean>
2023
<s:Boolean x:Key="/Default/CodeInspection/Highlighting/IncludeWarningsInSwea/@EntryValue">True</s:Boolean>

Diff for: src/JsonApiDotNetCore.OpenApi.Client/ApiException.cs

+34-33
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,45 @@
11
using JetBrains.Annotations;
22

33
// We cannot rely on generating ApiException as soon as we are generating multiple clients, see https://github.com/RicoSuter/NSwag/issues/2839#issuecomment-776647377.
4-
// Instead, we take the generated code as is and use it for the various clients.
5-
#nullable disable
6-
// @formatter:off
7-
// ReSharper disable All
8-
namespace JsonApiDotNetCore.OpenApi.Client.Exceptions
4+
// Instead, we configure NSwag to point to the exception below in the generated code.
5+
6+
// ReSharper disable once CheckNamespace
7+
namespace JsonApiDotNetCore.OpenApi.Client.Exceptions;
8+
9+
[UsedImplicitly(ImplicitUseTargetFlags.Members)]
10+
internal class ApiException : Exception
911
{
10-
[UsedImplicitly(ImplicitUseTargetFlags.Members)]
11-
internal class ApiException : Exception
12-
{
13-
public int StatusCode { get; }
12+
public int StatusCode { get; }
13+
14+
public string? Response { get; }
1415

15-
public string Response { get; }
16+
public IReadOnlyDictionary<string, IEnumerable<string>> Headers { get; }
1617

17-
public IReadOnlyDictionary<string, IEnumerable<string>> Headers { get; }
18+
public ApiException(string message, int statusCode, string? response, IReadOnlyDictionary<string, IEnumerable<string>> headers, Exception innerException)
19+
: base(
20+
message + "\n\nStatus: " + statusCode + "\nResponse: \n" +
21+
(response == null ? "(null)" : response[..(response.Length >= 512 ? 512 : response.Length)]), innerException)
22+
{
23+
StatusCode = statusCode;
24+
Response = response;
25+
Headers = headers;
26+
}
1827

19-
public ApiException(string message, int statusCode, string response, IReadOnlyDictionary<string, IEnumerable<string>> headers, Exception innerException)
20-
: base(
21-
message + "\n\nStatus: " + statusCode + "\nResponse: \n" +
22-
(response == null ? "(null)" : response.Substring(0, response.Length >= 512 ? 512 : response.Length)), innerException)
23-
{
24-
StatusCode = statusCode;
25-
Response = response;
26-
Headers = headers;
27-
}
28+
public override string ToString()
29+
{
30+
return $"HTTP Response: \n\n{Response}\n\n{base.ToString()}";
31+
}
32+
}
2833

29-
public override string ToString()
30-
{
31-
return $"HTTP Response: \n\n{Response}\n\n{base.ToString()}";
32-
}}
34+
[UsedImplicitly(ImplicitUseTargetFlags.Members)]
35+
internal sealed class ApiException<TResult> : ApiException
36+
{
37+
public TResult Result { get; }
3338

34-
internal sealed class ApiException<TResult> : ApiException
39+
public ApiException(string message, int statusCode, string? response, IReadOnlyDictionary<string, IEnumerable<string>> headers, TResult result,
40+
Exception innerException)
41+
: base(message, statusCode, response, headers, innerException)
3542
{
36-
public TResult Result { get; }
37-
38-
public ApiException(string message, int statusCode, string response, IReadOnlyDictionary<string, IEnumerable<string>> headers, TResult result,
39-
Exception innerException)
40-
: base(message, statusCode, response, headers, innerException)
41-
{
42-
Result = result;
43-
}}
43+
Result = result;
44+
}
4445
}

Diff for: src/JsonApiDotNetCore.OpenApi/JsonApiOperationIdSelector.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ private string ApplyTemplate(string operationIdTemplate, ResourceType resourceTy
112112
throw new UnreachableCodeException();
113113
}
114114

115-
string method = endpoint.HttpMethod!.ToLowerInvariant();
115+
string method = endpoint.HttpMethod.ToLowerInvariant();
116116
string relationshipName = operationIdTemplate.Contains("[RelationshipName]") ? endpoint.RelativePath.Split("/").Last() : string.Empty;
117117

118118
// @formatter:wrap_chained_method_calls chop_always

Diff for: src/JsonApiDotNetCore.OpenApi/ServiceCollectionExtensions.cs

-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ private static void AddCustomApiExplorer(IServiceCollection services, IMvcCoreBu
4141
var apiDescriptionProviders = provider.GetRequiredService<IEnumerable<IApiDescriptionProvider>>();
4242

4343
JsonApiActionDescriptorCollectionProvider descriptorCollectionProviderWrapper = new(controllerResourceMapping, actionDescriptorCollectionProvider);
44-
4544
return new ApiDescriptionGroupCollectionProvider(descriptorCollectionProviderWrapper, apiDescriptionProviders);
4645
});
4746

Diff for: src/JsonApiDotNetCore.OpenApi/StringExtensions.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ namespace JsonApiDotNetCore.OpenApi;
44

55
internal static class StringExtensions
66
{
7+
private static readonly Regex Pattern = new("(?:^|-|_| +)(.)", RegexOptions.Compiled);
8+
79
public static string Pascalize(this string source)
810
{
9-
return Regex.Replace(source, "(?:^|-|_| +)(.)", match => match.Groups[1].Value.ToUpper());
11+
return Pattern.Replace(source, match => match.Groups[1].Value.ToUpper());
1012
}
1113
}

Diff for: src/JsonApiDotNetCore.OpenApi/SwaggerComponents/NullableReferenceSchemaGenerator.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ internal sealed class NullableReferenceSchemaGenerator
1010
private readonly NullableReferenceSchemaStrategy _nullableReferenceStrategy =
1111
Enum.Parse<NullableReferenceSchemaStrategy>(NullableReferenceSchemaStrategy.Implicit.ToString());
1212

13-
private readonly string _nullableSchemaReferenceId;
1413
private readonly ISchemaRepositoryAccessor _schemaRepositoryAccessor;
14+
private readonly string _nullableSchemaReferenceId;
1515

1616
private OpenApiSchema? _referenceSchemaForExplicitNullValue;
1717

Diff for: test/OpenApiClientTests/NamingConvention/CamelCase/GeneratedTypesTests.cs

-78
This file was deleted.

Diff for: test/OpenApiClientTests/NamingConvention/KebabCase/GeneratedTypesTests.cs

-79
This file was deleted.

0 commit comments

Comments
 (0)