public IDocument AddServer()

in src/Microsoft.Azure.WebJobs.Extensions.OpenApi/Document.cs [73:107]


        public IDocument AddServer(IHttpRequestDataObject req, string routePrefix, IOpenApiConfigurationOptions options = null)
        {
            this._req = req;

            var prefix = string.IsNullOrWhiteSpace(routePrefix) ? string.Empty : $"/{routePrefix}";
            var baseUrl = $"{this._req.GetScheme(options)}://{this._req.Host}{prefix}";

            var server = new OpenApiServer { Url = baseUrl };

            if (options.IsNullOrDefault())
            {
                this.OpenApiDocument.Servers = new List<OpenApiServer>() { server };

                return this;
            }

            // Filters out the existing base URLs that are the same as the current host URL.
            var servers = options.Servers
                                 .Where(p => p.Url.TrimEnd('/') != baseUrl.TrimEnd('/'))
                                 .ToList();
            if (!servers.Any())
            {
                servers.Insert(0, server);
            }

            if (options.IncludeRequestingHostName
                && !servers.Any(p => p.Url.TrimEnd('/') == baseUrl.TrimEnd('/')))
            {
                servers.Insert(0, server);
            }

            this.OpenApiDocument.Servers = servers;

            return this;
        }