Skip to content

OpenApiSecurityScheme for auth token input field in interactive swagger UI documentation #35903

@khteh

Description

@khteh

Description

I don't see OpenApiSecurityScheme which allows Swashbuckle.AspNetCore.SwaggerUI interactive documentation to add authentication token after logging in to use protected resources. Previously:

    builder.Services.AddSwaggerGen(c =>
    {
        c.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme
        {
            Scheme = "Bearer",
            In = ParameterLocation.Header,
            Description = "Please insert JWT with Bearer into field",
            Name = "Authorization",
            Type = SecuritySchemeType.ApiKey
        });
    }

Page URL

https://learn.microsoft.com/en-us/aspnet/core/fundamentals/openapi/aspnetcore-openapi?view=aspnetcore-9.0&tabs=visual-studio%2Cvisual-studio-code

Content source URL

https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/fundamentals/openapi/aspnetcore-openapi.md

Document ID

27bad30c-e0b4-10fb-b202-a29d4f8fad24

Platform Id

11e029f8-4c25-d943-fe65-31bfcaf35e2b

Article author

@captainsafia

Metadata

  • ID: 27bad30c-e0b4-10fb-b202-a29d4f8fad24
  • PlatformId: 11e029f8-4c25-d943-fe65-31bfcaf35e2b
  • Service: aspnet-core
  • Sub-service: fundamentals

Related Issues

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions