diff --git a/weather-service/build.gradle b/weather-service/build.gradle index 33758a4f..ee0a9f34 100644 --- a/weather-service/build.gradle +++ b/weather-service/build.gradle @@ -2,6 +2,7 @@ plugins { id 'java' id 'org.springframework.boot' version '3.2.3' id 'io.spring.dependency-management' version '1.1.4' + id "org.springdoc.openapi-gradle-plugin" version '1.8.0' } group = 'com.waither' @@ -45,6 +46,20 @@ dependencies { // Redis implementation 'org.springframework.boot:spring-boot-starter-data-redis' + + //Springdoc + implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.1.0' +} + +openApi { + apiDocsUrl.set("http://localhost:3000") // Document URL + outputDir.set(file("$rootDir/docs")) // Build Result Path + outputFileName.set("weather.json") // Build Result File Name + groupedApiMappings.set(Map.of("http://localhost:8081/weather/api-docs", "weather.json")) + waitTimeInSeconds.set(60) // Timeout + customBootRun { + args.add("--spring.profiles.active=dev") + } } dependencyManagement { diff --git a/weather-service/docs/weather.json b/weather-service/docs/weather.json new file mode 100644 index 00000000..765d6691 --- /dev/null +++ b/weather-service/docs/weather.json @@ -0,0 +1,182 @@ +{ + "openapi": "3.0.1", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost:8081", + "description": "Generated server url" + } + ], + "paths": { + "/api/v1/weather/short": { + "post": { + "tags": [ + "weather-test-controller" + ], + "operationId": "createExpectedWeatherTest", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ForeCastTestRequest" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/api/v1/weather/msg": { + "post": { + "tags": [ + "weather-test-controller" + ], + "operationId": "createDisasterMsgTest", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/MsgTestRequest" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/api/v1/weather/daily": { + "post": { + "tags": [ + "weather-test-controller" + ], + "operationId": "createDailyWeatherTest", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ForeCastTestRequest" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/api/v1/weather/air": { + "post": { + "tags": [ + "weather-test-controller" + ], + "operationId": "airKoreaTest", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AirTestRequest" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/api/v1/weather/accuweather": { + "post": { + "tags": [ + "weather-test-controller" + ], + "operationId": "accuweatherTest", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AccuweatherTestRequest" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK" + } + } + } + } + }, + "components": { + "schemas": { + "ForeCastTestRequest": { + "type": "object", + "properties": { + "nx": { + "type": "integer", + "format": "int32" + }, + "ny": { + "type": "integer", + "format": "int32" + }, + "baseDate": { + "type": "string" + }, + "baseTime": { + "type": "string" + } + } + }, + "MsgTestRequest": { + "type": "object", + "properties": { + "location": { + "type": "string" + } + } + }, + "AirTestRequest": { + "type": "object", + "properties": { + "searchDate": { + "type": "string" + } + } + }, + "AccuweatherTestRequest": { + "type": "object", + "properties": { + "latitude": { + "type": "number", + "format": "double" + }, + "longitude": { + "type": "number", + "format": "double" + } + } + } + } + } +} \ No newline at end of file