![]() Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.), specifying the Swagger JSON endpoint.Ĭ.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1") Īs we are done, we have to run the application using the following command: Navigate to the configure method of Startup.cs and add the following code Step 3: Letting the middleware know about the swagger UI and the endpoint information Now add using so that compiler could know from the where the reference of Info class should be taken. Public void ConfigureServices(IServiceCollection services)Ĭ.SwaggerDoc("v1", new Info ) Now we have to modify the ConfigureServices Method Step 2: Add & Configure Swagger to Middleware NET Core CLI or console and run the following commandĭotnet add TodoApi.csproj package Swashbuckle.AspNetCore This will create a webapi project without swagger added.ĭirectory Structure will look something like below NET CLI or console and write the following command Today I’ll be taking you through the steps through which we can add swagger in our Web API But this is also as straightforward as Visual Studio. In the last couple of days, I was checking a few developers are facing some issues while adding swagger to their web API’s when they are creating it from the VS Code environment.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |