Skip to content

Add IgnoreResponseTypes option to OpenApiSpecGeneratorPlugin #1266

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

Merged
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
10 changes: 10 additions & 0 deletions DevProxy.Plugins/Generation/OpenApiSpecGeneratorPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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);
}

Expand Down
4 changes: 4 additions & 0 deletions schemas/v1.0.0/openapispecgeneratorplugin.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down