Skip to content

.NET Core RESTful API with Swagger API Doc based on Northwind MySQL database template

License

Notifications You must be signed in to change notification settings

dpedwards/dotnet-core-restapi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LICENSE .NET Core swagger

This Template is based on the Northwind MySQl database, an excellent tutorial schema for a small-business ERP, with customers, orders, inventory, purchasing, suppliers, shipping, employees, and single-entry accounting.

Notable features

  • OAuth 2.0 JWT bearer authentication
  • .pfx certificate support
  • swagger API Doc
  • CRUD operations
  • File up-/download
  • Windows & Linux platform support
  • MySQL / MS SQL support
  • Razor Page support
  • Unit Test
  • Error logging

Pictures

Index:

Swagger API Doc Overview:

JWT WebService (Swagger API Doc):

JWT Bearer (Swagger API Doc):

API key authorization (Swagger API Doc):

WebService call (Swagger API Doc):

Installation

For this project you need to install .NET Core 2.1 Framework and MySQL/MariaDB on your local machine!

  1. Execute the northwind.sql file in MySQL/MariaDB and create the northwind db:

    path: RESTfulAPI/RESTfulAPI/wwwroot/documents/northwind.sql
  2. Execute the nothwind-data.sql file in MySQL/MariaDB and fill the previously created northwind db with test datasets:

    path: RESTfulAPI/RESTfulAPI/wwwroot/documents/northwind-data.sql
  3. Change the MySQL/MariaDB connection string in appsettings.json file:

    path: RESTfulAPI/RESTfulAPI/application.json
  4. Run the project inside the Visual Studio IDE/Visual Sudio Code Editor or navigate to project root path RESTfulAPI\RESTfulAPI with Windows cmd or linux terminal console and enter the following dotnet core commands:

    cmd: dotnet restore
    cmd: dotnet run

Development

  1. If all is fine the project will run on port 5001 you can access with https://localhost:5001.

  2. For testing REST CRUD operations you can access the swagger API Doc https://localhost:5001/swagger.

  3. Before you can start CRUD operations on any implemented WebService you have to authenticate with the Token WebService:

  4. Paste in the following JSON structure and press the Try it out! button.

              {
                "userName": "TestUser",
                "password": "P455w0rd"
              }
  1. Next copy the Bearer token string inside from the response body element like in this example in the square brackets --> "token:""[eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6I...]".

  2. Now navigate to the top of the swagger API Doc page view and push the green space button with white text Authorize on the right side.

  3. After a new window poped up, paste the Bearer token string in the value: field with following convention shown in square brackets --> [Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6I...].

  4. Finally authenticate with pushing the grey Auhtorize button.

If you need some more help please feel free to message me. Happy coding!

Usage

For detailed instructions on how to configure, customize, add/migrate content, and more read the template`s documentation.


Pull Requests

When submitting a pull request:

  1. Clone the repo.
  2. Create a branch off of master and give it a meaningful name (e.g. my-awesome-new-feature).
  3. Open a pull request on GitHub and describe the feature or fix.

Template documentation and demo pages can be found in the /docs if submitting improvements, typo corrections, etc.


Credits

Creator

Davain Pablo Edwards

Environment requirements

Project packages requirements:


License

MIT License

Copyright (c) 2019 Davain Pablo Edwards

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

.NET Core RESTful API with Swagger API Doc based on Northwind MySQL database template

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published