Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions backend/api/model/crossdomain/plugin/openapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,12 +228,14 @@ func (op *Openapi3Operation) ToEinoSchemaParameterInfo(ctx context.Context) (map
Required: paramVal.Required,
}

if _, ok := result[paramVal.Name]; ok {
logs.CtxWarnf(ctx, "duplicate parameter name '%s'", paramVal.Name)
// Use location+name as unique key to allow same names in different locations
key := paramVal.In + "-" + paramVal.Name
if _, ok := result[key]; ok {
logs.CtxWarnf(ctx, "duplicate parameter in same location: %s@%s", paramVal.Name, paramVal.In)
continue
}

result[paramVal.Name] = paramInfo
result[key] = paramInfo
}

if op.RequestBody == nil || op.RequestBody.Value == nil || len(op.RequestBody.Value.Content) == 0 {
Expand All @@ -259,12 +261,14 @@ func (op *Openapi3Operation) ToEinoSchemaParameterInfo(ctx context.Context) (map
continue
}

if _, ok := result[paramName]; ok {
logs.CtxWarnf(ctx, "duplicate parameter name '%s'", paramName)
// Use location+name as unique key for body parameters
key := string(ParamInBody) + "-" + paramName
if _, ok := result[key]; ok {
logs.CtxWarnf(ctx, "duplicate parameter in same location: %s@%s", paramName, string(ParamInBody))
continue
}

result[paramName] = paramInfo
result[key] = paramInfo
}

break // Take only one MIME.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -366,16 +366,18 @@ export const handleIsShowDelete = (
return isShowDelete(data, targetKey);
};

// Check if the same name exists
// Check if the same name exists in the same location
export const checkSameName = (
data: Array<APIParameter>,
targetKey: string,
val: string,
): boolean | undefined => {
for (const item of data) {
if (item[ROWKEY] === targetKey) {
// Filter by both name and location to allow same names in different locations
const items = data.filter(
(dataItem: APIParameter) => dataItem.name === val,
(dataItem: APIParameter) =>
dataItem.name === val && dataItem.location === item.location,
);
return items.length > 1;
} else if (
Expand Down