munishchouhan / WeatherForecast

Rest API for Weather Forecasting
1 stars 0 forks source link
java rest-api spring-boot

Weather Forecasting Rest API version 2.0

Getting started

This application is build on spring boot v 2.4.2.Release To use Weather Forecasting Rest API, User need to register with http://openweathermap.org service to get APIKEY, which will be added in application.properties file.

Prerequisite

Build

This application uses MAVEN 3.5.2 for build. Use below command at the root directory of this project

mvn clean install

Run

Once the build is successful, you can find the jar file of this application in ~/target folder Run the jar file using below command

java -jar .\target\weatherforecast-0.0.1-SNAPSHOT.jar

Access API

http://localhost:9090/data/{cityname} e.g. http://localhost:9090/data/berlin

response Example:

[{"date":[2019,1,14],"avg_day_temp":34.705,"avg_night_temp":35.3625,"avg_pressure":1005.36375},{"date":[2019,1,15],"avg_day_temp":35.385,"avg_night_temp":36.5425,"avg_pressure":1016.5550000000001},{"date":[2019,1,16],"avg_day_temp":42.81999999999999,"avg_night_temp":43.102500000000006,"avg_pressure":1010.2175}]

Access Swagger UI

http://localhost:9090/swagger-ui.html This can be used for manual testing

Unit Testing

To Test Application :

you can run com.weatherforecast.WeatherForcastApplicationTests

Integration Testing

To Test Integration with openweathermap.org:

you can run com.weatherforecast.integration.WeatherForecastIntegrationTest

Reasoning and Motivations

At first, I created a high level design:

API call-->/data/{city}-->dataservice-->openweathermap forecast API-->dataservice-->response for /data

Note: In case study, I assume that, Average is referring to mean and not to mode or median

Following are my reasoning and motivations through out this case study: