ApiVersioning + Swagger + ApplicationService not working
See original GitHub issueHi I try to use ApiVersioning for dynamic web api But this doesn’t work reference:https://github.com/microsoft/aspnet-api-versioning/blob/master/samples/aspnetcore/SwaggerSample/Startup.cs
ApplicationService
[ApiVersion("1.0")]
public class TestAppService: ApplicationService, ITestAppService
{
public Task<string> Get()
{
return Task.FromResult("Test");
}
}
Startup.cs
services.AddApiVersioning(options =>
{
options.ReportApiVersions = true;
options.ApiVersionReader = new HeaderApiVersionReader("Api-Version");
options.AssumeDefaultVersionWhenUnspecified = true;
options.DefaultApiVersion = new ApiVersion(1, 0);
});
services.AddVersionedApiExplorer(options =>
{
options.AssumeDefaultVersionWhenUnspecified = true;
options.DefaultApiVersion = new ApiVersion(1, 0);
options.GroupNameFormat = "'v'VVV";
});
apiVersioning and swagger cannot find TestAppService on abp 5.5.0.0
Issue Analytics
- State:
- Created 3 years ago
- Comments:16 (6 by maintainers)
Top Results From Across the Web
Swagger versioning is not working. It displays all endpoints ...
I need to create an endpoint for the new version of API and with the same route as a previous version. My controller...
Read more >Troubleshooting issues when using Swagger as a REST API ...
This error can occur in the following circumstances: Syntax errors in the index.html file, located in /swagger/dist/ folder. The variable URL ...
Read more >How to Swagger API Versioning in ASP.NET Core
In this article, let's see how we can dynamically integrate Swagger UI documentation, for all the API versions available in our ASP.
Read more >2. Making Swagger work with API versioning - YouTube
Small problem - Swagger not working with version APIs : 00:18 3. ... Configuring Swagger services using IOptions pattern: 05:04 5.
Read more >Set up Swagger and API versioning in .NET 5 web API
API versioning and Swagger goes hand in hand when developing APIs. Learn how to easily set it up.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @vcluopeng thanks for answering.
Hi @ismcagdas,
I managed to add API versioning to asp.net Zero. If you think there is more easier or better way to achieve this, I would happy to here. If you think it is ok, can we have this as part of documentation of asp.net zero (.netcore + angular)
File
ProjectName.Web.Host\startup\startup.cs
methodConfigureServices
changed related code to this:File
ProjectName.Web.Host\startup\startup.cs
inConfigure
method changed code to this:File
ProjectName.Web.Core.ProjectNameCoreModule.cs
InPreInitialize
method changed code to this:Comment or remove following lines
And add these line to be able adding apppservice as controller with version in url:
Change appsettingjson.json
Add version Info to AppService or methods:
Note: To get latest APı methods in nswag In file
ProjectName.Web.Host\nswag\service.config.nswag
change following:"url": "https://localhost:44301/swagger/v1/swagger.json",
-->"url": "https://localhost:44301/swagger/v1.0/swagger.json",
Or change to desired version"url": "https://localhost:44301/swagger/v3.0/swagger.json",
Now versioning works as expected.
V1
V2
V3
@sajasbana Unfortunately I couldn’t create sample project because of time. But I have added all steps in this comment. May this can help you.