@xyd-js/openapi 0.1.0-xyd.11 → 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.
- package/CHANGELOG.md +16 -0
- package/__fixtures__/-2.complex.openai/input.yaml +39848 -0
- package/__fixtures__/-2.complex.openai/output.json +321646 -0
- package/__fixtures__/-2.complex.openai/pluginOasOpenai.ts +553 -0
- package/__fixtures__/1.basic/input.yaml +226 -0
- package/__fixtures__/1.basic/output.json +1919 -0
- package/__fixtures__/2.more/input.yaml +76 -0
- package/__fixtures__/2.more/output.json +292 -0
- package/__fixtures__/3.multiple-responses/input.yaml +48 -0
- package/__fixtures__/3.multiple-responses/output.json +266 -0
- package/__fixtures__/4.abc/input.yaml +639 -0
- package/__fixtures__/4.abc/output.json +3828 -0
- package/__fixtures__/5.xdocs.codeLanguages/input.yaml +231 -0
- package/__fixtures__/5.xdocs.codeLanguages/output.json +1879 -0
- package/__fixtures__/5.xdocs.sidebar/input.yaml +256 -0
- package/__fixtures__/5.xdocs.sidebar/output.json +843 -0
- package/__fixtures__/6.codeSamples/input.yaml +75 -0
- package/__fixtures__/6.codeSamples/output.json +293 -0
- package/__tests__/oapSchemaToReferences.test.ts +88 -0
- package/__tests__/utils.ts +81 -0
- package/dist/index.cjs +1859 -162
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +36 -4
- package/dist/index.d.ts +36 -4
- package/dist/index.js +1855 -155
- package/dist/index.js.map +1 -1
- package/index.ts +10 -2
- package/package.json +11 -6
- package/src/const.ts +5 -1
- package/src/converters/oas-componentSchemas.ts +205 -0
- package/src/converters/oas-examples.ts +417 -0
- package/src/{parameters.ts → converters/oas-parameters.ts} +17 -3
- package/src/converters/oas-paths.ts +354 -0
- package/src/{requestBody.ts → converters/oas-requestBody.ts} +30 -10
- package/src/converters/oas-responses.ts +76 -0
- package/src/converters/oas-schema.ts +141 -0
- package/src/index.ts +13 -5
- package/src/oas-core.ts +579 -0
- package/src/types.ts +18 -0
- package/src/utils.ts +103 -90
- package/src/xdocs/index.ts +18 -0
- package/src/xdocs/pluginSidebar.ts +580 -0
- package/src/xdocs/types.ts +26 -0
- package/vitest.config.ts +7 -0
- package/src/examples.ts +0 -116
- package/src/paths.ts +0 -103
- package/src/properties.ts +0 -37
- package/src/responses.ts +0 -38
- package/src/schema.ts +0 -62
|
@@ -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
|