@xyd-js/openapi 0.1.0-xyd.10 → 0.1.0-xyd.13

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 (49) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/__fixtures__/-2.complex.openai/input.yaml +39848 -0
  3. package/__fixtures__/-2.complex.openai/output.json +321646 -0
  4. package/__fixtures__/-2.complex.openai/pluginOasOpenai.ts +553 -0
  5. package/__fixtures__/1.basic/input.yaml +226 -0
  6. package/__fixtures__/1.basic/output.json +1919 -0
  7. package/__fixtures__/2.more/input.yaml +76 -0
  8. package/__fixtures__/2.more/output.json +292 -0
  9. package/__fixtures__/3.multiple-responses/input.yaml +48 -0
  10. package/__fixtures__/3.multiple-responses/output.json +266 -0
  11. package/__fixtures__/4.abc/input.yaml +639 -0
  12. package/__fixtures__/4.abc/output.json +3828 -0
  13. package/__fixtures__/5.xdocs.codeLanguages/input.yaml +231 -0
  14. package/__fixtures__/5.xdocs.codeLanguages/output.json +1879 -0
  15. package/__fixtures__/5.xdocs.sidebar/input.yaml +256 -0
  16. package/__fixtures__/5.xdocs.sidebar/output.json +843 -0
  17. package/__fixtures__/6.codeSamples/input.yaml +75 -0
  18. package/__fixtures__/6.codeSamples/output.json +293 -0
  19. package/__tests__/oapSchemaToReferences.test.ts +88 -0
  20. package/__tests__/utils.ts +81 -0
  21. package/dist/index.cjs +1859 -162
  22. package/dist/index.cjs.map +1 -1
  23. package/dist/index.d.cts +36 -4
  24. package/dist/index.d.ts +36 -4
  25. package/dist/index.js +1855 -155
  26. package/dist/index.js.map +1 -1
  27. package/index.ts +10 -2
  28. package/package.json +11 -6
  29. package/src/const.ts +5 -1
  30. package/src/converters/oas-componentSchemas.ts +205 -0
  31. package/src/converters/oas-examples.ts +417 -0
  32. package/src/{parameters.ts → converters/oas-parameters.ts} +17 -3
  33. package/src/converters/oas-paths.ts +354 -0
  34. package/src/{requestBody.ts → converters/oas-requestBody.ts} +30 -10
  35. package/src/converters/oas-responses.ts +76 -0
  36. package/src/converters/oas-schema.ts +141 -0
  37. package/src/index.ts +13 -5
  38. package/src/oas-core.ts +579 -0
  39. package/src/types.ts +18 -0
  40. package/src/utils.ts +103 -90
  41. package/src/xdocs/index.ts +18 -0
  42. package/src/xdocs/pluginSidebar.ts +580 -0
  43. package/src/xdocs/types.ts +26 -0
  44. package/vitest.config.ts +7 -0
  45. package/src/examples.ts +0 -116
  46. package/src/paths.ts +0 -103
  47. package/src/properties.ts +0 -37
  48. package/src/responses.ts +0 -38
  49. package/src/schema.ts +0 -62
@@ -0,0 +1,226 @@
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
+ requestBody:
131
+ required: true
132
+ content:
133
+ application/json:
134
+ schema:
135
+ $ref: '#/components/schemas/PostInput'
136
+ responses:
137
+ '201':
138
+ description: Post created successfully
139
+ content:
140
+ application/json:
141
+ schema:
142
+ $ref: '#/components/schemas/Post'
143
+ components:
144
+ schemas:
145
+ User:
146
+ type: object
147
+ required:
148
+ - id
149
+ - username
150
+ properties:
151
+ id:
152
+ type: integer
153
+ format: int64
154
+ username:
155
+ type: string
156
+ email:
157
+ type: string
158
+ format: email
159
+ status:
160
+ type: string
161
+ enum: [active, inactive]
162
+ createdAt:
163
+ type: string
164
+ format: date-time
165
+ updatedAt:
166
+ type: string
167
+ format: date-time
168
+ UserInput:
169
+ type: object
170
+ required:
171
+ - username
172
+ - email
173
+ properties:
174
+ username:
175
+ type: string
176
+ email:
177
+ type: string
178
+ format: email
179
+ status:
180
+ type: string
181
+ enum: [active, inactive]
182
+ UserUpdate:
183
+ type: object
184
+ properties:
185
+ username:
186
+ type: string
187
+ email:
188
+ type: string
189
+ format: email
190
+ status:
191
+ type: string
192
+ enum: [active, inactive]
193
+ Post:
194
+ type: object
195
+ required:
196
+ - id
197
+ - title
198
+ - content
199
+ - userId
200
+ properties:
201
+ id:
202
+ type: integer
203
+ format: int64
204
+ title:
205
+ type: string
206
+ content:
207
+ type: string
208
+ userId:
209
+ type: integer
210
+ format: int64
211
+ createdAt:
212
+ type: string
213
+ format: date-time
214
+ updatedAt:
215
+ type: string
216
+ format: date-time
217
+ PostInput:
218
+ type: object
219
+ required:
220
+ - title
221
+ - content
222
+ properties:
223
+ title:
224
+ type: string
225
+ content:
226
+ type: string