Skip to content

Commit e07d6ab

Browse files
Remove --serializeasv2
Remove deprecated `--serializeasv2` option.
1 parent ca6e376 commit e07d6ab

File tree

2 files changed

+0
-49
lines changed

2 files changed

+0
-49
lines changed

src/Swashbuckle.AspNetCore.Cli/Program.cs

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ namespace Swashbuckle.AspNetCore.Cli;
1717
internal class Program
1818
{
1919
private const string OpenApiVersionOption = "--openapiversion";
20-
private const string SerializeAsV2Flag = "--serializeasv2";
2120

2221
public static int Main(string[] args)
2322
{
@@ -41,9 +40,6 @@ public static int Main(string[] args)
4140
c.Option(OpenApiVersionOption, "output Swagger in the specified version, defaults to 3.0");
4241
c.Option("--yaml", "exports swagger in a yaml format", true);
4342

44-
// TODO Remove this option in the major version that adds support for OpenAPI 3.1
45-
c.Option(SerializeAsV2Flag, "output Swagger in the V2 format rather than V3 [deprecated]", true);
46-
4743
c.OnRun((namedArgs) =>
4844
{
4945
string subProcessCommandLine = PrepareCommandLine(args, namedArgs);
@@ -66,9 +62,6 @@ public static int Main(string[] args)
6662
c.Option(OpenApiVersionOption, "");
6763
c.Option("--yaml", "", true);
6864

69-
// TODO Remove this option in the major version that adds support for OpenAPI 3.1
70-
c.Option(SerializeAsV2Flag, "", true);
71-
7265
c.OnRun((namedArgs) =>
7366
{
7467
SetupAndRetrieveSwaggerProviderAndOptions(namedArgs, out var swaggerProvider, out var swaggerOptions);
@@ -116,11 +109,6 @@ public static int Main(string[] args)
116109
_ => throw new NotSupportedException($"The specified OpenAPI version \"{versionArg}\" is not supported."),
117110
};
118111
}
119-
else if (namedArgs.ContainsKey(SerializeAsV2Flag))
120-
{
121-
specVersion = OpenApiSpecVersion.OpenApi2_0;
122-
WriteSerializeAsV2DeprecationWarning();
123-
}
124112

125113
if (swaggerDocumentSerializer != null)
126114
{
@@ -328,20 +316,4 @@ private static bool TryGetCustomHost<THost>(
328316
host = (THost)factoryMethod.Invoke(null, null);
329317
return true;
330318
}
331-
332-
private static void WriteSerializeAsV2DeprecationWarning()
333-
{
334-
const string AppName = "Swashbuckle.AspNetCore.Cli";
335-
336-
string message = $"The {SerializeAsV2Flag} flag will be removed in a future version of {AppName}. Use the {OpenApiVersionOption} option instead.";
337-
338-
Console.WriteLine(message);
339-
340-
// See https://docs.github.com/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions#setting-a-warning-message
341-
// and https://docs.github.com/actions/writing-workflows/choosing-what-your-workflow-does/store-information-in-variables#default-environment-variables
342-
if (Environment.GetEnvironmentVariable("GITHUB_ACTIONS") is "true")
343-
{
344-
Console.WriteLine($"::warning title={AppName}::{message}");
345-
}
346-
}
347319
}

test/Swashbuckle.AspNetCore.Cli.Test/ToolTests.cs

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -69,27 +69,6 @@ public static void Can_Generate_Swagger_Json_v2_OpenApiVersion()
6969
Assert.True(productsPath.TryGetProperty("post", out _));
7070
}
7171

72-
[Fact]
73-
public static void Can_Generate_Swagger_Json_v2_SerializeAsV2()
74-
{
75-
using var document = RunToJsonCommand((outputPath) =>
76-
[
77-
"tofile",
78-
"--output",
79-
outputPath,
80-
"--serializeasv2",
81-
Path.Combine(Directory.GetCurrentDirectory(), "Basic.dll"),
82-
"v1"
83-
]);
84-
85-
Assert.Equal("2.0", document.RootElement.GetProperty("swagger").GetString());
86-
87-
// verify one of the endpoints
88-
var paths = document.RootElement.GetProperty("paths");
89-
var productsPath = paths.GetProperty("/products");
90-
Assert.True(productsPath.TryGetProperty("post", out _));
91-
}
92-
9372
[Fact]
9473
public static void Can_Generate_Swagger_Json_v3()
9574
{

0 commit comments

Comments
 (0)