Coder Social home page Coder Social logo

projetapi's Introduction

ASP.NET CORE WEBAPI Sample with swagger

Introduction

This short tutorial demonstrates how you can create a web api as micro service and cover your code with unit test and how you can use the principle of clean code.

The purpose of this example is to use the NoSQL data to display the temperatures of the different country and city, the user can search the temperature by specifying the country.

Installation

You must download the code from git and use visual studio 2017 (you can download Vs2017 from https://visualstudio.microsoft.com/fr/downloads/) to open it and build the solution finaly you can run this application on iis express

  • You can display the first page to test this application
  • The first page is a swagger page how display all action in this api (documentatuin swagger : https://swagger.io/tools/swagger-ui/)

you can choose the endpoint to test it the swagger page look like this.

alt text

Demonstration

This application respect the separation of concern you can find the use of interface to declare the method used in different layer.

Inject all interface in the configure services method in Startup.cs file. The controller inject the business class and the business class inject the repository class with this method we facilitate the test of same layer of our application.

  • display the getAll action from swagger interface

alt text

  • response: alt text

Unit test

to test this application i used NUnit framework and mock

  • mock the class used in the tested method.

projetapi's People

Contributors

amelmhamdi avatar

Watchers

 avatar

projetapi's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.