azure-functions-openapi-extension icon indicating copy to clipboard operation
azure-functions-openapi-extension copied to clipboard

Documentation: Update .ConfigureFunctionsWorkerDefaults(...) to be .ConfigureFunctionsWebApplication(...)

Open throwaway34059 opened this issue 1 year ago • 0 comments

In the documentation

It says to use:

namespace MyOpenApiFunctionApp
{
    public class Program
    {
        public static void Main()
        {
            var host = new HostBuilder()
            // Remove this line below
                .ConfigureFunctionsWorkerDefaults()
            // Remove this line above

            // Add these lines below
                .ConfigureFunctionsWorkerDefaults(worker => worker.UseNewtonsoftJson())
            // Add these lines above
                .Build();

            host.Run();
        }
    }
}

I guess newer versions of Azure Functions it should be:

.ConfigureFunctionsWebApplication(worker => worker.UseNewtonsoftJson())

This is mentioned in #629 but it's subtle and not the focus of that ticket. It took me a several tries and a couple hours to realize the documentation does not meet the scaffold of the function.

If you replace the line in the scaffold with documented version of things your get a 200 OK white screen.

throwaway34059 avatar Mar 01 '24 20:03 throwaway34059