-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathexample.yaml
More file actions
103 lines (97 loc) · 2.69 KB
/
example.yaml
File metadata and controls
103 lines (97 loc) · 2.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
swagger: "2.0"
info:
title: mocam-example
version: "1.0"
description: "mocam-seminar-swagger-test-yml"
host: localhost:3000
basePath: /api/v1.0
schemes:
- http
- https
# 클라이언트에게 보낼 Content-type을 설정해 줍니다.
#consume:
# - application/json
# 클라이언트로 부터 받을 Content-type을 설정해 줍니다.
#produces:
# - apllication/json
# paths 명령어 하위로 url 경로를 적어줍니다.
paths:
/user/{user_name}:
# 각 url에 대해 어떤 http method를 사용할지 적어줍니다.
post:
summary: api-summary
description: swagger-example
#produces: application/json
consumes:
- application/x-www-form-urlencoded
tags:
- tag-for-user
parameters:
# path parameter 설정하기
- in: path
name: user_name
type: string
required: true
description: spec for user_name
# QueryString 설정하기
- in: query
name: offest
type: integer
description: offset for pagination
# header parameters
- in: header
name: mc-request-token
type: string
required: true
# request body 설정하기
# 1. x-www-form-urlencoded 2. form-data
# consumes를 설정해줘야 한다 => 최상단에 설정해주면 전체적으로 반영되는듯 하다.
# form 데이터 안에서는 $ref로 items값을 지정할 수 없습니다.
# { 'username' : 'dongsu', 'id': 'Dongineer'}
# - in: formData
# name: name
# type: string
# description: user's name
# case1
- in: body
name : user
schema:
type: object
required:
- userName
properties:
username:
type: string
password:
type: string
responses:
# status code에 따라 응답 메시지를 설정해 줍니다.
200:
# 모델을 만들어 놓고 참조하는 방식
description: status code 200
schema:
$ref: "#/definitions/user"
300:
# 직접 모델과 예제 데이터를 만드는 방식
description: status code 300
schema:
type: object
properties:
id:
type: integer
example: 4
name:
type: string
example: mocam-example-name
definitions:
user:
type: object
required:
- username
properties:
id:
type: integer
description: The user ID.
username:
type: string
description: The user name.