-
Notifications
You must be signed in to change notification settings - Fork 104
/
Copy pathapi.yaml
193 lines (187 loc) · 4.84 KB
/
api.yaml
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
openapi: '3.0.2'
info:
title: IMD Blog API!
version: '1.0'
description: API do blog do IMD
contact:
name: Gustavo Leitão
servers:
- url: http://localhost:8080/api
description: Servidor de teste
paths:
/posts:
post:
description: Adiciona uma postagem no blog
operationId: postPost
summary: Adiciona um post
tags:
- Posts
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/Post"
responses:
'200':
description: OK
'401':
description: Não autorizado
content:
application/json:
schema:
$ref: "#/components/schemas/Erro"
'403':
description: Acesso negado
content:
application/json:
schema:
$ref: "#/components/schemas/Erro"
/usuarios/login:
post:
operationId: userLogin
summary: Realiza autenticação na API
requestBody:
content:
application/json:
schema:
type: object
properties:
email:
type: string
example: foo@bar.com
senha:
type: string
example: algosecreto
tags:
- Autenticação
responses:
'200':
description: ok
content:
application/json:
schema:
type: object
properties:
accessToken:
type: string
example: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOjUsImlzcyI6ImltZC1iYWNrZW5kIiwiYXVkIjoiaW1kLWZyb250ZW5kIiwiZW1haWwiOiJuZXd0b25AZ21haWwuY29tIiwia
'403':
description: Forbidden
content:
application/json:
schema:
$ref: "#/components/schemas/Erro"
/usuarios:
get:
operationId: getUsuarios
summary: Obtém todos os usuários do sistema
tags:
- Usuários
responses:
'200':
description: Lista de usuários
content:
appication/json:
schema:
type: object
properties:
usuarios:
type: array
items:
$ref: "#/components/schemas/Usuario"
delete:
tags:
- Usuários
description: Remove um usuáriodeterminado ID
operationId: deleteUserByID
summary: Remove um usuário
parameters:
- in: query
name: id
schema:
type: integer
responses:
'200':
description: OK
content:
application/json:
schema:
type: object
properties:
msg:
type: string
example: "Usuário deletado com sucesso!"
'400':
description: 400 Bad Request
content:
application/json:
schema:
$ref: "#/components/schemas/Erro"
/usuarios/{id}:
get:
operationId: getById
summary: Obtém um usuário a partir do id
tags:
- Usuários
parameters:
- in: path
name: id
schema:
type: integer
required: true
responses:
'200':
description: Retorna um usuário
content:
appication/json:
schema:
type: object
properties:
usuario:
type: object
$ref: "#/components/schemas/Usuario"
'400':
description: Bad Request
content:
appication/json:
schema:
$ref: "#/components/schemas/Erro"
components:
securitySchemes:
bearerAuth: # arbitrary name for the security scheme
type: http
scheme: bearer
bearerFormat: JWT # optional, arbitrary value for documentation purposes
schemas:
Usuario:
type: object
properties:
id:
type: integer
description: Id do usuário
example: 9
email:
type: string
description: E-mail do usuário
example: foo@bar.com.br
Post:
type: object
properties:
titulo:
type: string
example: Titulo do seu post
texto:
type: string
example: Conteudo do seu post...
userId:
type: integer
example: 9
Erro:
type: object
properties:
msg:
type: string
description: Mensagem de erro
example: Usuário não encontrado!
security:
- bearerAuth: []