diff --git a/DevProxy.Plugins/Generation/OpenApiSpecGeneratorPlugin.cs b/DevProxy.Plugins/Generation/OpenApiSpecGeneratorPlugin.cs index 55e33bae..31382748 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/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": [