Hi,
I am using ASP.Net 5 Swagger for my API, works very good. For Authentication i want to use Oauth2 and tried to replicate the example:
services.AddSwaggerGen(c =>
{
c.AddSecurityDefinition("oauth2", new OAuth2Scheme
{
Type = "oauth2",
Flow = "implicit",
AuthorizationUrl = "http://petstore.swagger.io/api/oauth/dialog",
Scopes = new Dictionary<string, string>
{
{ "read", "read access" },
{ "write", "write access" }
}
});
c.OperationFilter<AssignSecurityRequirements>();
});
My project.json:
"Swashbuckle.SwaggerGen": "6.0.0-rc1-final",
"Swashbuckle.SwaggerUi": "6.0.0-rc1-final"
The example is working, but in my project the extension for services.AddSwaggerGen does not accept any argument. The using statement
using Swashbuckle.SwaggerGen.Generator;
The error is that SwaggerGen does not contain the namespace Generator.
Anything broken in the nuget package?
Confirming this issue in 6.0.0-rc1-final from nuget.
The following appears to do it... Doesn't match the samples for some reason, not sure what is the anticipated workflow going forward.
services.ConfigureSwaggerDocument(options =>
{
options.SingleApiVersion(new Info
{
Version = "v1",
Title = "<TITLE>",
Description = "<DESCRIPTION>"
});
options.SecurityDefinitions.Add("oauth2", new OAuth2Scheme {
Type = "oauth2",
Flow = "implicit",
AuthorizationUrl = "<URL>",
Scopes = new Dictionary<string, string> { { "full", "full control" } }
});
options.OperationFilter<AssignSecurityRequirements>();
});
services.ConfigureSwaggerSchema(options => {
options.DescribeAllEnumsAsStrings = true;
});
Yea, this is broken :(
Should be fixed in the 6.0.0-beta9 release.
not working !
Most helpful comment
Should be fixed in the 6.0.0-beta9 release.