-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi.yaml
276 lines (254 loc) · 7.5 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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
openapi: 3.0.1
info:
title: Opinion service
description: Client API
version: 1.0.0
servers:
- url: 'https://localhost/'
tags:
- name: question
description: Operations with questions.
- name: answer
description: Manage answers
paths:
/question/list:
post:
tags:
- question
summary: Request list of questions.
operationId: questionsList
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/QuestionsRequest'
required: true
responses:
'200':
description: OK. Body contains list of questions.
content:
application/json:
schema:
$ref: '#/components/schemas/QuestionsResponse'
/question/create:
post:
tags:
- question
summary: Create new question.
operationId: createQuestion
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/CreateQuestionRequest'
required: true
responses:
'200':
description: Information about result of processing create question request.
content:
application/json:
schema:
$ref: '#/components/schemas/CreateQuestionResponse'
components:
schemas:
Discriminable:
type: object
description: |
Support serialization of implementations.
properties:
className:
type: string
title: Discriminator
description: |
Used by json serializers to specify implementation class.
discriminator:
propertyName: className
Request:
type: object
description: Common interface for all requests.
allOf:
- $ref: "#/components/schemas/Discriminable"
- type: object
properties:
requestId:
description: Unique id of the request.
type: string
processingMode:
$ref: '#/components/schemas/ProcessingMode'
stub:
$ref: '#/components/schemas/Stub'
discriminator:
propertyName: className
Response:
type: object
description: Common interface for all responses.
allOf:
- $ref: "#/components/schemas/Discriminable"
- type: object
properties:
requestId:
description: Id of initial request.
type: string
result:
$ref: "#/components/schemas/Result"
errors:
type: array
items:
$ref: '#/components/schemas/ServerError'
discriminator:
propertyName: className
EmptyResponse:
type: object
description: |
Universal empty response used in case specific response
faild to be generated.
allOf:
- $ref: "#/components/schemas/Response"
ServerError:
description: |
Any message which can be useful for a client, e.g. form field validation error,
some remark or hint for client.
type: object
properties:
message:
type: string
field:
type: string
level:
$ref: "#/components/schemas/ErrorLevel"
errorType:
$ref: "#/components/schemas/ErrorType"
ErrorLevel:
description: Server side error level.
type: string
enum: [hint, warning, error]
ErrorType:
description: Points to error
type: string
enum: [initialization_error, request_parsing_error, fail_build_request_model, error_stub, validation_error, server_error, db_error]
ProcessingMode:
description: Specify how the request should be processed.
type: string
default: prod
enum: [prod, test, stub]
Stub:
description: Server return specified stub response in 'stub' processing mode.
type: string
enum: [success, fail]
Pagination:
description: |
Specify range of objects.
Set an object id and specify how many objects before/after specified
object are required.
type: object
properties:
objectsCount:
description: Count of objects.
type: integer
format: int32
objectId:
description: Object id used as a boundary of the range.
type: string
relation:
description: |
Specify should objects with smaller or greaterids ids,
should be selected.
type: string
enum: [before, after]
QuestionsRequest:
description: Request list of questions.
type: object
allOf:
- $ref: '#/components/schemas/Request'
- type: object
properties:
pagination:
$ref: "#/components/schemas/Pagination"
QuestionsResponse:
description: List of questions with additional information.
type: object
allOf:
- $ref: "#/components/schemas/Response"
- type: object
properties:
questions:
type: array
items:
$ref: "#/components/schemas/Question"
CreateQuestionRequest:
description: Request new question creation.
type: object
allOf:
- $ref: '#/components/schemas/Request'
- type: object
properties:
question:
$ref: '#/components/schemas/Question'
CreateQuestionResponse:
description: Response to new question creation.
type: object
allOf:
- $ref: '#/components/schemas/Response'
- type: object
properties:
question:
$ref: '#/components/schemas/Question'
Question:
description: Mutable question.
type: object
properties:
questionId:
description: Unique question identifier.
type: string
title:
description: Short description of the question.
type: string
title: Question header.
content:
description: The full question tetx.
type: string
author:
description: Question author.
type: string
creationTime:
description: Time the question was created.
type: string
language:
type: string
tags:
description: Tags used to classify and search questions, similar with StackOverflow tags.
type: array
items:
type: string
likesCount:
type: integer
answersCount:
type: integer
permissions:
description: Inform client what it can do with the question.
type: array
uniqueItems: true
items:
$ref: "#/components/schemas/Permission"
state:
$ref: "#/components/schemas/QuestionState"
visibility:
$ref: "#/components/schemas/Visibility"
Permission:
description: Which operations are granted to client.
type: string
enum: [read, update, delete]
Visibility:
description: |
Grant permissions to observe an object.
Used on server side to deside if an object could be provided to a user.
type: string
enum: [owner_only, registered_only, public]
Result:
description: Result of request processing.
type: string
enum: [ success, error ]
QuestionState:
description: Question lifecycle state.
type: string
enum: [ proposed, moderated, accepted, opened, closed ]