File tree Expand file tree Collapse file tree 6 files changed +1256
-18
lines changed
NamingConvention/KebabCase Expand file tree Collapse file tree 6 files changed +1256
-18
lines changed Original file line number Diff line number Diff line change 28
28
</ItemGroup >
29
29
30
30
<ItemGroup >
31
- <OpenApiReference Include =" ..\OpenApiTests\LegacyOpenApiIntegration\swagger .json" >
31
+ <OpenApiReference Include =" ..\OpenApiTests\SwaggerDocuments\LegacyOpenApiIntegration .json" >
32
32
<Namespace >OpenApiClientTests.LegacyClient.GeneratedCode</Namespace >
33
33
<ClassName >OpenApiClient</ClassName >
34
34
<CodeGenerator >NSwagCSharp</CodeGenerator >
35
35
<Options >/UseBaseUrl:false /GenerateClientInterfaces:true /ClientClassAccessModifier:internal</Options >
36
36
</OpenApiReference >
37
37
</ItemGroup >
38
38
39
- <ItemGroup >
40
- <EmbeddedResource Include =" ..\OpenApiTests\LegacyOpenApiIntegration\swagger.json" />
41
- </ItemGroup >
42
-
43
39
<!-- Fixes IntelliSense errors on openapi.json in Visual Studio 2019, which uses the schema for OpenAPI 3.1 by default. -->
44
40
<ProjectExtensions >
45
41
<VisualStudio >
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ public LegacyOpenApiIntegrationTests()
24
24
public async Task Retrieved_document_matches_expected_document ( )
25
25
{
26
26
// Arrange
27
- string embeddedResourceName = $ "{ nameof ( OpenApiTests ) } .{ nameof ( LegacyOpenApiIntegration ) } .swagger .json";
27
+ string embeddedResourceName = $ "{ nameof ( OpenApiTests ) } .SwaggerDocuments. { nameof ( LegacyOpenApiIntegration ) } .json";
28
28
string expectedDocument = await LoadEmbeddedResourceAsync ( embeddedResourceName ) ;
29
29
const string requestUrl = "swagger/v1/swagger.json" ;
30
30
Original file line number Diff line number Diff line change 1
1
using System ;
2
+ using System . IO ;
2
3
using System . Net . Http ;
3
4
using System . Text . Json ;
4
5
using System . Threading ;
@@ -22,8 +23,10 @@ public KebabCaseTests(IntegrationTestContext<KebabCaseNamingConventionStartup<Na
22
23
_lazyOpenApiDocument ??= new Lazy < Task < JsonDocument > > ( async ( ) =>
23
24
{
24
25
testContext . UseController < SupermarketsController > ( ) ;
25
- const string requestUrl = "swagger/v1/swagger.json" ;
26
- string content = await GetAsync ( requestUrl ) ;
26
+
27
+ string content = await GetAsync ( "swagger/v1/swagger.json" ) ;
28
+
29
+ await WriteToSwaggerDocumentsFolderAsync ( content ) ;
27
30
28
31
return JsonDocument . Parse ( content ) ;
29
32
} , LazyThreadSafetyMode . ExecutionAndPublication ) ;
@@ -39,6 +42,18 @@ private async Task<string> GetAsync(string requestUrl)
39
42
return await responseMessage . Content . ReadAsStringAsync ( ) ;
40
43
}
41
44
45
+ private static async Task WriteToSwaggerDocumentsFolderAsync ( string content )
46
+ {
47
+ string path = GetSwaggerDocumentPath ( nameof ( KebabCase ) ) ;
48
+ await File . WriteAllTextAsync ( path , content ) ;
49
+ }
50
+
51
+ private static string GetSwaggerDocumentPath ( string fileName )
52
+ {
53
+ string swaggerDocumentsDirectory = Directory . GetParent ( Environment . CurrentDirectory ) ! . Parent ! . Parent ! . FullName ;
54
+ return Path . Join ( swaggerDocumentsDirectory , "SwaggerDocuments" , $ "{ fileName } .json") ;
55
+ }
56
+
42
57
[ Fact ]
43
58
public async Task Kebab_naming_policy_is_applied_to_get_collection_endpoint ( )
44
59
{
Original file line number Diff line number Diff line change 4
4
</PropertyGroup >
5
5
6
6
<ItemGroup >
7
- <ProjectReference Include =" ..\..\src\JsonApiDotNetCore.OpenApi\JsonApiDotNetCore.OpenApi.csproj" />
8
- <ProjectReference Include =" ..\TestBuildingBlocks\TestBuildingBlocks.csproj" />
7
+ <ProjectReference Include =" ..\..\src\JsonApiDotNetCore.OpenApi\JsonApiDotNetCore.OpenApi.csproj" />
8
+ <ProjectReference Include =" ..\TestBuildingBlocks\TestBuildingBlocks.csproj" />
9
9
</ItemGroup >
10
10
11
11
<ItemGroup >
12
- <PackageReference Include =" coverlet.collector" Version =" $(CoverletVersion)" PrivateAssets =" All" />
13
- <PackageReference Include =" Microsoft.AspNetCore.Mvc.Testing" Version =" $(AspNetCoreVersion)" />
14
- <PackageReference Include =" Microsoft.NET.Test.Sdk" Version =" $(TestSdkVersion)" />
15
- <PackageReference Include =" BlushingPenguin.JsonPath" Version =" $(BlushingPenguinVersion)" />
16
- <PackageReference Include =" Microsoft.OpenApi.Readers" Version =" 1.2.3" />
12
+ <PackageReference Include =" coverlet.collector" Version =" $(CoverletVersion)" PrivateAssets =" All" />
13
+ <PackageReference Include =" Microsoft.AspNetCore.Mvc.Testing" Version =" $(AspNetCoreVersion)" />
14
+ <PackageReference Include =" Microsoft.NET.Test.Sdk" Version =" $(TestSdkVersion)" />
15
+ <PackageReference Include =" BlushingPenguin.JsonPath" Version =" $(BlushingPenguinVersion)" />
16
+ <PackageReference Include =" Microsoft.OpenApi.Readers" Version =" 1.2.3" />
17
17
</ItemGroup >
18
18
19
19
<ItemGroup >
20
- <EmbeddedResource Include =" LegacyOpenApiIntegration\swagger .json" />
20
+ <EmbeddedResource Include =" SwaggerDocuments\LegacyOpenApiIntegration .json" />
21
21
</ItemGroup >
22
-
22
+
23
23
<!-- Fixes IntelliSense errors on openapi.json in Visual Studio 2019, which uses the schema for OpenAPI 3.1 by default. -->
24
24
<ProjectExtensions >
25
25
<VisualStudio >
26
- <UserProperties swagger_1json__JsonSchema =" https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/schemas/v3.0/schema.json" />
26
+ <UserProperties swagger_1json__JsonSchema =" https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/schemas/v3.0/schema.json" />
27
27
</VisualStudio >
28
28
</ProjectExtensions >
29
29
</Project >
You can’t perform that action at this time.
0 commit comments