@xyd-js/openapi 0.1.0-build.168

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.
Files changed (64) hide show
  1. package/CHANGELOG.md +1517 -0
  2. package/LICENSE +21 -0
  3. package/README.md +3 -0
  4. package/__fixtures__/-2.complex.openai/input.yaml +39848 -0
  5. package/__fixtures__/-2.complex.openai/output.json +321646 -0
  6. package/__fixtures__/-2.complex.openai/pluginOasOpenai.ts +553 -0
  7. package/__fixtures__/-3.random/input.yaml +234 -0
  8. package/__fixtures__/-3.random/output.json +1140 -0
  9. package/__fixtures__/1.basic/input.yaml +226 -0
  10. package/__fixtures__/1.basic/output.json +1919 -0
  11. package/__fixtures__/2.more/input.yaml +76 -0
  12. package/__fixtures__/2.more/output.json +327 -0
  13. package/__fixtures__/3.multiple-responses/input.yaml +48 -0
  14. package/__fixtures__/3.multiple-responses/output.json +311 -0
  15. package/__fixtures__/5.xdocs.codeLanguages/input.yaml +231 -0
  16. package/__fixtures__/5.xdocs.codeLanguages/output.json +1879 -0
  17. package/__fixtures__/5.xdocs.sidebar/input.yaml +256 -0
  18. package/__fixtures__/5.xdocs.sidebar/output.json +843 -0
  19. package/__fixtures__/6.codeSamples/input.yaml +75 -0
  20. package/__fixtures__/6.codeSamples/output.json +293 -0
  21. package/__tests__/oapSchemaToReferences.test.ts +82 -0
  22. package/__tests__/utils.ts +81 -0
  23. package/dist/index.cjs +2154 -0
  24. package/dist/index.cjs.map +1 -0
  25. package/dist/index.d.cts +40 -0
  26. package/dist/index.d.ts +40 -0
  27. package/dist/index.js +2119 -0
  28. package/dist/index.js.map +1 -0
  29. package/examples/basic/index.ts +20 -0
  30. package/examples/basic/index2.ts +36 -0
  31. package/examples/basic/openapi.yaml +124 -0
  32. package/examples/dist/index.cjs +2 -0
  33. package/examples/dist/index.cjs.map +1 -0
  34. package/examples/dist/index.d.cts +2 -0
  35. package/examples/dist/index.d.ts +2 -0
  36. package/examples/dist/index.js +2 -0
  37. package/examples/dist/index.js.map +1 -0
  38. package/examples/semi/index.ts +16 -0
  39. package/examples/semi/openapi.yaml +365 -0
  40. package/examples/semi/references.json +500 -0
  41. package/examples/webhooks/index.ts +16 -0
  42. package/examples/webhooks/openapi.yaml +248 -0
  43. package/examples/webhooks/references.json +895 -0
  44. package/index.ts +12 -0
  45. package/package.json +31 -0
  46. package/src/const.ts +14 -0
  47. package/src/converters/oas-componentSchemas.ts +205 -0
  48. package/src/converters/oas-examples.ts +530 -0
  49. package/src/converters/oas-parameters.ts +41 -0
  50. package/src/converters/oas-paths.ts +354 -0
  51. package/src/converters/oas-requestBody.ts +57 -0
  52. package/src/converters/oas-responses.ts +76 -0
  53. package/src/converters/oas-schema.ts +141 -0
  54. package/src/index.ts +21 -0
  55. package/src/oas-core.ts +579 -0
  56. package/src/types.ts +18 -0
  57. package/src/utils.ts +157 -0
  58. package/src/xdocs/index.ts +18 -0
  59. package/src/xdocs/pluginSidebar.ts +580 -0
  60. package/src/xdocs/types.ts +26 -0
  61. package/tsconfig.json +18 -0
  62. package/tsup.config.ts +19 -0
  63. package/tsup.examples-config.ts +30 -0
  64. package/vitest.config.ts +7 -0
@@ -0,0 +1,76 @@
1
+ openapi: 3.0.0
2
+ paths:
3
+ /users:
4
+ get:
5
+ summary: Returns a list of users
6
+ description: Optional extended description in CommonMark or HTML.
7
+ responses:
8
+ '200':
9
+ description: A JSON array of users
10
+ content:
11
+ application/json:
12
+ schema:
13
+ # Response
14
+ # $ref: '#/components/schemas/User'
15
+ # Response & User
16
+ # allOf:
17
+ # - $ref: '#/components/schemas/Response'
18
+ # - $ref: '#/components/schemas/User'
19
+ # # Response | User
20
+ # anyOf:
21
+ # - $ref: '#/components/schemas/Response'
22
+ # - $ref: '#/components/schemas/User'
23
+ # # Response ^ User
24
+ # oneOf:
25
+ # - $ref: '#/components/schemas/Response'
26
+ # - $ref: '#/components/schemas/User'
27
+
28
+
29
+ type: array
30
+ items:
31
+ # Response
32
+ # $ref: '#/components/schemas/User'
33
+ # # Response & User
34
+ allOf:
35
+ - $ref: '#/components/schemas/Response'
36
+ - $ref: '#/components/schemas/User'
37
+ # # Response | User
38
+ # anyOf:
39
+ # - $ref: '#/components/schemas/Response'
40
+ # - $ref: '#/components/schemas/User'
41
+ # # Response ^ User
42
+ # oneOf:
43
+ # - $ref: '#/components/schemas/Response'
44
+ # - $ref: '#/components/schemas/User'
45
+
46
+ components:
47
+ schemas:
48
+ Response:
49
+ type: object
50
+ title: "Hello Response"
51
+ properties:
52
+ message:
53
+ type: string
54
+ User:
55
+ type: object
56
+ required:
57
+ - id
58
+ - username
59
+ properties:
60
+ id:
61
+ type: integer
62
+ format: int64
63
+ username:
64
+ type: string
65
+ email:
66
+ type: string
67
+ format: email
68
+ status:
69
+ type: string
70
+ enum: [ active, inactive ]
71
+ createdAt:
72
+ type: string
73
+ format: date-time
74
+ updatedAt:
75
+ type: string
76
+ format: date-time
@@ -0,0 +1,327 @@
1
+ [
2
+ {
3
+ "title": "Returns a list of users",
4
+ "canonical": "returns-a-list-of-users",
5
+ "description": "Optional extended description in CommonMark or HTML.",
6
+ "type": "rest_get",
7
+ "category": "rest",
8
+ "context": {
9
+ "method": "get",
10
+ "path": "/users",
11
+ "fullPath": "/users",
12
+ "group": [
13
+ ""
14
+ ],
15
+ "scopes": []
16
+ },
17
+ "examples": {
18
+ "groups": [
19
+ {
20
+ "description": "Example request",
21
+ "examples": [
22
+ {
23
+ "codeblock": {
24
+ "tabs": [
25
+ {
26
+ "title": "shell",
27
+ "language": "shell",
28
+ "code": "curl --request \\\n --url https://example.com/ \\\n --header 'accept: application/json'"
29
+ },
30
+ {
31
+ "title": "javascript",
32
+ "language": "javascript",
33
+ "code": "const options = {method: '', headers: {accept: 'application/json'}};\n\nfetch('https://example.com/', options)\n .then(res => res.json())\n .then(res => console.log(res))\n .catch(err => console.error(err));"
34
+ },
35
+ {
36
+ "title": "python",
37
+ "language": "python",
38
+ "code": "import requests\n\nurl = \"https://example.com/\"\n\nheaders = {\"accept\": \"application/json\"}\n\nresponse = requests.request(\"\", url, headers=headers)\n\nprint(response.text)"
39
+ },
40
+ {
41
+ "title": "go",
42
+ "language": "go",
43
+ "code": "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\t\"io\"\n)\n\nfunc main() {\n\n\turl := \"https://example.com/\"\n\n\treq, _ := http.NewRequest(\"\", url, nil)\n\n\treq.Header.Add(\"accept\", \"application/json\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := io.ReadAll(res.Body)\n\n\tfmt.Println(string(body))\n\n}"
44
+ }
45
+ ]
46
+ }
47
+ }
48
+ ]
49
+ },
50
+ {
51
+ "description": "Example response",
52
+ "examples": [
53
+ {
54
+ "codeblock": {
55
+ "title": "200",
56
+ "tabs": [
57
+ {
58
+ "title": "application/json",
59
+ "language": "json",
60
+ "code": "[\n {\n \"message\": \"string\",\n \"id\": 0,\n \"username\": \"string\",\n \"email\": \"user@example.com\",\n \"status\": \"active\",\n \"createdAt\": \"2019-08-24T14:15:22Z\",\n \"updatedAt\": \"2019-08-24T14:15:22Z\"\n }\n]"
61
+ }
62
+ ]
63
+ }
64
+ }
65
+ ]
66
+ }
67
+ ]
68
+ },
69
+ "definitions": [
70
+ {
71
+ "title": "Response",
72
+ "variants": [
73
+ {
74
+ "title": "200",
75
+ "description": "A JSON array of users",
76
+ "properties": [],
77
+ "rootProperty": {
78
+ "type": "$$array",
79
+ "properties": [
80
+ {
81
+ "name": "message",
82
+ "type": "string",
83
+ "description": "",
84
+ "meta": []
85
+ },
86
+ {
87
+ "name": "id",
88
+ "type": "integer",
89
+ "description": "",
90
+ "meta": [
91
+ {
92
+ "name": "required",
93
+ "value": "true"
94
+ }
95
+ ]
96
+ },
97
+ {
98
+ "name": "username",
99
+ "type": "string",
100
+ "description": "",
101
+ "meta": [
102
+ {
103
+ "name": "required",
104
+ "value": "true"
105
+ }
106
+ ]
107
+ },
108
+ {
109
+ "name": "email",
110
+ "type": "string",
111
+ "description": "",
112
+ "meta": []
113
+ },
114
+ {
115
+ "name": "status",
116
+ "type": "$$enum",
117
+ "description": "",
118
+ "meta": [
119
+ {
120
+ "name": "enum-type",
121
+ "value": "string"
122
+ }
123
+ ],
124
+ "properties": [
125
+ {
126
+ "name": "active",
127
+ "type": "string",
128
+ "description": "",
129
+ "meta": []
130
+ },
131
+ {
132
+ "name": "inactive",
133
+ "type": "string",
134
+ "description": "",
135
+ "meta": []
136
+ }
137
+ ]
138
+ },
139
+ {
140
+ "name": "createdAt",
141
+ "type": "string",
142
+ "description": "",
143
+ "meta": []
144
+ },
145
+ {
146
+ "name": "updatedAt",
147
+ "type": "string",
148
+ "description": "",
149
+ "meta": []
150
+ }
151
+ ]
152
+ },
153
+ "meta": [
154
+ {
155
+ "name": "status",
156
+ "value": "200"
157
+ },
158
+ {
159
+ "name": "contentType",
160
+ "value": "application/json"
161
+ },
162
+ {
163
+ "name": "definitionDescription",
164
+ "value": ""
165
+ }
166
+ ],
167
+ "symbolDef": {
168
+ "id": []
169
+ }
170
+ }
171
+ ],
172
+ "properties": []
173
+ }
174
+ ]
175
+ },
176
+ {
177
+ "title": "Response",
178
+ "description": "",
179
+ "canonical": "objects/Response",
180
+ "definitions": [
181
+ {
182
+ "title": "Response",
183
+ "properties": [
184
+ {
185
+ "name": "message",
186
+ "type": "string",
187
+ "description": "",
188
+ "meta": []
189
+ }
190
+ ],
191
+ "meta": []
192
+ }
193
+ ],
194
+ "examples": {
195
+ "groups": [
196
+ {
197
+ "description": "Example",
198
+ "examples": [
199
+ {
200
+ "codeblock": {
201
+ "tabs": [
202
+ {
203
+ "title": "json",
204
+ "language": "json",
205
+ "code": "{\n \"message\": \"\"\n}"
206
+ }
207
+ ]
208
+ }
209
+ }
210
+ ]
211
+ }
212
+ ]
213
+ },
214
+ "type": "rest_component_schema",
215
+ "context": {
216
+ "componentSchema": "Response",
217
+ "group": [
218
+ "Objects"
219
+ ]
220
+ }
221
+ },
222
+ {
223
+ "title": "User",
224
+ "description": "",
225
+ "canonical": "objects/User",
226
+ "definitions": [
227
+ {
228
+ "title": "User",
229
+ "properties": [
230
+ {
231
+ "name": "id",
232
+ "type": "integer",
233
+ "description": "",
234
+ "meta": [
235
+ {
236
+ "name": "required",
237
+ "value": "true"
238
+ }
239
+ ]
240
+ },
241
+ {
242
+ "name": "username",
243
+ "type": "string",
244
+ "description": "",
245
+ "meta": [
246
+ {
247
+ "name": "required",
248
+ "value": "true"
249
+ }
250
+ ]
251
+ },
252
+ {
253
+ "name": "email",
254
+ "type": "string",
255
+ "description": "",
256
+ "meta": []
257
+ },
258
+ {
259
+ "name": "status",
260
+ "type": "$$enum",
261
+ "description": "",
262
+ "meta": [
263
+ {
264
+ "name": "enum-type",
265
+ "value": "string"
266
+ }
267
+ ],
268
+ "properties": [
269
+ {
270
+ "name": "active",
271
+ "type": "string",
272
+ "description": "",
273
+ "meta": []
274
+ },
275
+ {
276
+ "name": "inactive",
277
+ "type": "string",
278
+ "description": "",
279
+ "meta": []
280
+ }
281
+ ]
282
+ },
283
+ {
284
+ "name": "createdAt",
285
+ "type": "string",
286
+ "description": "",
287
+ "meta": []
288
+ },
289
+ {
290
+ "name": "updatedAt",
291
+ "type": "string",
292
+ "description": "",
293
+ "meta": []
294
+ }
295
+ ],
296
+ "meta": []
297
+ }
298
+ ],
299
+ "examples": {
300
+ "groups": [
301
+ {
302
+ "description": "Example",
303
+ "examples": [
304
+ {
305
+ "codeblock": {
306
+ "tabs": [
307
+ {
308
+ "title": "json",
309
+ "language": "json",
310
+ "code": "{\n \"id\": 0,\n \"username\": \"\",\n \"email\": \"\",\n \"status\": \"\",\n \"createdAt\": \"\",\n \"updatedAt\": \"\"\n}"
311
+ }
312
+ ]
313
+ }
314
+ }
315
+ ]
316
+ }
317
+ ]
318
+ },
319
+ "type": "rest_component_schema",
320
+ "context": {
321
+ "componentSchema": "User",
322
+ "group": [
323
+ "Objects"
324
+ ]
325
+ }
326
+ }
327
+ ]
@@ -0,0 +1,48 @@
1
+ openapi: 3.0.0
2
+ paths:
3
+ /response:
4
+ get:
5
+ summary: Returns a response
6
+ description: Returns a response or a stream of responses
7
+ responses:
8
+ "400":
9
+ description: Bad Request
10
+ content:
11
+ application/json:
12
+ schema:
13
+ $ref: "#/components/schemas/ErrorResponse"
14
+
15
+ "200":
16
+ description: OK
17
+ content:
18
+ application/json:
19
+ schema:
20
+ $ref: "#/components/schemas/Response"
21
+ text/event-stream:
22
+ schema:
23
+ $ref: "#/components/schemas/ResponseStream"
24
+
25
+ components:
26
+ schemas:
27
+ ErrorResponse:
28
+ type: object
29
+ title: "ErrorResponse"
30
+ properties:
31
+ message:
32
+ type: string
33
+
34
+ Response:
35
+ type: object
36
+ title: "Hello Response"
37
+ properties:
38
+ message:
39
+ type: string
40
+
41
+ ResponseStream:
42
+ type: object
43
+ title: "Hello ResponseStream"
44
+ properties:
45
+ message:
46
+ type: string
47
+
48
+