@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,234 @@
1
+ openapi: 3.0.3
2
+ info:
3
+ title: Book API
4
+ description: API for managing books and authors
5
+ version: 1.0.0
6
+ contact:
7
+ name: API Support
8
+ email: support@example.com
9
+ license:
10
+ name: MIT
11
+ url: https://opensource.org/licenses/MIT
12
+
13
+ servers:
14
+ - url: https://api.example.com/v1
15
+ description: Production server
16
+ - url: https://staging-api.example.com/v1
17
+ description: Staging server
18
+
19
+ paths:
20
+ /books:
21
+ get:
22
+ summary: Get a book by title
23
+ description: Retrieve a book by its title
24
+ operationId: getBookByTitle
25
+ parameters:
26
+ - name: title
27
+ in: query
28
+ required: true
29
+ description: The title of the book
30
+ schema:
31
+ type: string
32
+ - name: date
33
+ in: query
34
+ required: false
35
+ description: The date of the book
36
+ schema:
37
+ type: string
38
+ responses:
39
+ '200':
40
+ description: Book found successfully
41
+ content:
42
+ application/json:
43
+ schema:
44
+ $ref: '#/components/schemas/Book'
45
+ '404':
46
+ description: Book not found
47
+ content:
48
+ application/json:
49
+ schema:
50
+ $ref: '#/components/schemas/Error'
51
+ '400':
52
+ description: Bad request
53
+ content:
54
+ application/json:
55
+ schema:
56
+ $ref: '#/components/schemas/Error'
57
+
58
+ x-codeSamples:
59
+ - lang: bash
60
+ label: List all users
61
+ source: |
62
+ curl -X GET https://api.example.com/users
63
+
64
+ - lang: javascript
65
+ label: List all users
66
+ source: |
67
+ const api = require('api-client');
68
+ api.users.list();
69
+
70
+ - lang: bash
71
+ label: Get user by ID
72
+ source: |
73
+ curl -X GET https://api.example.com/users/123
74
+
75
+ - lang: javascript
76
+ label: Get user by ID
77
+ source: |
78
+ const api = require('api-client');
79
+ api.users.get('123');
80
+ post:
81
+ summary: Add a book
82
+ description: Create a new book
83
+ operationId: addBook
84
+ requestBody:
85
+ required: true
86
+ content:
87
+ application/json:
88
+ schema:
89
+ $ref: '#/components/schemas/BookInput'
90
+ responses:
91
+ '201':
92
+ description: Book created successfully
93
+ content:
94
+ application/json:
95
+ schema:
96
+ $ref: '#/components/schemas/Book'
97
+ '400':
98
+ description: Bad request
99
+ content:
100
+ application/json:
101
+ schema:
102
+ $ref: '#/components/schemas/Error'
103
+
104
+ /authors:
105
+ post:
106
+ summary: Add an author
107
+ description: Create a new author
108
+ operationId: addAuthor
109
+ requestBody:
110
+ required: true
111
+ content:
112
+ application/json:
113
+ schema:
114
+ type: object
115
+ required:
116
+ - name
117
+ properties:
118
+ name:
119
+ type: string
120
+ description: The name of the author
121
+ responses:
122
+ '201':
123
+ description: Author created successfully
124
+ content:
125
+ application/json:
126
+ schema:
127
+ $ref: '#/components/schemas/Author'
128
+ '400':
129
+ description: Bad request
130
+ content:
131
+ application/json:
132
+ schema:
133
+ $ref: '#/components/schemas/Error'
134
+
135
+ components:
136
+ schemas:
137
+ Book:
138
+ type: object
139
+ required:
140
+ - title
141
+ - author_name
142
+ - info
143
+ properties:
144
+ title:
145
+ type: string
146
+ description: The title of the book
147
+ author_name:
148
+ type: string
149
+ description: The author of the book
150
+ info:
151
+ $ref: '#/components/schemas/BookInfo'
152
+ example:
153
+ title: "The Great Gatsby"
154
+ author_name: "F. Scott Fitzgerald"
155
+ info:
156
+ date: "1925-04-10"
157
+
158
+ BookInfo:
159
+ type: object
160
+ required:
161
+ - date
162
+ properties:
163
+ date:
164
+ type: string
165
+ description: The date of the book
166
+ format: date
167
+ example:
168
+ date: "1925-04-10"
169
+
170
+ Author:
171
+ type: object
172
+ required:
173
+ - name
174
+ properties:
175
+ name:
176
+ type: string
177
+ description: The name of the author
178
+ books:
179
+ type: array
180
+ items:
181
+ type: string
182
+ description: The books of the author
183
+ example:
184
+ name: "F. Scott Fitzgerald"
185
+ books: ["The Great Gatsby", "Tender Is the Night"]
186
+
187
+ BookInput:
188
+ type: object
189
+ required:
190
+ - title
191
+ - info
192
+ properties:
193
+ title:
194
+ type: string
195
+ description: The title of the book
196
+ info:
197
+ $ref: '#/components/schemas/BookInfoInput'
198
+ example:
199
+ title: "The Great Gatsby"
200
+ info:
201
+ date: "1925-04-10"
202
+
203
+ BookInfoInput:
204
+ type: object
205
+ required:
206
+ - date
207
+ properties:
208
+ date:
209
+ type: string
210
+ description: The date of the book
211
+ format: date
212
+ example:
213
+ date: "1925-04-10"
214
+
215
+ Error:
216
+ type: object
217
+ required:
218
+ - message
219
+ properties:
220
+ message:
221
+ type: string
222
+ description: Error message
223
+ code:
224
+ type: string
225
+ description: Error code
226
+ example:
227
+ message: "Book not found"
228
+ code: "BOOK_NOT_FOUND"
229
+
230
+ tags:
231
+ - name: books
232
+ description: Operations related to books
233
+ - name: authors
234
+ description: Operations related to authors