---
title: "Discussion on \"Designing REST APIs in .NET 5\" | Hashnode"
description: "Discussion on \"Designing REST APIs in .NET 5\". Learn best practice such as  Configuring Swagger, API Versioning, use of DTOs, and Repository Pattern."
url: "https://hashnode.com/posts/designing-rest-apis-in-net-5/6027f954e522c1626f3723bd"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Designing REST APIs in .NET 5](https://kemicaldev.hashnode.dev/designing-rest-apis-in-net-5?utm_source=hashnode&utm_medium=feed)

Learn best practice such as Configuring Swagger, API Versioning, use of DTOs, and Repository Pattern.

Feb 13, 2021 · 11 min read · kemicaldev.hashnode.dev  
Updated Feb 15, 2021  
Read the article

-   [#aspnet-core](https://hashnode.com/tag/aspnet-core)
-   [#net-core](https://hashnode.com/tag/net-core)
-   [#rest-api](https://hashnode.com/tag/rest-api)
-   [#web-api](https://hashnode.com/tag/web-api)
-   [#crud](https://hashnode.com/tag/crud)

## Written by

[Gabriel](https://hashnode.com/@Overdosengine)

@Overdosengine · Uyo, Nigeria

  
[View profile](https://hashnode.com/@Overdosengine)

Software Developer

I am Gabriel, a software developer from Uyo, Nigeria. I'm a graduate of Chemical Engineering but my passion for tech led me into a career in software development.

## Responses 3

Markdown supported · ⌘↵ to post

[DANIEL OYAGHA](https://hashnode.com/@dyagzie)

[Feb 24, 2021](https://hashnode.com/posts/designing-rest-apis-in-net-5/6027f954e522c1626f3723bd/comment/603657df05efef7f0a9d3697)

My leader sir, I am here again ooooo.

Apparently, I have concluded the code along of the above project, like I noted in my last question when I scaffold a new project template, it already came with a Swagger template already registered in the Startup class. However, I commented out the default swagger registration in the startup class so I could follow yours as described above but when I run the project it throws an error. When I launch the project it goes to this path [localhost/swagger/index.html](https://localhost:44366/swagger/index.html) and I see a default swagger UI similar to yours. But when I navigate to /genre it throws an error "This localhost page can’t be found No webpage was found for the web address: [localhost/genre](https://localhost:44366/genre) HTTP ERROR 404"

Here is a link to my github repo of my codes [github.com/dyagzy/.Net5RestApi](https://github.com/dyagzy/.Net5RestApi)

I will appreciate if you can help debug this... now I will move on to code up the Unit test project while I wait for you...

Thank you in advance chief.

[Gabriel](https://hashnode.com/@Overdosengine)

[Feb 25, 2021](https://hashnode.com/posts/designing-rest-apis-in-net-5/6027f954e522c1626f3723bd/comment/603657df05efef7f0a9d3697#reply-6037626805efef7f0a9d4a91)

Okay. Do you know how to use Swagger? When using Swagger you don't have to change the URL or navigate to any of the actions. The documentation provides ways on how to go about it. You simply just have to click on the endpoint you want to test and follow the instructions and it calls the data you need.

[Iam Merryheart](https://hashnode.com/@Dyagzy)

[Feb 14, 2021](https://hashnode.com/posts/designing-rest-apis-in-net-5/6027f954e522c1626f3723bd/comment/6028f12c355c6669fd17bb47)

Thank you for taking the time to elaborate on the above subject. I am still kind of new to the tech so permit me to ask the following naive questions.

1.  Why did you have to configure swagger again when by default swagger is already configured to the start up class of the. Net5.0 project template?
    
2.  How did you come about all the data annotations and why did you have to use them on all those controller action methods?
    
3.  I didn't really get the difference between the Update Patch method and why you have to use a JsonPatchDoc and all that.
    

1.  You didn't specify the version number for each of the various nuggets packages you installed am asking because I still get confused on how to know which package number to install on a particular project especially when such a package has different variations of it's packages.
    
2.  For the application to access the table in the database, it has to be configured as a service in the DI (Dependency Injection) Container located in the Startup.cs file. You didn't show the code section for this, I think it was an omission.
    
3.  I am new to everything you had described above so I would like to code along then revert back to you if I have a bug or if I have more questions. Once again I am very grateful for the opportunity to learn from you via this article.
    

[Gabriel](https://hashnode.com/@Overdosengine)

[Feb 14, 2021](https://hashnode.com/posts/designing-rest-apis-in-net-5/6027f954e522c1626f3723bd/comment/6028f12c355c6669fd17bb47#reply-60295d9899eab86a04872524)

1.  I added some custom configuration to add API Versioning into the Swagger Doc in the ConfigureSwaggerOptions class so this demands that I reconfigure the existing configuration model.
    
2.  The data annotations I used are built into the ASP.NET Core runtime. I added them as part of the documentatng status code into Swagger Documentation which is available when you run the application.
    
3.  Using JsonPatchDoc is .NET best practice for PATCH REQUEST. It is different from PUT. PATCH request updates only one part of the resource while with PUT you can update one or more part of the resource.
    

Check [docs.microsoft.com/en-us/aspnet/core/web-api/json…](https://docs.microsoft.com/en-us/aspnet/core/web-api/jsonpatch?view=aspnetcore-5.0) for more on configuring and using PATCH request.

1.  If you're using .NET 5 to follow along you can install the latest version of the nuget package.
    
2.  It's was not omitted. Might be a network challenge from your end.
    
3.  Thanks for your comprehensive feedback. I'm always available if you have more questions.
    

[Idris Olubisi](https://hashnode.com/@olanetsoft)

[Feb 14, 2021](https://hashnode.com/posts/designing-rest-apis-in-net-5/6027f954e522c1626f3723bd/comment/6028e624355c6669fd17bab0)

Thanks for sharing
