기타
[기타] SwaggerHub를 사용하여 API 관리하기
전자기린
2020. 1. 9. 17:22
Swagger Hub란?
API Document 역할을 하며
API를 등록하면 해당 API에 대한 작동 테스트가 가능하며
[입력 값]이나 [입력 필수 값]을 지정 가능하며 API 작동 원리를 이해하는 것에 도움을 준다.
Build, Collaborate & Integrate APIs | SwaggerHub
app.swaggerhub.com
1. 로그인 (GitHub 계정을 통해 접속할 수 있습니다.)
2. 새로운 API를 생성합니다.
2-1. Create New - Create New API
2-2. API 정보를 입력합니다.
3. Code Editor에 API 정보 입력하기 (11라인부터 입력)
openapi: 3.0.0
info:
version: '1.0.0'
title: 'SwaggerHub_Example'
description: 'SwaggerHub 예제'
# Added by API Auto Mocking Plugin
servers:
# Added by API Auto Mocking Plugin
- description: SwaggerHub API Auto Mocking
url: https://virtserver.swaggerhub.com/jeseokMun/SwaggerHub_Example/1.0.0
- description: JSON Placeholder API
url: https://jsonplaceholder.typicode.com
paths:
/todos/{id}:
get:
summary: ID값을 반환함.
parameters:
- name: id
in: path
required: true
description: 입력된 ID값을 반환함.
schema:
type: integer
responses:
'200':
description: OK
content:
application/json:
schema:
type: object
properties:
userID:
type: integer
id:
type: integer
title:
type: string
completed:
type: boolean
위처럼 API를 등록할 경우 해당 API에 대한 테스트를 진행할 수 있게 된다.