Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation C# to VB.NET (I can't translate a required function) #2557

Closed
ghost opened this issue Nov 25, 2022 · 1 comment
Closed

Documentation C# to VB.NET (I can't translate a required function) #2557

ghost opened this issue Nov 25, 2022 · 1 comment

Comments

@ghost
Copy link

ghost commented Nov 25, 2022

Good day,

I have tried to translate the existing Swashbuckle c# documentation to vb.net.
I need the "authentication" button to appear on the swagger documentation page.
The fact is that in the documentation found for C# the following function appears:

`
services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new OpenApiInfo
{
Version = "v1",
Title = "API Auth",
Description = "A simple demo with JWT Auth APIs and Basic Auth APIs",
Contact = new OpenApiContact
{
Name = @"GitHub Repository",
Email = string.Empty,
Url = new Uri("https://XXX/X")
}
});
var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
c.IncludeXmlComments(xmlPath, true);

            // add JWT Authentication
            var securityScheme = new OpenApiSecurityScheme
            {
                Name = "JWT Authentication",
                Description = "Enter JWT Bearer token **_only_**",
                In = ParameterLocation.Header,
                Type = SecuritySchemeType.Http,
                Scheme = "bearer", // must be lower case
                BearerFormat = "JWT",
                Reference = new OpenApiReference
                {
                    Id = JwtBearerDefaults.AuthenticationScheme,
                    Type = ReferenceType.SecurityScheme
                }
            };
            c.AddSecurityDefinition(securityScheme.Reference.Id, securityScheme);
            c.AddSecurityRequirement(new OpenApiSecurityRequirement
            {
                {securityScheme, new string[] { }}
            });

            // add Basic Authentication
            var basicSecurityScheme = new OpenApiSecurityScheme
            {
                Type = SecuritySchemeType.Http,
                Scheme = "basic",
                Reference = new OpenApiReference { Id = "BasicAuth", Type = ReferenceType.SecurityScheme }
            };
            c.AddSecurityDefinition(basicSecurityScheme.Reference.Id, basicSecurityScheme);
            c.AddSecurityRequirement(new OpenApiSecurityRequirement
            {
                {basicSecurityScheme, new string[] { }}
            });
        });

`

I have not found the way to access "services"

The global files of my API are:

/global.asax
/App_Start/WebApiConfig.vb

Thank you for your time

@martincostello
Copy link
Collaborator

Closing as the OP has deleted their GitHub account so there's no way to answer them.

@martincostello martincostello closed this as not planned Won't fix, can't repro, duplicate, stale Apr 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant