@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,256 @@
1
+ openapi: 3.0.0
2
+ info:
3
+ title: Sample API
4
+ description: Optional multiline or single-line description in [CommonMark](http://commonmark.org/help/) or HTML.
5
+ version: 0.1.9
6
+ servers:
7
+ - url: http://api.example.com/v1
8
+ description: Optional server description, e.g. Main (production) server
9
+ - url: http://staging-api.example.com
10
+ description: Optional server description, e.g. Internal staging server for testing
11
+ paths:
12
+ /users:
13
+ get:
14
+ summary: Returns a list of users
15
+ description: Optional extended description in CommonMark or HTML.
16
+ parameters:
17
+ - name: limit
18
+ in: query
19
+ description: Maximum number of items to return
20
+ required: true
21
+ schema:
22
+ type: integer
23
+ default: 20
24
+ - name: offset
25
+ in: query
26
+ description: Number of items to skip
27
+ required: false
28
+ schema:
29
+ type: integer
30
+ default: 0
31
+ responses:
32
+ '200':
33
+ description: A JSON array of users
34
+ content:
35
+ application/json:
36
+ schema:
37
+ type: array
38
+ items:
39
+ $ref: '#/components/schemas/User'
40
+ post:
41
+ summary: Creates a new user
42
+ requestBody:
43
+ required: true
44
+ content:
45
+ application/json:
46
+ schema:
47
+ $ref: '#/components/schemas/UserInput'
48
+ responses:
49
+ '201':
50
+ description: User created successfully
51
+ content:
52
+ application/json:
53
+ schema:
54
+ $ref: '#/components/schemas/User'
55
+ /users/{userId}:
56
+ parameters:
57
+ - name: userId
58
+ in: path
59
+ required: true
60
+ schema:
61
+ type: integer
62
+ format: int64
63
+ get:
64
+ summary: Get user by ID
65
+ responses:
66
+ '200':
67
+ description: User details
68
+ content:
69
+ application/json:
70
+ schema:
71
+ $ref: '#/components/schemas/User'
72
+ '404':
73
+ description: User not found
74
+ put:
75
+ summary: Update user (full update)
76
+ requestBody:
77
+ required: true
78
+ content:
79
+ application/json:
80
+ schema:
81
+ $ref: '#/components/schemas/UserInput'
82
+ responses:
83
+ '200':
84
+ description: User updated successfully
85
+ content:
86
+ application/json:
87
+ schema:
88
+ $ref: '#/components/schemas/User'
89
+ patch:
90
+ summary: Update user (partial update)
91
+ requestBody:
92
+ required: true
93
+ content:
94
+ application/json:
95
+ schema:
96
+ $ref: '#/components/schemas/UserUpdate'
97
+ responses:
98
+ '200':
99
+ description: User updated successfully
100
+ content:
101
+ application/json:
102
+ schema:
103
+ $ref: '#/components/schemas/User'
104
+ delete:
105
+ summary: Delete user
106
+ responses:
107
+ '204':
108
+ description: User deleted successfully
109
+ /users/{userId}/posts:
110
+ parameters:
111
+ - name: userId
112
+ in: path
113
+ required: true
114
+ schema:
115
+ type: integer
116
+ format: int64
117
+ get:
118
+ summary: Get user's posts
119
+ responses:
120
+ '200':
121
+ description: List of user's posts
122
+ content:
123
+ application/json:
124
+ schema:
125
+ type: array
126
+ items:
127
+ $ref: '#/components/schemas/Post'
128
+ post:
129
+ summary: Create a new post for user
130
+ operationId: createPostForUser
131
+ requestBody:
132
+ required: true
133
+ content:
134
+ application/json:
135
+ schema:
136
+ $ref: '#/components/schemas/PostInput'
137
+ responses:
138
+ '201':
139
+ description: Post created successfully
140
+ content:
141
+ application/json:
142
+ schema:
143
+ $ref: '#/components/schemas/Post'
144
+ components:
145
+ schemas:
146
+ User:
147
+ type: object
148
+ required:
149
+ - id
150
+ - username
151
+ properties:
152
+ id:
153
+ type: integer
154
+ format: int64
155
+ username:
156
+ type: string
157
+ email:
158
+ type: string
159
+ format: email
160
+ status:
161
+ type: string
162
+ enum: [active, inactive]
163
+ createdAt:
164
+ type: string
165
+ format: date-time
166
+ updatedAt:
167
+ type: string
168
+ format: date-time
169
+ UserInput:
170
+ type: object
171
+ required:
172
+ - username
173
+ - email
174
+ properties:
175
+ username:
176
+ type: string
177
+ email:
178
+ type: string
179
+ format: email
180
+ status:
181
+ type: string
182
+ enum: [active, inactive]
183
+ UserUpdate:
184
+ type: object
185
+ properties:
186
+ username:
187
+ type: string
188
+ email:
189
+ type: string
190
+ format: email
191
+ status:
192
+ type: string
193
+ enum: [active, inactive]
194
+ Post:
195
+ type: object
196
+ required:
197
+ - id
198
+ - title
199
+ - content
200
+ - userId
201
+ properties:
202
+ id:
203
+ type: integer
204
+ format: int64
205
+ title:
206
+ type: string
207
+ content:
208
+ type: string
209
+ userId:
210
+ type: integer
211
+ format: int64
212
+ createdAt:
213
+ type: string
214
+ format: date-time
215
+ updatedAt:
216
+ type: string
217
+ format: date-time
218
+ PostInput:
219
+ type: object
220
+ required:
221
+ - title
222
+ - content
223
+ properties:
224
+ title:
225
+ type: string
226
+ content:
227
+ type: string
228
+
229
+ x-docs:
230
+ sidebar:
231
+ - group: API & Reference
232
+ pages:
233
+ - group: Endpoints
234
+ pages:
235
+ - group: Users
236
+ path: users
237
+ pages:
238
+ - type: endpoint
239
+ key: GET /users
240
+ path: get
241
+
242
+ - type: endpoint
243
+ key: GET /users/{userId}
244
+ path: userId
245
+
246
+ - type: endpoint
247
+ key: GET /users/{userId}/posts
248
+ path: posts
249
+
250
+ - type: endpoint
251
+ key: createPostForUser
252
+ path: posts/create
253
+
254
+ - type: object
255
+ key: User
256
+ path: object