기상청 API 허브를 기반으로 작성
This commit is contained in:
98
api/main.tsp
98
api/main.tsp
@@ -1,44 +1,82 @@
|
||||
import "@typespec/http";
|
||||
|
||||
using Http;
|
||||
@service(#{ title: "Widget Service" })
|
||||
namespace DemoService;
|
||||
@service(#{ title: "Seven Skies Service" })
|
||||
namespace SevenSkiesService;
|
||||
|
||||
model Widget {
|
||||
id: string;
|
||||
weight: int32;
|
||||
color: "red" | "blue";
|
||||
@doc("섭씨 온도(℃)")
|
||||
scalar Celsius extends numeric;
|
||||
|
||||
enum WeatherCondition {
|
||||
@doc("맑음") Clear: "CLEAR",
|
||||
@doc("구름많음") Cloudy: "CLOUDY",
|
||||
@doc("비") Rain: "RAIN",
|
||||
@doc("눈") Snow: "SNOW",
|
||||
@doc("비/눈") RainSnow: "RAIN_SNOW",
|
||||
}
|
||||
|
||||
model WidgetList {
|
||||
items: Widget[];
|
||||
model DailyForecast {
|
||||
@doc("해당 날짜")
|
||||
date: offsetDateTime;
|
||||
|
||||
@doc("하루 동안의 예상 최고 기온(℃)")
|
||||
high: Celsius;
|
||||
|
||||
@doc("하루 동안의 예상 최저 기온(℃)")
|
||||
low: Celsius;
|
||||
|
||||
@doc("하루 전체를 대표하는 날씨 상태")
|
||||
condition: WeatherCondition;
|
||||
}
|
||||
|
||||
model DailyForecastList {
|
||||
items: DailyForecast[];
|
||||
}
|
||||
|
||||
model HourlyForecast {
|
||||
@doc("예상 시간")
|
||||
time: offsetDateTime;
|
||||
|
||||
@doc("1시간 동안의 예상 기온(℃)")
|
||||
temperature: Celsius;
|
||||
|
||||
@doc("1시간 동안의 예상 날씨 상태")
|
||||
condition: WeatherCondition;
|
||||
}
|
||||
|
||||
model HourlyForecastList {
|
||||
items: HourlyForecast[];
|
||||
}
|
||||
|
||||
@error
|
||||
model Error {
|
||||
code: int32;
|
||||
message: string;
|
||||
@doc("에러 코드")
|
||||
errorCode: int32;
|
||||
|
||||
@doc("에러 메시지")
|
||||
errorMessage: string;
|
||||
}
|
||||
|
||||
model AnalyzeResult {
|
||||
id: string;
|
||||
analysis: string;
|
||||
}
|
||||
@route("/forecasts")
|
||||
@tag("Forecasts")
|
||||
interface Forecasts {
|
||||
@get
|
||||
@route("/daily")
|
||||
listDaily(): {
|
||||
@statusCode statusCode: 200;
|
||||
@body body: DailyForecastList;
|
||||
} | {
|
||||
@statusCode statusCode: 500;
|
||||
@body body: Error;
|
||||
};
|
||||
|
||||
@route("/widgets")
|
||||
@tag("Widgets")
|
||||
interface Widgets {
|
||||
/** List widgets */
|
||||
@get list(): WidgetList | Error;
|
||||
/** Read widgets */
|
||||
@get read(@path id: string): Widget | Error;
|
||||
/** Create a widget */
|
||||
@post create(@body body: Widget): Widget | Error;
|
||||
/** Update a widget */
|
||||
@patch update(@path id: string, @body body: MergePatchUpdate<Widget>): Widget | Error;
|
||||
/** Delete a widget */
|
||||
@delete delete(@path id: string): void | Error;
|
||||
|
||||
/** Analyze a widget */
|
||||
@route("{id}/analyze") @post analyze(@path id: string): AnalyzeResult | Error;
|
||||
@get
|
||||
@route("/hourly")
|
||||
listHourly(): {
|
||||
@statusCode statusCode: 200;
|
||||
@body body: HourlyForecastList;
|
||||
} | {
|
||||
@statusCode statusCode: 500;
|
||||
@body body: Error;
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user