在Swashbuckle中的哪里设置API主机架构?

时间:2019-07-02 20:13:01

标签: swagger swashbuckle

我正在尝试找出如何解决Swagger在STAGE和PROD服务器上显示的问题。我相信我的问题是我们拥有使用HTTPS到达的Load Balancer,但是一旦到达那里,所有站点都将通过HTTP服务。我相信这就是我得到的原因

  

无法从服务器读取。它可能没有适当的访问控制源设置。

所以我在Swagger上找到了以下内容,我想我只需要将Schema设置为HTTP,但是我不确定100%在哪里进行此更改?是否将其添加到SwaggerConfig.cs文件中? https://swagger.io/docs/specification/2-0/api-host-and-base-path/

这是我的SwaggerConfig.cs文件中的内容:

public class SwaggerConfig
    {
        //public static void Register(HttpConfiguration config)
        public static void Register()
        {    
            var thisAssembly = typeof(SwaggerConfig).Assembly;

            GlobalConfiguration.Configuration
                .EnableSwagger(c =>
                {
                    c.ApiKey("Api-Token")
                        .Description("API Key for accessing secure APIs")
                        .Name("Api-Token")
                        .In("header");

                    c.SingleApiVersion("v1", "WorkdayAPI");
                    c.IncludeXmlComments(string.Format(@"{0}\bin\WorkdayApi.XML",
                       System.AppDomain.CurrentDomain.BaseDirectory));

                    // If you want the output Swagger docs to be indented properly, enable the "PrettyPrint" option.
                    c.PrettyPrint();

                })
                .EnableSwaggerUi(c =>
                {
                    // If your API supports ApiKey, you can override the default values.
                    // "apiKeyIn" can either be "query" or "header
                    c.EnableApiKeySupport("Api-Token", "header");
                });
        }
    }

0 个答案:

没有答案
相关问题