[Swagger] FormatGroupName generates an extra ApiVersionDescription #1036
Replies: 1 comment
-
Your configuration looks correct to me. I configured a similar setup using the OpenAPI example with the following changes: Added: [ApiVersion(1.0)]
[Route( "api/[controller]" )]
public class ValuesController : ControllerBase
{
[HttpGet]
public IActionResult Get() => Ok();
} Changed: [ApiVersion( 1.0 )]
[ApiVersion( 0.9, Deprecated = true )]
[ApiExplorerSettings( GroupName = "Orders" )]
[Route( "api/[controller]" )]
public class OrdersController : ControllerBase
{
// omitted for brevity
} [ApiVersion( 1.0 )]
[ApiVersion( 0.9, Deprecated = true )]
[ApiExplorerSettings( GroupName = "People" )]
[Route( "api/v{version:apiVersion}/[controller]" )]
public class PeopleController : ControllerBase
{
// omitted for brevity
} .AddApiExplorer(
options =>
{
options.GroupNameFormat = "'v'VVV";
options.SubstituteApiVersionInUrl = true;
options.FormatGroupName = ( group, version ) => $"{group}-{version}";
} ); which produces the following:
Everything else is unchanged. That is what I would expect. I see that you're still using the older Sidebar
|
Beta Was this translation helpful? Give feedback.
-
I am using the latest version of the ApiExplorer (v7.1) and I am currently attempting to have different swagger documents for different controllers but also have versioning in addition to that.
I have these two controllers:
I define my ApiExplorer as such:
But then, inside of the my
Startup.cs
'sConfigureServices
function, I loop through the api versions:And end up with three Swagger documents with group names:
account-v1
,admin-v1
andv1
The weird part is that, after that in the
Configure
method of theStartup.cs
file, I callUseSwaggerUI
and define my endpoints like the following:But only my two documents show up in the loop, i.e.
account-v1
andadmin-v1
.So in other words, three swagger documents are created but only two of them are linked to endpoints in the UI.
Is this expected behavior?
Beta Was this translation helpful? Give feedback.
All reactions