示例#1
0
        /// <summary>
        /// Gets the COLID Swagger Options from AppSettings.
        /// </summary>
        /// <exception cref="ArgumentNullException">If the options are not set.</exception>
        /// <param name="configuration">key/value application configuration properties</param>
        /// <returns>configuration for swagger</returns>
        private static ColidSwaggerOptions ParseColidSwaggerOptions(IConfiguration configuration)
        {
            Guard.ArgumentNotNull(configuration.GetSection("ColidSwaggerOptions"), "Configuration:ColidSwaggerOptions");
            var colidSwaggerOptions = new ColidSwaggerOptions();

            configuration.Bind(nameof(ColidSwaggerOptions), colidSwaggerOptions);

            return(colidSwaggerOptions);
        }
示例#2
0
        private static string CreateOpenApiInfoDescription(ColidSwaggerOptions colidSwaggerOptions)
        {
            var description = $"The {colidSwaggerOptions.EnvironmentLabel} API of COLID (Corporate Linked Data).";

            if (!string.IsNullOrWhiteSpace(colidSwaggerOptions.DocumentationApiUrl))
            {
                description += $"<br>Also see <b><a href='{colidSwaggerOptions.DocumentationUrl}'>API Documentation</a></b>";
            }

            description += $"<br><br><b>Note:</b>You need to authorize using the Authorize button prior using!";
            return(description);
        }
示例#3
0
        /// <summary>
        /// Generates the Open API Info for the Swagger documentation page.
        /// </summary>
        /// <param name="colidSwaggerOptions">the configuration for the Swagger module</param>
        /// <param name="version">The current version the Open API Info is for.</param>
        /// <returns>Open API Info Object, it provides the metadata about the Open API.</returns>
        private static OpenApiInfo GetSwaggerInformation(ColidSwaggerOptions colidSwaggerOptions, string version)
        {
            var description = CreateOpenApiInfoDescription(colidSwaggerOptions);
            var serviceName = GetServiceName();

            return(new OpenApiInfo
            {
                Version = version,
                Title = $"COLID {serviceName} API {colidSwaggerOptions.EnvironmentLabel}",
                Description = description,
                Contact = new OpenApiContact
                {
                    Name = "Contact COLID team",
                    Email = colidSwaggerOptions.ContactEmail,
                    Url = new Uri(colidSwaggerOptions.DocumentationUrl)
                },
            });
        }