Skip to content

Commit

Permalink
✨ feat: Api Docs 설정 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
seheonnn committed May 11, 2024
1 parent dbd87fb commit 6c2acb6
Show file tree
Hide file tree
Showing 2 changed files with 197 additions and 0 deletions.
15 changes: 15 additions & 0 deletions weather-service/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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 {
Expand Down
182 changes: 182 additions & 0 deletions weather-service/docs/weather.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
}
}
}

0 comments on commit 6c2acb6

Please sign in to comment.