Azure / azure-functions-openapi-extension

This extension provides an Azure Functions app with Open API capability for better discoverability to consuming parties
https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.OpenApi/
MIT License
370 stars 194 forks source link

Swagger Serializer Settings #652

Open jnoren1 opened 5 months ago

jnoren1 commented 5 months ago

Describe the issue I cannot find anywhere that allows me to set the settings or even which serializer swagger uses to serialize my objects. I utilize custom serializer settings (Newtonsoft) that send my objects differently depending on the destination. In my application these settings change the output or even hide fields.

For example, to a database, I may want ENUMs to use numbers for storage, but for APIs (and swagger) I would want strings. Or I may want some fields exposed for different levels of authentication for a publicly available API. Decorating functions won't work because the I need the behavior to change at runtime.

I've seen the following as recommendation in the issues, but this seems to have no effect whatsoever. Sadly I've not been able to find anything else in the documentation.

var host = new HostBuilder()
    .ConfigureFunctionsWebApplication(builder =>
    {
        builder.UseNewtonsoftJson();
    })
    .Build();
host.Run();

The Question What serializer is used by swagger/openapi? How can one alter the settings and add customer converters?