Beispiel #1
0
        private static void AddSwaggerApiVersionDescriptions(IServiceCollection services, Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenOptions options)
        {
            var provider = services.BuildServiceProvider()
                           .GetRequiredService <IApiVersionDescriptionProvider>();

            // add a swagger document for each discovered API version
            // note: you might choose to skip or document deprecated API versions differently

            foreach (var description in provider.ApiVersionDescriptions)
            {
                options.SwaggerDoc(description.GroupName, new OpenApiInfo()
                {
                    Version     = description.GroupName,
                    Title       = "ChummerHub",
                    Description = "Description for API " + description.GroupName + " to store and search Chummer Xml files",
                    Contact     = new OpenApiContact
                    {
                        Name  = "Archon Megalon",
                        Email = "*****@*****.**",
                    },
                    License = new OpenApiLicense
                    {
                        Name = "License",
                        Url  = new Uri("https://github.com/chummer5a/chummer5a/blob/master/LICENSE.txt"),
                    }
                });
            }
        }
Beispiel #2
0
        internal static void AddSwaggerAuthorizeBearer(this Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenOptions x)
        {
            x.SwaggerDoc("v1", new OpenApiInfo
            {
                Version = "v1",
                Title   = "OnlineShop Api"
            });
            x.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme
            {
                Name         = "Authorization",
                In           = ParameterLocation.Header,
                Type         = SecuritySchemeType.ApiKey,
                Scheme       = "Bearer",
                BearerFormat = "JWT",
                Description  =
                    "Input your Bearer token in this format - Bearer {your token here} to access this API",
            });

            x.AddSecurityRequirement(new OpenApiSecurityRequirement
            {
                {
                    new OpenApiSecurityScheme
                    {
                        Reference = new OpenApiReference
                        {
                            Type = ReferenceType.SecurityScheme,
                            Id   = "Bearer",
                        },
                        Scheme = "Bearer",
                        Name   = "Bearer",
                        In     = ParameterLocation.Header,
                    }, new List <string>()
                },
            });
        }
Beispiel #3
0
        private void SetupSwaggerGen(Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenOptions options)
        {
            var info = new OpenApiInfo {
                Title = "My API", Version = "v1"
            };

            options.SwaggerDoc("v1", info);
        }
Beispiel #4
0
        private void SwaggerConfugure(Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenOptions options)
        {
            options.SwaggerDoc("v1", new Info
            {
                Version = "v1",
                Title   = "NHlsOnDemand"
            });

            //Determine base path for the application.
            var basePath = PlatformServices.Default.Application.ApplicationBasePath;

            //Set the comments path for the swagger json and ui.
            options.IncludeXmlComments(Path.Combine(basePath, "NHlsOnDemand.xml"));

            options.MapType <Guid>(() => new Schema {
                Type = "string", Format = "uuid", Example = Guid.NewGuid()
            });
            options.MapType <Uri>(() => new Schema {
                Type = "uri", Format = "uri", Example = "http://example.com/source/id"
            });
        }