@unispechq/unispec-schema 0.4.0 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +170 -162
- package/examples/README.md +128 -0
- package/examples/invalid/config/additional-properties.json +26 -0
- package/examples/invalid/config/missing-service-name.json +22 -0
- package/examples/invalid/config/missing-version.json +6 -0
- package/examples/invalid/graphql-additional-properties.json +22 -0
- package/examples/invalid/graphql-missing-arg-type.json +26 -0
- package/examples/invalid/graphql-missing-name.json +19 -0
- package/examples/invalid/graphql-missing-schema.json +19 -0
- package/examples/invalid/mixed-invalid-protocol.json +26 -0
- package/examples/invalid/mixed-missing-graphql-schema.json +33 -0
- package/examples/invalid/mixed-multiple-errors.json +41 -0
- package/examples/invalid/rest-additional-properties.json +25 -0
- package/examples/invalid/rest-invalid-identifiers.json +29 -0
- package/examples/invalid/rest-invalid-method.json +23 -0
- package/examples/invalid/rest-missing-required.json +21 -0
- package/examples/invalid/websocket-additional-properties.json +27 -0
- package/examples/invalid/websocket-invalid-direction.json +27 -0
- package/examples/invalid/websocket-missing-channel-name.json +25 -0
- package/examples/invalid/websocket-missing-message-name.json +25 -0
- package/examples/valid/config/complete.json +61 -0
- package/examples/valid/config/minimal.json +8 -0
- package/examples/valid/graphql-complete.json +348 -0
- package/examples/valid/graphql-simple.json +34 -0
- package/examples/valid/mixed-complete.json +799 -0
- package/examples/valid/mixed-simple.json +56 -0
- package/examples/valid/rest-complete.json +539 -0
- package/examples/valid/rest-simple.json +279 -0
- package/examples/valid/websocket-complete.json +471 -0
- package/examples/valid/websocket-simple.json +116 -0
- package/index.cjs +7 -7
- package/index.d.ts +9 -9
- package/index.mjs +9 -9
- package/package.json +15 -6
- package/schema/index.json +19 -19
- package/schema/types/common.schema.json +195 -195
- package/schema/types/graphql.schema.json +172 -172
- package/schema/types/rest.schema.json +221 -226
- package/schema/types/schemas.schema.json +84 -84
- package/schema/types/service.schema.json +158 -158
- package/schema/types/websocket.schema.json +185 -190
- package/schema/unispec-config.schema.json +509 -509
- package/schema/unispec-tests.schema.json +368 -378
- package/schema/unispec.schema.json +18 -23
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
{
|
|
2
|
+
"unispecVersion": "0.1.0",
|
|
3
|
+
"service": {
|
|
4
|
+
"name": "blog-api",
|
|
5
|
+
"description": "Simple blog API with posts and comments",
|
|
6
|
+
"version": "1.0.0",
|
|
7
|
+
"baseUrl": "https://blog.example.com/api",
|
|
8
|
+
"tags": ["blog", "posts", "comments"],
|
|
9
|
+
"protocols": {
|
|
10
|
+
"rest": {
|
|
11
|
+
"routes": [
|
|
12
|
+
{
|
|
13
|
+
"name": "getPosts",
|
|
14
|
+
"summary": "List all blog posts",
|
|
15
|
+
"path": "/posts",
|
|
16
|
+
"method": "GET",
|
|
17
|
+
"queryParams": [
|
|
18
|
+
{
|
|
19
|
+
"name": "category",
|
|
20
|
+
"description": "Filter by category",
|
|
21
|
+
"required": false,
|
|
22
|
+
"schemaRef": "CategoryFilter"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"name": "published",
|
|
26
|
+
"description": "Filter by published status",
|
|
27
|
+
"required": false,
|
|
28
|
+
"schemaRef": "PublishedFilter"
|
|
29
|
+
}
|
|
30
|
+
],
|
|
31
|
+
"responses": {
|
|
32
|
+
"200": {
|
|
33
|
+
"description": "List of posts",
|
|
34
|
+
"content": {
|
|
35
|
+
"application/json": {
|
|
36
|
+
"schemaRef": "PostListResponse"
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"name": "createPost",
|
|
44
|
+
"summary": "Create new blog post",
|
|
45
|
+
"path": "/posts",
|
|
46
|
+
"method": "POST",
|
|
47
|
+
"requestBody": {
|
|
48
|
+
"required": true,
|
|
49
|
+
"content": {
|
|
50
|
+
"application/json": {
|
|
51
|
+
"schemaRef": "CreatePostRequest"
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
"responses": {
|
|
56
|
+
"201": {
|
|
57
|
+
"description": "Post created",
|
|
58
|
+
"content": {
|
|
59
|
+
"application/json": {
|
|
60
|
+
"schemaRef": "PostResponse"
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"name": "getPostById",
|
|
68
|
+
"summary": "Get post by ID",
|
|
69
|
+
"path": "/posts/{id}",
|
|
70
|
+
"method": "GET",
|
|
71
|
+
"pathParams": [
|
|
72
|
+
{
|
|
73
|
+
"name": "id",
|
|
74
|
+
"required": true,
|
|
75
|
+
"schemaRef": "PostId"
|
|
76
|
+
}
|
|
77
|
+
],
|
|
78
|
+
"responses": {
|
|
79
|
+
"200": {
|
|
80
|
+
"description": "Post details",
|
|
81
|
+
"content": {
|
|
82
|
+
"application/json": {
|
|
83
|
+
"schemaRef": "PostResponse"
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
"404": {
|
|
88
|
+
"description": "Post not found",
|
|
89
|
+
"content": {
|
|
90
|
+
"application/json": {
|
|
91
|
+
"schemaRef": "ErrorResponse"
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
"name": "addComment",
|
|
99
|
+
"summary": "Add comment to post",
|
|
100
|
+
"path": "/posts/{id}/comments",
|
|
101
|
+
"method": "POST",
|
|
102
|
+
"pathParams": [
|
|
103
|
+
{
|
|
104
|
+
"name": "id",
|
|
105
|
+
"required": true,
|
|
106
|
+
"schemaRef": "PostId"
|
|
107
|
+
}
|
|
108
|
+
],
|
|
109
|
+
"requestBody": {
|
|
110
|
+
"required": true,
|
|
111
|
+
"content": {
|
|
112
|
+
"application/json": {
|
|
113
|
+
"schemaRef": "CreateCommentRequest"
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
"responses": {
|
|
118
|
+
"201": {
|
|
119
|
+
"description": "Comment added",
|
|
120
|
+
"content": {
|
|
121
|
+
"application/json": {
|
|
122
|
+
"schemaRef": "CommentResponse"
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
]
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
"schemas": {
|
|
132
|
+
"PostId": {
|
|
133
|
+
"type": "string",
|
|
134
|
+
"pattern": "^[0-9a-fA-F]{24}$"
|
|
135
|
+
},
|
|
136
|
+
"CategoryFilter": {
|
|
137
|
+
"type": "string",
|
|
138
|
+
"enum": ["tech", "lifestyle", "business", "entertainment"]
|
|
139
|
+
},
|
|
140
|
+
"PublishedFilter": {
|
|
141
|
+
"type": "boolean"
|
|
142
|
+
},
|
|
143
|
+
"CreatePostRequest": {
|
|
144
|
+
"type": "object",
|
|
145
|
+
"required": ["title", "content", "author"],
|
|
146
|
+
"properties": {
|
|
147
|
+
"title": {
|
|
148
|
+
"type": "string",
|
|
149
|
+
"minLength": 1,
|
|
150
|
+
"maxLength": 200
|
|
151
|
+
},
|
|
152
|
+
"content": {
|
|
153
|
+
"type": "string",
|
|
154
|
+
"minLength": 10
|
|
155
|
+
},
|
|
156
|
+
"author": {
|
|
157
|
+
"type": "string",
|
|
158
|
+
"minLength": 1
|
|
159
|
+
},
|
|
160
|
+
"category": {
|
|
161
|
+
"$ref": "#/service/schemas/CategoryFilter"
|
|
162
|
+
},
|
|
163
|
+
"tags": {
|
|
164
|
+
"type": "array",
|
|
165
|
+
"items": {
|
|
166
|
+
"type": "string"
|
|
167
|
+
}
|
|
168
|
+
},
|
|
169
|
+
"published": {
|
|
170
|
+
"type": "boolean",
|
|
171
|
+
"default": false
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
"PostResponse": {
|
|
176
|
+
"type": "object",
|
|
177
|
+
"properties": {
|
|
178
|
+
"id": {
|
|
179
|
+
"$ref": "#/service/schemas/PostId"
|
|
180
|
+
},
|
|
181
|
+
"title": {
|
|
182
|
+
"type": "string"
|
|
183
|
+
},
|
|
184
|
+
"content": {
|
|
185
|
+
"type": "string"
|
|
186
|
+
},
|
|
187
|
+
"author": {
|
|
188
|
+
"type": "string"
|
|
189
|
+
},
|
|
190
|
+
"category": {
|
|
191
|
+
"$ref": "#/service/schemas/CategoryFilter"
|
|
192
|
+
},
|
|
193
|
+
"tags": {
|
|
194
|
+
"type": "array",
|
|
195
|
+
"items": {
|
|
196
|
+
"type": "string"
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
"published": {
|
|
200
|
+
"type": "boolean"
|
|
201
|
+
},
|
|
202
|
+
"createdAt": {
|
|
203
|
+
"type": "string",
|
|
204
|
+
"format": "date-time"
|
|
205
|
+
},
|
|
206
|
+
"updatedAt": {
|
|
207
|
+
"type": "string",
|
|
208
|
+
"format": "date-time"
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
},
|
|
212
|
+
"PostListResponse": {
|
|
213
|
+
"type": "object",
|
|
214
|
+
"properties": {
|
|
215
|
+
"posts": {
|
|
216
|
+
"type": "array",
|
|
217
|
+
"items": {
|
|
218
|
+
"$ref": "#/service/schemas/PostResponse"
|
|
219
|
+
}
|
|
220
|
+
},
|
|
221
|
+
"total": {
|
|
222
|
+
"type": "integer"
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
},
|
|
226
|
+
"CreateCommentRequest": {
|
|
227
|
+
"type": "object",
|
|
228
|
+
"required": ["author", "content"],
|
|
229
|
+
"properties": {
|
|
230
|
+
"author": {
|
|
231
|
+
"type": "string",
|
|
232
|
+
"minLength": 1
|
|
233
|
+
},
|
|
234
|
+
"content": {
|
|
235
|
+
"type": "string",
|
|
236
|
+
"minLength": 1,
|
|
237
|
+
"maxLength": 1000
|
|
238
|
+
},
|
|
239
|
+
"email": {
|
|
240
|
+
"type": "string",
|
|
241
|
+
"format": "email"
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
},
|
|
245
|
+
"CommentResponse": {
|
|
246
|
+
"type": "object",
|
|
247
|
+
"properties": {
|
|
248
|
+
"id": {
|
|
249
|
+
"type": "string"
|
|
250
|
+
},
|
|
251
|
+
"author": {
|
|
252
|
+
"type": "string"
|
|
253
|
+
},
|
|
254
|
+
"content": {
|
|
255
|
+
"type": "string"
|
|
256
|
+
},
|
|
257
|
+
"email": {
|
|
258
|
+
"type": "string"
|
|
259
|
+
},
|
|
260
|
+
"createdAt": {
|
|
261
|
+
"type": "string",
|
|
262
|
+
"format": "date-time"
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
},
|
|
266
|
+
"ErrorResponse": {
|
|
267
|
+
"type": "object",
|
|
268
|
+
"properties": {
|
|
269
|
+
"message": {
|
|
270
|
+
"type": "string"
|
|
271
|
+
},
|
|
272
|
+
"code": {
|
|
273
|
+
"type": "string"
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
}
|