Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
赵月辉
/
fastgpt-migrated
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Unverified
Commit
f351d4ea
authored
May 10, 2024
by
heheer
Committed by
GitHub
May 10, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: openapi integer & array type (#1439)
parent
d70efe1d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
12 deletions
+34
-12
packages/global/core/plugin/httpPlugin/utils.ts
+31
-9
projects/app/src/components/core/workflow/Flow/nodes/NodeLaf.tsx
+3
-3
No files found.
packages/global/core/plugin/httpPlugin/utils.ts
View file @
f351d4ea
...
@@ -52,13 +52,35 @@ export const str2OpenApiSchema = async (yamlStr = ''): Promise<OpenApiJsonSchema
...
@@ -52,13 +52,35 @@ export const str2OpenApiSchema = async (yamlStr = ''): Promise<OpenApiJsonSchema
})
})
.
flat
()
.
flat
()
.
filter
(
Boolean
)
as
OpenApiJsonSchema
[
'pathData'
];
.
filter
(
Boolean
)
as
OpenApiJsonSchema
[
'pathData'
];
return
{
pathData
,
serverPath
};
return
{
pathData
,
serverPath
};
}
catch
(
err
)
{
}
catch
(
err
)
{
throw
new
Error
(
'Invalid Schema'
);
throw
new
Error
(
'Invalid Schema'
);
}
}
};
};
export
const
getType
=
(
schema
:
{
type
:
string
;
items
?:
{
type
:
string
}
})
=>
{
const
typeMap
:
{
[
key
:
string
]:
WorkflowIOValueTypeEnum
}
=
{
string
:
WorkflowIOValueTypeEnum
.
arrayString
,
number
:
WorkflowIOValueTypeEnum
.
arrayNumber
,
integer
:
WorkflowIOValueTypeEnum
.
arrayNumber
,
boolean
:
WorkflowIOValueTypeEnum
.
arrayBoolean
,
object
:
WorkflowIOValueTypeEnum
.
arrayObject
};
if
(
schema
?.
type
===
'integer'
)
{
return
WorkflowIOValueTypeEnum
.
number
;
}
if
(
schema
?.
type
===
'array'
&&
schema
?.
items
)
{
const
itemType
=
typeMap
[
schema
.
items
.
type
];
if
(
itemType
)
{
return
itemType
;
}
}
return
schema
?.
type
as
WorkflowIOValueTypeEnum
;
};
export
const
httpApiSchema2Plugins
=
async
({
export
const
httpApiSchema2Plugins
=
async
({
parentId
,
parentId
,
apiSchemaStr
=
''
,
apiSchemaStr
=
''
,
...
@@ -87,7 +109,7 @@ export const httpApiSchema2Plugins = async ({
...
@@ -87,7 +109,7 @@ export const httpApiSchema2Plugins = async ({
...(
item
.
params
?.
map
((
param
:
any
)
=>
{
...(
item
.
params
?.
map
((
param
:
any
)
=>
{
return
{
return
{
key
:
param
.
name
,
key
:
param
.
name
,
valueType
:
param
.
schema
.
type
,
valueType
:
getType
(
param
.
schema
)
,
label
:
param
.
name
,
label
:
param
.
name
,
renderTypeList
:
[
FlowNodeInputTypeEnum
.
reference
],
renderTypeList
:
[
FlowNodeInputTypeEnum
.
reference
],
required
:
param
.
required
,
required
:
param
.
required
,
...
@@ -109,7 +131,7 @@ export const httpApiSchema2Plugins = async ({
...
@@ -109,7 +131,7 @@ export const httpApiSchema2Plugins = async ({
const
prop
=
properties
[
key
];
const
prop
=
properties
[
key
];
return
{
return
{
key
,
key
,
valueType
:
prop
.
type
,
valueType
:
getType
(
prop
)
,
label
:
key
,
label
:
key
,
renderTypeList
:
[
FlowNodeInputTypeEnum
.
reference
],
renderTypeList
:
[
FlowNodeInputTypeEnum
.
reference
],
required
:
false
,
required
:
false
,
...
@@ -136,7 +158,7 @@ export const httpApiSchema2Plugins = async ({
...
@@ -136,7 +158,7 @@ export const httpApiSchema2Plugins = async ({
return
{
return
{
id
,
id
,
key
:
param
.
name
,
key
:
param
.
name
,
valueType
:
param
.
schema
.
type
,
valueType
:
getType
(
param
.
schema
)
,
label
:
param
.
name
,
label
:
param
.
name
,
type
:
FlowNodeOutputTypeEnum
.
source
type
:
FlowNodeOutputTypeEnum
.
source
};
};
...
@@ -147,7 +169,7 @@ export const httpApiSchema2Plugins = async ({
...
@@ -147,7 +169,7 @@ export const httpApiSchema2Plugins = async ({
return
{
return
{
id
,
id
,
key
,
key
,
valueType
:
properties
[
key
].
type
,
valueType
:
getType
(
properties
[
key
])
,
label
:
key
,
label
:
key
,
type
:
FlowNodeOutputTypeEnum
.
source
,
type
:
FlowNodeOutputTypeEnum
.
source
,
edit
:
true
edit
:
true
...
@@ -159,7 +181,7 @@ export const httpApiSchema2Plugins = async ({
...
@@ -159,7 +181,7 @@ export const httpApiSchema2Plugins = async ({
...(
item
.
params
?.
map
((
param
:
any
)
=>
{
...(
item
.
params
?.
map
((
param
:
any
)
=>
{
return
{
return
{
key
:
param
.
name
,
key
:
param
.
name
,
valueType
:
param
.
schema
.
type
,
valueType
:
getType
(
param
.
schema
)
,
label
:
param
.
name
,
label
:
param
.
name
,
renderTypeList
:
[
FlowNodeInputTypeEnum
.
reference
],
renderTypeList
:
[
FlowNodeInputTypeEnum
.
reference
],
canEdit
:
true
,
canEdit
:
true
,
...
@@ -173,7 +195,7 @@ export const httpApiSchema2Plugins = async ({
...
@@ -173,7 +195,7 @@ export const httpApiSchema2Plugins = async ({
...(
propsKeys
?.
map
((
key
)
=>
{
...(
propsKeys
?.
map
((
key
)
=>
{
return
{
return
{
key
,
key
,
valueType
:
properties
[
key
].
type
,
valueType
:
getType
(
properties
[
key
])
,
label
:
key
,
label
:
key
,
renderTypeList
:
[
FlowNodeInputTypeEnum
.
reference
],
renderTypeList
:
[
FlowNodeInputTypeEnum
.
reference
],
canEdit
:
true
,
canEdit
:
true
,
...
@@ -197,7 +219,7 @@ export const httpApiSchema2Plugins = async ({
...
@@ -197,7 +219,7 @@ export const httpApiSchema2Plugins = async ({
if
(
param
.
in
===
'header'
)
{
if
(
param
.
in
===
'header'
)
{
httpNodeHeaders
.
push
({
httpNodeHeaders
.
push
({
key
:
param
.
name
,
key
:
param
.
name
,
type
:
param
.
schema
?.
type
||
WorkflowIOValueTypeEnum
.
string
,
type
:
getType
(
param
.
schema
)
||
WorkflowIOValueTypeEnum
.
string
,
value
:
`{{
${
param
.
name
}
}}`
value
:
`{{
${
param
.
name
}
}}`
});
});
}
else
if
(
param
.
in
===
'body'
)
{
}
else
if
(
param
.
in
===
'body'
)
{
...
@@ -209,7 +231,7 @@ export const httpApiSchema2Plugins = async ({
...
@@ -209,7 +231,7 @@ export const httpApiSchema2Plugins = async ({
}
else
if
(
param
.
in
===
'query'
)
{
}
else
if
(
param
.
in
===
'query'
)
{
httpNodeParams
.
push
({
httpNodeParams
.
push
({
key
:
param
.
name
,
key
:
param
.
name
,
type
:
param
.
schema
?.
type
||
WorkflowIOValueTypeEnum
.
string
,
type
:
getType
(
param
.
schema
)
||
WorkflowIOValueTypeEnum
.
string
,
value
:
`{{
${
param
.
name
}
}}`
value
:
`{{
${
param
.
name
}
}}`
});
});
}
}
...
...
projects/app/src/components/core/workflow/Flow/nodes/NodeLaf.tsx
View file @
f351d4ea
...
@@ -9,7 +9,7 @@ import { useTranslation } from 'next-i18next';
...
@@ -9,7 +9,7 @@ import { useTranslation } from 'next-i18next';
import
{
getLafAppDetail
}
from
'@/web/support/laf/api'
;
import
{
getLafAppDetail
}
from
'@/web/support/laf/api'
;
import
MySelect
from
'@fastgpt/web/components/common/MySelect'
;
import
MySelect
from
'@fastgpt/web/components/common/MySelect'
;
import
{
getApiSchemaByUrl
}
from
'@/web/core/plugin/api'
;
import
{
getApiSchemaByUrl
}
from
'@/web/core/plugin/api'
;
import
{
str2OpenApiSchema
}
from
'@fastgpt/global/core/plugin/httpPlugin/utils'
;
import
{
getType
,
str2OpenApiSchema
}
from
'@fastgpt/global/core/plugin/httpPlugin/utils'
;
import
{
useUserStore
}
from
'@/web/support/user/useUserStore'
;
import
{
useUserStore
}
from
'@/web/support/user/useUserStore'
;
import
{
useSystemStore
}
from
'@/web/common/system/useSystemStore'
;
import
{
useSystemStore
}
from
'@/web/common/system/useSystemStore'
;
import
{
ChevronRightIcon
}
from
'@chakra-ui/icons'
;
import
{
ChevronRightIcon
}
from
'@chakra-ui/icons'
;
...
@@ -155,7 +155,7 @@ const NodeLaf = (props: NodeProps<FlowNodeItemType>) => {
...
@@ -155,7 +155,7 @@ const NodeLaf = (props: NodeProps<FlowNodeItemType>) => {
desc
:
bodyParams
[
key
].
description
,
desc
:
bodyParams
[
key
].
description
,
required
:
requiredParams
?.
includes
(
key
)
||
false
,
required
:
requiredParams
?.
includes
(
key
)
||
false
,
value
:
`{{
${
key
}
}}`
,
value
:
`{{
${
key
}
}}`
,
type
:
bodyParams
[
key
].
type
type
:
getType
(
bodyParams
[
key
])
}))
}))
].
filter
((
item
)
=>
!
inputs
.
find
((
input
)
=>
input
.
key
===
item
.
name
));
].
filter
((
item
)
=>
!
inputs
.
find
((
input
)
=>
input
.
key
===
item
.
name
));
...
@@ -189,7 +189,7 @@ const NodeLaf = (props: NodeProps<FlowNodeItemType>) => {
...
@@ -189,7 +189,7 @@ const NodeLaf = (props: NodeProps<FlowNodeItemType>) => {
const
allResponseParams
=
[
const
allResponseParams
=
[
...
Object
.
keys
(
responseParams
).
map
((
key
)
=>
({
...
Object
.
keys
(
responseParams
).
map
((
key
)
=>
({
valueType
:
responseParams
[
key
].
type
,
valueType
:
getType
(
responseParams
[
key
])
,
name
:
key
,
name
:
key
,
desc
:
responseParams
[
key
].
description
,
desc
:
responseParams
[
key
].
description
,
required
:
requiredResponseParams
?.
includes
(
key
)
||
false
required
:
requiredResponseParams
?.
includes
(
key
)
||
false
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment