[.core] Fake Api server dla asp.net core

juniordevops.pl 4 lat temu

Równocześnie stawiasz back i front end? Potrzebujesz do frontu działające API a jeszcze je nie ukończyłeś? Oto rozwiązanie.

Zainstaluj narzędzie dla dotnet CLI

dotnet tool install --global FakeServer

Stwórz bazę endpointów w pliku json

{ "olx": [ { "Id": "ASDSAD-DASDAS-DASDAS-DASD", "DateFetched": "2019-12-13", "MainPhoto": "htt://foto.jpg", "Price": 12.40, "Title": "Camera canon", "Description": "opis opis opis opis opis opis opis opis ", "AuctionId": "2213123213123123", "Auction": { "Id": "34234234", "DateCreated": "2019-12-11", "AuctionSource": "NY", "Phone": "403303033", "Email": "email@email.com", "Notes": "notes notes notes", "UserId": "12345", "User": { "Id" : "daasdas-asdas-d9asdasdas" } } }, { "Id": "ASDSAD-DASDAS-DASDAS-DASK", "DateFetched": "2019-12-14", "MainPhoto": "htt://foto.jpg", "Price": 11.40, "Title": "rower", "Description": "opis opis opis opis opis opis opis opis ", "AuctionId": "2213123213123133323", "Auction": { "Id": "34234234", "DateCreated": "2019-12-10", "AuctionSource": "NY", "Phone": "403303333033", "Email": "email@email.com", "Notes": "notes notes notes", "UserId": "12344", "User": { "Id" : "daasdas-asdas-d9asdasdas" } } } ], "configuration": { "url": "0.0.0.1:80", "password": "abba" }, "configuration_for_patch": { "url": "0.0.0.1:80", "password": "abba" }, "configuration_for_delete": { "url": "0.0.0.1:80", "password": "abba" } }

Następnie użyj narzędzia ze wskazaniem pliku z endpointami:

fake-server --file data.json --urls http://localhost:57602
Idź do oryginalnego materiału