Skip to content

Commit b383cfc

Browse files
committed
🐛 fix: fix openapi export entry
1 parent 9b9c1f6 commit b383cfc

File tree

4 files changed

+336
-2
lines changed

4 files changed

+336
-2
lines changed

tests/__snapshots__/openapi.test.ts.snap

Lines changed: 332 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,248 @@
11
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
22

3+
exports[`OpenAPIConvertor > convertOpenAPIToPluginSchema > can convert OpenAPI v2 MJ openAPI 1`] = `
4+
[
5+
{
6+
"description": "查询所有账号",
7+
"name": "listUsingGET",
8+
"parameters": {
9+
"properties": {},
10+
"type": "object",
11+
},
12+
},
13+
{
14+
"description": "指定ID获取账号",
15+
"name": "fetchUsingGET",
16+
"parameters": {
17+
"properties": {
18+
"id": {
19+
"description": "账号ID",
20+
"type": "string",
21+
},
22+
},
23+
"type": "object",
24+
},
25+
},
26+
{
27+
"description": "提交Blend任务",
28+
"name": "blendUsingPOST",
29+
"parameters": {
30+
"properties": {
31+
"base64Array": {
32+
"description": "图片base64数组",
33+
"example": [
34+
"data:image/png;base64,xxx1",
35+
"data:image/png;base64,xxx2",
36+
],
37+
"items": {
38+
"type": "string",
39+
},
40+
"refType": "string",
41+
"type": "array",
42+
},
43+
"dimensions": {
44+
"description": "比例: PORTRAIT(2:3); SQUARE(1:1); LANDSCAPE(3:2)",
45+
"enum": [
46+
"PORTRAIT",
47+
"SQUARE",
48+
"LANDSCAPE",
49+
],
50+
"example": "SQUARE",
51+
"refType": null,
52+
"type": "string",
53+
},
54+
"notifyHook": {
55+
"description": "回调地址, 为空时使用全局notifyHook",
56+
"refType": null,
57+
"type": "string",
58+
},
59+
"state": {
60+
"description": "自定义参数",
61+
"refType": null,
62+
"type": "string",
63+
},
64+
},
65+
"required": [
66+
"base64Array",
67+
],
68+
"type": "object",
69+
},
70+
},
71+
{
72+
"description": "绘图变化",
73+
"name": "changeUsingPOST",
74+
"parameters": {
75+
"properties": {
76+
"action": {
77+
"description": "UPSCALE(放大); VARIATION(变换); REROLL(重新生成)",
78+
"enum": [
79+
"UPSCALE",
80+
"VARIATION",
81+
"REROLL",
82+
],
83+
"example": "UPSCALE",
84+
"type": "string",
85+
},
86+
"index": {
87+
"description": "序号(1~4), action为UPSCALE,VARIATION时必传",
88+
"example": 1,
89+
"exclusiveMaximum": false,
90+
"exclusiveMinimum": false,
91+
"format": "int32",
92+
"maximum": 4,
93+
"minimum": 1,
94+
"type": "integer",
95+
},
96+
"notifyHook": {
97+
"description": "回调地址, 为空时使用全局notifyHook",
98+
"type": "string",
99+
},
100+
"state": {
101+
"description": "自定义参数",
102+
"type": "string",
103+
},
104+
"taskId": {
105+
"description": "任务ID",
106+
"example": "1320098173412546",
107+
"type": "string",
108+
},
109+
},
110+
"required": [
111+
"action",
112+
"taskId",
113+
],
114+
"type": "object",
115+
},
116+
},
117+
{
118+
"description": "提交Describe任务",
119+
"name": "describeUsingPOST",
120+
"parameters": {
121+
"properties": {
122+
"base64": {
123+
"description": "图片base64",
124+
"example": "data:image/png;base64,xxx",
125+
"type": "string",
126+
},
127+
"notifyHook": {
128+
"description": "回调地址, 为空时使用全局notifyHook",
129+
"type": "string",
130+
},
131+
"state": {
132+
"description": "自定义参数",
133+
"type": "string",
134+
},
135+
},
136+
"required": [
137+
"base64",
138+
],
139+
"type": "object",
140+
},
141+
},
142+
{
143+
"description": "提交Imagine任务",
144+
"name": "imagineUsingPOST",
145+
"parameters": {
146+
"properties": {
147+
"base64Array": {
148+
"description": "垫图base64数组",
149+
"items": {
150+
"type": "string",
151+
},
152+
"type": "array",
153+
},
154+
"notifyHook": {
155+
"description": "回调地址, 为空时使用全局notifyHook",
156+
"type": "string",
157+
},
158+
"prompt": {
159+
"description": "提示词",
160+
"example": "Cat",
161+
"type": "string",
162+
},
163+
"state": {
164+
"description": "自定义参数",
165+
"type": "string",
166+
},
167+
},
168+
"required": [
169+
"prompt",
170+
],
171+
"type": "object",
172+
},
173+
},
174+
{
175+
"description": "绘图变化-simple",
176+
"name": "simpleChangeUsingPOST",
177+
"parameters": {
178+
"properties": {
179+
"content": {
180+
"description": "变化描述: ID $action$index",
181+
"example": "1320098173412546 U2",
182+
"type": "string",
183+
},
184+
"notifyHook": {
185+
"description": "回调地址, 为空时使用全局notifyHook",
186+
"type": "string",
187+
},
188+
"state": {
189+
"description": "自定义参数",
190+
"type": "string",
191+
},
192+
},
193+
"required": [
194+
"content",
195+
],
196+
"type": "object",
197+
},
198+
},
199+
{
200+
"description": "查询所有任务",
201+
"name": "listUsingGET_1",
202+
"parameters": {
203+
"properties": {},
204+
"type": "object",
205+
},
206+
},
207+
{
208+
"description": "根据ID列表查询任务",
209+
"name": "listByIdsUsingPOST",
210+
"parameters": {
211+
"properties": {
212+
"ids": {
213+
"items": {
214+
"type": "string",
215+
},
216+
"type": "array",
217+
},
218+
},
219+
"type": "object",
220+
},
221+
},
222+
{
223+
"description": "查询任务队列",
224+
"name": "queueUsingGET",
225+
"parameters": {
226+
"properties": {},
227+
"type": "object",
228+
},
229+
},
230+
{
231+
"description": "指定ID获取任务",
232+
"name": "fetchUsingGET_1",
233+
"parameters": {
234+
"properties": {
235+
"id": {
236+
"description": "任务ID",
237+
"type": "string",
238+
},
239+
},
240+
"type": "object",
241+
},
242+
},
243+
]
244+
`;
245+
3246
exports[`OpenAPIConvertor > convertOpenAPIToPluginSchema > can convert OpenAPI v3.0.2 openAPI 1`] = `
4247
[
5248
{
@@ -47,3 +290,92 @@ exports[`OpenAPIConvertor > convertOpenAPIToPluginSchema > can convert OpenAPI v
47290
},
48291
]
49292
`;
293+
294+
exports[`OpenAPIConvertor > convertOpenAPIToPluginSchema > can convert OpenAPI v3.1 to lobe apis 1`] = `
295+
[
296+
{
297+
"description": "Read Course Segments",
298+
"name": "read_course_segments_course_segments__get",
299+
"parameters": {
300+
"properties": {},
301+
"type": "object",
302+
},
303+
},
304+
{
305+
"description": "Read Problem Set Item",
306+
"name": "read_problem_set_item_problem_set__problem_set_id___question_number__get",
307+
"parameters": {
308+
"properties": {
309+
"problem_set_id": {
310+
"title": "Problem Set Id",
311+
"type": "integer",
312+
},
313+
"question_number": {
314+
"title": "Question Number",
315+
"type": "integer",
316+
},
317+
},
318+
"required": [
319+
"problem_set_id",
320+
"question_number",
321+
],
322+
"type": "object",
323+
},
324+
},
325+
{
326+
"description": "Read Random Problem Set Items",
327+
"name": "read_random_problem_set_items_problem_set_random__problem_set_id___n_items__get",
328+
"parameters": {
329+
"properties": {
330+
"n_items": {
331+
"title": "N Items",
332+
"type": "integer",
333+
},
334+
"problem_set_id": {
335+
"title": "Problem Set Id",
336+
"type": "integer",
337+
},
338+
},
339+
"required": [
340+
"problem_set_id",
341+
"n_items",
342+
],
343+
"type": "object",
344+
},
345+
},
346+
{
347+
"description": "Read Range Of Problem Set Items",
348+
"name": "read_range_of_problem_set_items_problem_set_range__problem_set_id___start___end__get",
349+
"parameters": {
350+
"properties": {
351+
"end": {
352+
"title": "End",
353+
"type": "integer",
354+
},
355+
"problem_set_id": {
356+
"title": "Problem Set Id",
357+
"type": "integer",
358+
},
359+
"start": {
360+
"title": "Start",
361+
"type": "integer",
362+
},
363+
},
364+
"required": [
365+
"problem_set_id",
366+
"start",
367+
"end",
368+
],
369+
"type": "object",
370+
},
371+
},
372+
{
373+
"description": "Read User Id",
374+
"name": "read_user_id_user__get",
375+
"parameters": {
376+
"properties": {},
377+
"type": "object",
378+
},
379+
},
380+
]
381+
`;

tests/openapi.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { OpenAPIConvertor } from '@lobehub/chat-plugin-sdk';
1+
import { OpenAPIConvertor } from '@lobehub/chat-plugin-sdk/openapi';
22
import { describe, expect, it } from 'vitest';
33

44
import OpenAPI_Auth_API_Key from './fixtures/OpenAPI_Auth_API_Key.json';

tests/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
"paths": {
1717
"@/*": [".src/*"],
1818
"@lobehub/chat-plugin-sdk": ["./src"],
19-
"@lobehub/chat-plugin-sdk/client": ["./src/client"]
19+
"@lobehub/chat-plugin-sdk/client": ["./src/client"],
20+
"@lobehub/chat-plugin-sdk/openapi": ["./src/openapi"]
2021
},
2122
"types": ["vitest/globals"]
2223
},

vitest.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export default defineConfig({
77
'@': path.join(__dirname, './src'),
88
'@lobehub/chat-plugin-sdk': path.join(__dirname, './src'),
99
'@lobehub/chat-plugin-sdk/client': path.join(__dirname, './src/client'),
10+
'@lobehub/chat-plugin-sdk/openapi': path.join(__dirname, './src/openapi'),
1011
},
1112
coverage: {
1213
reporter: ['text', 'text-summary', 'json', 'lcov'],

0 commit comments

Comments
 (0)