Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid competing swagger generation during test build #2897

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
2 changes: 1 addition & 1 deletion test/Swashbuckle.AspNetCore.Cli.Test/ToolTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public void Can_Generate_Swagger_Json()
Assert.True(productsPath.TryGetProperty("post", out _));
}

[Fact(Skip = "Disabled because it makes CI unstable")]
[Fact]
public void Overwrites_Existing_File()
{
using var temporaryDirectory = new TemporaryDirectory();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class SwaggerIntegrationTests
{
[Theory]
[InlineData(typeof(Basic.Startup), "/swagger/v1/swagger.json")]
[InlineData(typeof(CliExample.Startup), "/swagger/v1/swagger.json")]
[InlineData(typeof(CliExample.Startup), "/swagger/v1/swagger_net8.0.json")]
[InlineData(typeof(ConfigFromFile.Startup), "/swagger/v1/swagger.json")]
[InlineData(typeof(CustomUIConfig.Startup), "/swagger/v1/swagger.json")]
[InlineData(typeof(CustomUIIndex.Startup), "/swagger/v1/swagger.json")]
Expand Down
2 changes: 1 addition & 1 deletion test/WebSites/CliExample/CliExample.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
-->

<Target Name="SwaggerToFile" AfterTargets="AfterBuild">
<Exec Command="dotnet dotnet-swagger.dll tofile --host http://localhost:51071 --output %22$(MSBuildThisFileDirectory)wwwroot/swagger/v1/swagger.json%22 %22$(OutputPath)$(AssemblyName).dll%22 v1"
<Exec Command="dotnet dotnet-swagger.dll tofile --host http://localhost:51071 --output %22$(MSBuildThisFileDirectory)wwwroot/swagger/v1/swagger_$(TargetFramework).json%22 %22$(OutputPath)$(AssemblyName).dll%22 v1"
WorkingDirectory="$(DotNetSwaggerPath)" />
</Target>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@
}
}
}
}
}
54 changes: 54 additions & 0 deletions test/WebSites/CliExample/wwwroot/swagger/v1/swagger_net7.0.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"openapi": "3.0.1",
"info": {
"title": "CliExample",
"version": "1.0"
},
"servers": [
{
"url": "http://localhost:51071"
}
],
"paths": {
"/products": {
"get": {
"tags": [
"Products"
],
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Product"
}
}
}
}
}
}
}
}
},
"components": {
"schemas": {
"Product": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int32"
},
"description": {
"type": "string",
"nullable": true
}
},
"additionalProperties": false
}
}
}
}
54 changes: 54 additions & 0 deletions test/WebSites/CliExample/wwwroot/swagger/v1/swagger_net8.0.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"openapi": "3.0.1",
"info": {
"title": "CliExample",
"version": "1.0"
},
"servers": [
{
"url": "http://localhost:51071"
}
],
"paths": {
"/products": {
"get": {
"tags": [
"Products"
],
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Product"
}
}
}
}
}
}
}
}
},
"components": {
"schemas": {
"Product": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int32"
},
"description": {
"type": "string",
"nullable": true
}
},
"additionalProperties": false
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
-->

<Target Name="SwaggerToFile" AfterTargets="AfterBuild">
<Exec Command="dotnet dotnet-swagger.dll tofile --host http://localhost:57556/ --output %22$(MSBuildThisFileDirectory)wwwroot/swagger/v1/swagger.json%22 %22$(OutputPath)$(AssemblyName).dll%22 v1"
<Exec Command="dotnet dotnet-swagger.dll tofile --host http://localhost:57556/ --output %22$(MSBuildThisFileDirectory)wwwroot/swagger/v1/swagger_$(TargetFramework).json%22 %22$(OutputPath)$(AssemblyName).dll%22 v1"
WorkingDirectory="$(DotNetSwaggerPath)" />
</Target>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"openapi": "3.0.1",
"info": {
"title": "CliExampleWithFactory",
"version": "1.0"
},
"servers": [
{
"url": "http://localhost:57556/"
}
],
"paths": {
"/products": {
"get": {
"tags": [
"Products"
],
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Product"
}
}
}
}
}
}
}
}
},
"components": {
"schemas": {
"Product": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int32"
},
"description": {
"type": "string",
"nullable": true
}
},
"additionalProperties": false
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"openapi": "3.0.1",
"info": {
"title": "CliExampleWithFactory",
"version": "1.0"
},
"servers": [
{
"url": "http://localhost:57556/"
}
],
"paths": {
"/products": {
"get": {
"tags": [
"Products"
],
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Product"
}
}
}
}
}
}
}
}
},
"components": {
"schemas": {
"Product": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int32"
},
"description": {
"type": "string",
"nullable": true
}
},
"additionalProperties": false
}
}
}
}
4 changes: 2 additions & 2 deletions test/WebSites/NswagClientExample/NswagClientExample.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
</ItemGroup>

<Target Name="SwaggerToFile" AfterTargets="AfterBuild">
<Exec Command="dotnet dotnet-swagger.dll tofile --host http://example.com --output %22$(MSBuildThisFileDirectory)swagger.json%22 %22$(OutputPath)$(AssemblyName).dll%22 v1"
<Exec Command="dotnet dotnet-swagger.dll tofile --host http://example.com --output %22$(MSBuildThisFileDirectory)swagger_$(TargetFramework).json%22 %22$(OutputPath)$(AssemblyName).dll%22 v1"
WorkingDirectory="$(DotNetSwaggerPath)" />
</Target>

<Target Name="NSwag" AfterTargets="SwaggerToFile">
<Exec Command="$(_NSwagTool) openapi2csclient /input:swagger.json /namespace:NSwagClient /output:NSwagClient/Client.cs" />
<Exec Command="$(_NSwagTool) openapi2csclient /input:swagger_$(TargetFramework).json /namespace:NSwagClient /output:NSwagClient/Client.cs" />
</Target>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,4 @@
}
}
}
}
}
Loading
Loading