Skip to content

Commit 7dd6d2a

Browse files
committed
tool name improvements
Signed-off-by: Grant Linville <[email protected]>
1 parent 4eb4ba0 commit 7dd6d2a

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

pkg/engine/openapi.go

+18-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,15 @@ func (e *Engine) runOpenAPIRevamp(tool types.Tool, input string) (*Return, error
4343
return nil, fmt.Errorf("failed to load OpenAPI file %s: %w", source, err)
4444
}
4545

46-
opList, err := openapi.List(t, filter, "getSchema"+strings.TrimPrefix(tool.Name, "listOperations"))
46+
// The name of the getSchema tool will depend on whether the tool comes from GitHub or a local OpenAPI file.
47+
// If it comes from GitHub, it will be "getSchema{OpenAPI Title}".
48+
// If it comes from a file, it will be "{listOperationsToolName}0" (i.e. "openapi0").
49+
// Something in the tool normalization logic is what causes this difference.
50+
getSchemaToolName := tool.Name + "0"
51+
if strings.HasPrefix(tool.Name, "listOperations") {
52+
getSchemaToolName = "getSchema" + strings.TrimPrefix(tool.Name, "listOperations")
53+
}
54+
opList, err := openapi.List(t, filter, getSchemaToolName)
4755
if err != nil {
4856
return nil, fmt.Errorf("failed to list operations: %w", err)
4957
}
@@ -85,7 +93,15 @@ func (e *Engine) runOpenAPIRevamp(tool types.Tool, input string) (*Return, error
8593
defaultHost = u.Scheme + "://" + u.Hostname()
8694
}
8795

88-
schema, _, found, err := openapi.GetSchema(operation, defaultHost, "runOperation"+strings.TrimPrefix(tool.Name, "getSchema"), t)
96+
// The name of the run tool will depend on whether the tool comes from GitHub or a local OpenAPI file.
97+
// If it comes from GitHub, it will be "runOperation{OpenAPI Title}".
98+
// If it comes from a file, it will be "{getSchemaToolName}0" (i.e. "openapi00").
99+
// Something in the tool normalization logic is what causes this difference.
100+
runToolName := tool.Name + "0"
101+
if strings.HasPrefix(tool.Name, "getSchema") {
102+
runToolName = "runOperation" + strings.TrimPrefix(tool.Name, "getSchema")
103+
}
104+
schema, _, found, err := openapi.GetSchema(operation, defaultHost, runToolName, t)
89105
if err != nil {
90106
return nil, fmt.Errorf("failed to get schema: %w", err)
91107
}

0 commit comments

Comments
 (0)