小编Has*_*hah的帖子

如何更改swagger文档基本URL?

一切都在本地很好用,但我想改变localhost:portNumber一些域名.这样我就可以从任何地方访问它,而不仅仅是咨询我的本地机器.我没有找到任何有助于在全球范围内访问swagger文档的帮助.请帮我指定我的网址 我想将我的localhost:xyzportNumber更改为某个域名url,以便我可以在线访问我的api文档. 目前一切都在当地工作,但我不知道如何更改基本网址. 这是我的swashbuckle版本

public class SwaggerConfig
{
    protected static string GetXmlCommentsPath()
    {
        return System.String.Format(@"{0}\bin\GenericAPI.XML",               System.AppDomain.CurrentDomain.BaseDirectory);
    }

    public static void Register()
    {
        var thisAssembly = typeof(SwaggerConfig).Assembly;

        GlobalConfiguration.Configuration
        .EnableSwagger(c =>
         {
             c.SingleApiVersion("v1", "GenericAPI");

            c.IncludeXmlComments(string.Format(@"{0}\bin\GenericAPI.XML",
            System.AppDomain.CurrentDomain.BaseDirectory));
           }).EnableSwaggerUi();

        //GlobalConfiguration.Configuration 
        //    .EnableSwagger(c =>
        //        {
        //            // By default, the service root url is inferred from the request used to access the docs.
        //            // However, there may be situations (e.g. proxy and load-balanced environments) where this does not
        //            // resolve correctly. You can …
Run Code Online (Sandbox Code Playgroud)

asp.net api base-url swagger swashbuckle

8
推荐指数
2
解决办法
1万
查看次数

标签 统计

api ×1

asp.net ×1

base-url ×1

swagger ×1

swashbuckle ×1