-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnote-service.yaml
More file actions
202 lines (193 loc) · 5 KB
/
Copy pathnote-service.yaml
File metadata and controls
202 lines (193 loc) · 5 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
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
194
195
196
197
198
199
200
201
202
openapi: 3.0.3
info:
title: Note Service API
version: 1.0.0
tags:
- name: Notes
description: Operations for managing notes
servers:
- url: /
paths:
/api/v1/notes:
get:
tags: [Notes]
summary: Get all notes for a user
operationId: getNotes
security:
- JWTAuth: []
responses:
'200':
description: List of notes
content:
application/json:
schema:
$ref: '#/components/schemas/ListNotesResponse'
'401':
description: Token either does not exist or is already expired
'500':
description: Unhandled error occurred
post:
tags: [Notes]
summary: Create a new note
operationId: createNote
security:
- JWTAuth: []
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/CreateNoteRequest'
responses:
'201':
description: Note created
content:
application/json:
schema:
$ref: '#/components/schemas/CreateNoteResponse'
'401':
description: Token either does not exist or is already expired
'500':
description: Unhandled error occurred
/api/v1/notes/{id}:
get:
tags: [Notes]
summary: Get a note by ID
operationId: getNoteById
security:
- JWTAuth: []
parameters:
- $ref: '#/components/parameters/id'
responses:
'200':
description: The note
content:
application/json:
schema:
$ref: '#/components/schemas/GetNoteResponse'
'401':
description: Token either does not exist or is already expired
'403':
description: Accessing note of someone else
'404':
description: Note not found
'500':
description: Unhandled error occurred
put:
tags: [Notes]
summary: Update a note's title and content
operationId: updateNote
security:
- JWTAuth: []
parameters:
- $ref: '#/components/parameters/id'
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/Note'
responses:
'200':
description: Updated note
content:
application/json:
schema:
$ref: '#/components/schemas/UpdateNoteResponse'
'401':
description: Token either does not exist or is already expired
'403':
description: Accessing note of someone else
'404':
description: Note not found
'500':
description: Unhandled error occurred
delete:
tags: [Notes]
summary: Delete a note by ID
operationId: deleteNote
security:
- JWTAuth: []
parameters:
- $ref: '#/components/parameters/id'
responses:
'204':
description: Note deleted
'401':
description: Token either does not exist or is already expired
'403':
description: Accessing note of someone else
'404':
description: Note not found
'500':
description: Unhandled error occurred
components:
securitySchemes:
JWTAuth:
$ref: './common.yaml#/components/securitySchemes/JWTAuth'
parameters:
id:
name: id
in: path
required: true
schema:
type: integer
format: int64
schemas:
Note:
type: object
additionalProperties: true
properties:
title:
type: string
pattern: '.*\S.*'
maxLength: 255
example: "Grocery List"
content:
type: string
example: "Milk, Bread, Eggs, Apples"
ListNotesResponse:
type: object
properties:
notes:
type: array
items:
$ref: "#/components/schemas/IdentifiedTimestampedNote"
required:
- notes
CreateNoteRequest:
allOf:
- $ref: '#/components/schemas/Note'
- type: object
required:
- title
- content
CreateNoteResponse:
allOf:
- $ref: '#/components/schemas/IdentifiedTimestampedNote'
GetNoteResponse:
allOf:
- $ref: "#/components/schemas/IdentifiedTimestampedNote"
UpdateNoteResponse:
allOf:
- $ref: "#/components/schemas/IdentifiedTimestampedNote"
IdentifiedNote:
type: object
allOf:
- $ref: './common.yaml#/components/schemas/Identifier'
- $ref: "#/components/schemas/Note"
required:
- id
- title
- content
IdentifiedTimestampedNote:
type: object
allOf:
- $ref: './common.yaml#/components/schemas/Timestamped'
- $ref: "#/components/schemas/IdentifiedNote"
required:
- id
- title
- content
- createdAt
- lastUpdatedAt