-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi.json
1 lines (1 loc) · 3.8 KB
/
api.json
1
{"openapi":"3.0.0","info":{"title":"Hero server API","version":"1.0.0"},"servers":[{"url":"https://heroes-hahow.herokuapp.com","description":"development"},{"url":"http://127.0.0.1:3100","description":"local"}],"schemes":["http"],"basePath":"/","paths":{"/heroes":{"get":{"tags":["Hero"],"summary":"List Heroes - 取得英雄列表","parameters":[{"$ref":"#/components/parameters/Name"},{"$ref":"#/components/parameters/Password"}],"consumes":["application/json"],"produces":["application/json"],"responses":{"200":{"description":"Success response","content":{"application/json":{"schema":{"type":"object","properties":{"heroes":{"type":"array","description":"英雄列表","items":{"$ref":"#/components/schemas/Hero"}}}}}}},"401":{"description":"Unauthorized (code: \"unauthorized\") (當Name跟Password都有給,但驗證身分錯誤時,回傳401)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"500":{"description":"Internal Server Error (code: \"internal_server_error\")","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/heroes/{heroId}":{"get":{"tags":["Hero"],"summary":"Single Hero - 取得單一英雄","parameters":[{"$ref":"#/components/parameters/heroId"},{"$ref":"#/components/parameters/Name"},{"$ref":"#/components/parameters/Password"}],"consumes":["application/json"],"produces":["application/json"],"responses":{"200":{"description":"Success response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Hero"}}}},"401":{"description":"Unauthorized (code: \"unauthorized\") (當Name跟Password都有給,但驗證身分錯誤時,回傳401)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"404":{"description":"Not Found (code: \"not_found\")","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"500":{"description":"Internal Server Error (code: \"internal_server_error\")","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}}},"components":{"schemas":{"ApiError":{"type":"object","required":["code","message"],"properties":{"code":{"type":"string","description":"錯誤代碼","example":"example_error_code"},"message":{"type":"string","description":"錯誤訊息","example":"example error message"},"stack":{"type":"string","description":"錯誤stack (在正式環境不會有)","example":"example error stack"}}},"Hero":{"type":"object","required":["id","name","image"],"properties":{"id":{"type":"string","description":"英雄id","example":"1"},"name":{"type":"string","description":"英雄名字","example":"Daredevil"},"image":{"type":"string","description":"英雄圖片","example":"http://i.annihil.us/u/prod/marvel/i/mg/6/90/537ba6d49472b/standard_xlarge.jpg"},"profile":{"$ref":"#/components/schemas/HeroProfile"}}},"HeroProfile":{"type":"object","description":"英雄檔案 (當使用者成功驗證身分後,才回傳此欄位)","required":["str","int","agi","luk"],"properties":{"str":{"type":"number","description":"力量屬性值","example":2},"int":{"type":"number","description":"智力屬性值","example":7},"agi":{"type":"number","description":"敏捷屬性值","example":9},"luk":{"type":"number","description":"幸運屬性值","example":7}}}},"parameters":{"heroId":{"in":"path","name":"heroId","description":"英雄id","required":true,"schema":{"type":"string","example":"1"}},"Name":{"in":"header","name":"Name","description":"_optional_ - 驗證用名稱 (當Name跟Password都有給時,會驗證使用者身分)","required":false,"schema":{"type":"string","example":"hahow"}},"Password":{"in":"header","name":"Password","description":"_optional_ - 驗證用密碼 (當Name跟Password都有給時,會驗證使用者身分)","required":false,"schema":{"type":"string","example":"rocks"}}}},"tags":[{"name":"Hero","description":"Hero API"}]}