From 75194bb878b7abc624fa2bb0ab3a8b789a53b236 Mon Sep 17 00:00:00 2001 From: Artem Azaraev Date: Tue, 24 Jun 2025 10:44:11 +0300 Subject: [PATCH 1/3] Add IgnoreResponseTypes option to OpenApiSpecGeneratorPlugin --- .../Generation/OpenApiSpecGeneratorPlugin.cs | 10 ++++++++++ schemas/v0.29.0/openapispecgeneratorplugin.schema.json | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/DevProxy.Plugins/Generation/OpenApiSpecGeneratorPlugin.cs b/DevProxy.Plugins/Generation/OpenApiSpecGeneratorPlugin.cs index 55e33bae..b5e4c96c 100644 --- a/DevProxy.Plugins/Generation/OpenApiSpecGeneratorPlugin.cs +++ b/DevProxy.Plugins/Generation/OpenApiSpecGeneratorPlugin.cs @@ -55,6 +55,7 @@ public sealed class OpenApiSpecGeneratorPluginConfiguration public bool IncludeOptionsRequests { get; set; } public SpecFormat SpecFormat { get; set; } = SpecFormat.Json; public SpecVersion SpecVersion { get; set; } = SpecVersion.v3_0; + public bool IgnoreResponseTypes { get; set; } } public sealed class OpenApiSpecGeneratorPlugin( @@ -416,6 +417,15 @@ private void SetResponseFromSession(OpenApiOperation operation, Response respons if (contentType.StartsWith("application/json", StringComparison.OrdinalIgnoreCase)) { Logger.LogDebug(" Processing JSON body..."); + if (Configuration.IgnoreResponseTypes) + { + Logger.LogDebug(" Ignoring response types"); + return new() + { + Type = "string", + }; + } + return GetSchemaFromJsonString(body); } diff --git a/schemas/v0.29.0/openapispecgeneratorplugin.schema.json b/schemas/v0.29.0/openapispecgeneratorplugin.schema.json index 44a862cc..77fe414f 100644 --- a/schemas/v0.29.0/openapispecgeneratorplugin.schema.json +++ b/schemas/v0.29.0/openapispecgeneratorplugin.schema.json @@ -11,6 +11,10 @@ "type": "boolean", "description": "Determines whether to include OPTIONS requests in the generated OpenAPI spec. Default: false." }, + "ignoreResponseTypes": { + "type": "boolean", + "description": "Determines whether to ignore response types in the generated OpenAPI spec. Default: false." + }, "specVersion": { "type": "string", "enum": [ From 76482581ccf50c4720f4f35a2bcb9b278dad9e0f Mon Sep 17 00:00:00 2001 From: Waldek Mastykarz Date: Wed, 2 Jul 2025 14:43:00 +0200 Subject: [PATCH 2/3] Moves schema changes to v1.0.0 --- schemas/v0.29.0/openapispecgeneratorplugin.schema.json | 4 ---- schemas/v1.0.0/openapispecgeneratorplugin.schema.json | 4 ++++ 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/schemas/v0.29.0/openapispecgeneratorplugin.schema.json b/schemas/v0.29.0/openapispecgeneratorplugin.schema.json index 77fe414f..44a862cc 100644 --- a/schemas/v0.29.0/openapispecgeneratorplugin.schema.json +++ b/schemas/v0.29.0/openapispecgeneratorplugin.schema.json @@ -11,10 +11,6 @@ "type": "boolean", "description": "Determines whether to include OPTIONS requests in the generated OpenAPI spec. Default: false." }, - "ignoreResponseTypes": { - "type": "boolean", - "description": "Determines whether to ignore response types in the generated OpenAPI spec. Default: false." - }, "specVersion": { "type": "string", "enum": [ diff --git a/schemas/v1.0.0/openapispecgeneratorplugin.schema.json b/schemas/v1.0.0/openapispecgeneratorplugin.schema.json index 44a862cc..77fe414f 100644 --- a/schemas/v1.0.0/openapispecgeneratorplugin.schema.json +++ b/schemas/v1.0.0/openapispecgeneratorplugin.schema.json @@ -11,6 +11,10 @@ "type": "boolean", "description": "Determines whether to include OPTIONS requests in the generated OpenAPI spec. Default: false." }, + "ignoreResponseTypes": { + "type": "boolean", + "description": "Determines whether to ignore response types in the generated OpenAPI spec. Default: false." + }, "specVersion": { "type": "string", "enum": [ From 6516b91234f95da8dfa4ae2a651a2e97a23fba4a Mon Sep 17 00:00:00 2001 From: Waldek Mastykarz Date: Wed, 2 Jul 2025 14:44:59 +0200 Subject: [PATCH 3/3] Removes dangling comma --- DevProxy.Plugins/Generation/OpenApiSpecGeneratorPlugin.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DevProxy.Plugins/Generation/OpenApiSpecGeneratorPlugin.cs b/DevProxy.Plugins/Generation/OpenApiSpecGeneratorPlugin.cs index b5e4c96c..31382748 100644 --- a/DevProxy.Plugins/Generation/OpenApiSpecGeneratorPlugin.cs +++ b/DevProxy.Plugins/Generation/OpenApiSpecGeneratorPlugin.cs @@ -422,7 +422,7 @@ private void SetResponseFromSession(OpenApiOperation operation, Response respons Logger.LogDebug(" Ignoring response types"); return new() { - Type = "string", + Type = "string" }; }