/ParksApi

API for State and National Parks Lookup with an attempt at Swagger Documentation

Primary LanguageC#

Parks Api

By Rosario Ruvalcaba

A C# .Net Web Api application that maintains and returns data of state and national parks.

Technologies Used

  • C#
  • .Net 5.0
  • ASP .Net Core MVC
  • MySQL Workbench
  • Entity Core Framework
  • Markdown
  • Newtonsoft.json/Swagger

Description

The Parks RESTful API has full CRUD functionality. The API will return park information such as Name, Date Established, Acrerage, etc. The Parks SQL database can be queried for parks with these various properties. Parks can be added, deleted, and edited either fully though PUT route, or partially via PATCH. Swagger is used to document endpoints.

Setup/Installation Requirements

  • Clone repository from Github and save a copy on own computer. Then on your local copy, navigate to the top level of the directory.

  • If saving repository remotely, make an initial commit pushing ONLY your .gitignore file so sensitive information is not pushed.

  • Ensure you have C# and .NET installed by running the command [dotnet --version] in your terminal. If the response is not a version number, install .NET from Microsoft website.

  • Install MySQL Community Server MySQL Workbench per instruction provided below by Epicodus:

  • Create file called appsettings.json in the main project directory (HairSalon)

    • Open file and add the following: { "ConnectionStrings": { "DefaultConnection": "Server=localhost;Port=3306;database=[DATABASE NAME HERE];uid=[USER ID HERE];pwd=[PASSWORD HERE];" } }
    • Substitute your own information for DATABASE NAME HERE, USER ID HERE, and PASSWORD HERE.
  • Navigate to the ParksApi directory in the project and run the command [dotnet restore, then dotnet build].

  • Next run the command [dotnet ef database update] to re-create the database with all it's migrations in MySql.

  • While still in the ParksApi directory, run the command [dotnet run] to run the application using a localhost server.

  • You can now use Postman (http://localhost:5000/api/parks) or Swagger (https://localhost:5001/swagger/index.html) to use the API

Routes/Endpoints

  • Routes and required parameters can be viewed on Swagger once the application is running: https://localhost:5001/swagger/index.html

  • Here's a screen shot showing the routes with a short summary of what they do

Alt text

Known Bugs

XLM comments are not conscise/clean looking in the controller file. Need to edit

Search by acreage is too strict -- client must enter correct and exact double so it must be edited to be more broad, perhaps to search for parks above or below a certain acreage, which is more realistic to what someone would be searching for.

License

MIT License

Copyright (c) September_2022 Rosario Ruvalcaba Harwood