mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-23 13:03:50 +00:00
4.7 doc update (#1068)
* fix: plugin update * feat: get current time plugin * fix: ts * perf: select app ux * fix: ts * perf: max w * move code * perf: inform tip * fix: inform * doc * fix: tool handle * perf: tmp file store * doc * fix: message file selector * feat: doc * perf: switch trigger * doc * fix: openapi import * rount the number * parse openapi schema * fix empty line after variables (#64) * doc image * image size * doc * doc * catch error --------- Co-authored-by: heheer <71265218+newfish-cmyk@users.noreply.github.com>
This commit is contained in:
@@ -6,7 +6,7 @@ import { chatNodeSystemPromptTip } from './tip';
|
||||
|
||||
export const Input_Template_Switch: FlowNodeInputItemType = {
|
||||
key: ModuleInputKeyEnum.switch,
|
||||
type: FlowNodeInputTypeEnum.triggerAndFinish,
|
||||
type: FlowNodeInputTypeEnum.hidden,
|
||||
label: '',
|
||||
description: 'core.module.input.description.Trigger',
|
||||
valueType: ModuleIOValueTypeEnum.any,
|
||||
|
@@ -122,6 +122,7 @@ export const HttpModule468: FlowNodeTemplateType = {
|
||||
outputType: FlowNodeOutputTypeEnum.source,
|
||||
valueType: ModuleIOValueTypeEnum.string
|
||||
}
|
||||
}
|
||||
},
|
||||
Output_Template_Finish
|
||||
]
|
||||
};
|
||||
|
@@ -13,19 +13,21 @@ import { HttpParamAndHeaderItemType } from '../../module/api';
|
||||
import { CreateOnePluginParams } from '../controller';
|
||||
import { ModuleItemType } from '../../module/type';
|
||||
import { HttpImgUrl } from '../../../common/file/image/constants';
|
||||
import SwaggerParser from '@apidevtools/swagger-parser';
|
||||
|
||||
export const str2OpenApiSchema = (yamlStr = ''): OpenApiJsonSchema => {
|
||||
export const str2OpenApiSchema = async (yamlStr = ''): Promise<OpenApiJsonSchema> => {
|
||||
try {
|
||||
const data: OpenAPIV3.Document = (() => {
|
||||
const data = (() => {
|
||||
try {
|
||||
return JSON.parse(yamlStr);
|
||||
} catch (jsonError) {
|
||||
return yaml.load(yamlStr, { schema: yaml.FAILSAFE_SCHEMA });
|
||||
}
|
||||
})();
|
||||
const jsonSchema = (await SwaggerParser.parse(data)) as OpenAPIV3.Document;
|
||||
|
||||
const serverPath = data.servers?.[0].url || '';
|
||||
const pathData = Object.keys(data.paths)
|
||||
const serverPath = jsonSchema.servers?.[0].url || '';
|
||||
const pathData = Object.keys(jsonSchema.paths)
|
||||
.map((path) => {
|
||||
const methodData: any = data.paths[path];
|
||||
return Object.keys(methodData)
|
||||
@@ -55,7 +57,7 @@ export const str2OpenApiSchema = (yamlStr = ''): OpenApiJsonSchema => {
|
||||
}
|
||||
};
|
||||
|
||||
export const httpApiSchema2Plugins = ({
|
||||
export const httpApiSchema2Plugins = async ({
|
||||
parentId,
|
||||
apiSchemaStr = '',
|
||||
customHeader = ''
|
||||
@@ -63,8 +65,9 @@ export const httpApiSchema2Plugins = ({
|
||||
parentId: string;
|
||||
apiSchemaStr?: string;
|
||||
customHeader?: string;
|
||||
}): CreateOnePluginParams[] => {
|
||||
const jsonSchema = str2OpenApiSchema(apiSchemaStr);
|
||||
}): Promise<CreateOnePluginParams[]> => {
|
||||
const jsonSchema = await str2OpenApiSchema(apiSchemaStr);
|
||||
|
||||
const baseUrl = jsonSchema.serverPath;
|
||||
|
||||
return jsonSchema.pathData.map((item) => {
|
||||
@@ -222,7 +225,7 @@ export const httpApiSchema2Plugins = ({
|
||||
}
|
||||
}
|
||||
if (item.request) {
|
||||
const properties = item.request?.content?.['application/json']?.schema?.properties;
|
||||
const properties = item.request?.content?.['application/json']?.schema?.properties || {};
|
||||
const keys = Object.keys(properties);
|
||||
if (keys.length > 0) {
|
||||
httpNodeBody = JSON.stringify(
|
||||
|
Reference in New Issue
Block a user