Swagger not generating Web API 2.0 document when code deployed on Azure App service

Viewed 84
  1. Swagger, generating documents perfectly on localhost for web api 2.0 application
  2. Swagger, does not generating documents on Azure App service having pay as you go subscription

Could you please suggest any related configuration around azure app service for swagger.

enter image description here

[assembly: PreApplicationStartMethod(typeof(SwaggerConfig), "Register")]
 public class SwaggerConfig
{
    public static void Register()
    {
        var thisAssembly = typeof(SwaggerConfig).Assembly;

        GlobalConfiguration.Configuration
            .EnableSwagger(c =>
            {
                c.SingleApiVersion("v1", "FFX WebAPI");
                c.OperationFilter<AuthorizationOperationFilter>();
                c.PrettyPrint();
               
            })
            .EnableSwaggerUi(c =>
            {
                c.DocumentTitle("FFX WebAPI");
                c.SupportedSubmitMethods(!int.TryParse(ConfigurationManager.AppSettings["Environment"],out int result) || result != 4 ? new string[] { "Get", "Post" }: new string[] { });
            });
    }
}

    public class AuthorizationOperationFilter : IOperationFilter
{
    public void Apply(Operation operation, SchemaRegistry schemaRegistry, ApiDescription apiDescription)
    {
        if (operation.parameters == null)
        {
            operation.parameters = new List<Parameter>();
        }
        operation.parameters.Add(new Parameter
        {
            name = ApplicationConstants.Token,
            @in = "header",
            description = "enter token",
            required = false, 
            type = "string"
        });
    }
}
1 Answers
#if DEBUG
    [ApiExplorerSettings(IgnoreApi = false)]
#else
    [ApiExplorerSettings(IgnoreApi = false)]
#endif

In controller file : Need to check whether explore API settings is enable or disable in build debug and release mode.

Related