Skip to content

Commit

Permalink
fix: openapi: description length and default bearer auth (#221)
Browse files Browse the repository at this point in the history
Signed-off-by: Grant Linville <[email protected]>
  • Loading branch information
g-linville authored Apr 5, 2024
1 parent eb35802 commit 4074644
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pkg/engine/openapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,11 @@ func (e *Engine) runOpenAPI(tool types.Tool, input string) (*Return, error) {
}

// Check for authentication (only if using HTTPS)
if u.Scheme == "https" && len(instructions.SecurityInfos) > 0 {
if err := handleAuths(req, envMap, instructions.SecurityInfos); err != nil {
return nil, fmt.Errorf("error setting up authentication: %w", err)
if u.Scheme == "https" {
if len(instructions.SecurityInfos) > 0 {
if err := handleAuths(req, envMap, instructions.SecurityInfos); err != nil {
return nil, fmt.Errorf("error setting up authentication: %w", err)
}
}

// If there is a bearer token set for the whole server, and no Authorization header has been defined, use it.
Expand Down
4 changes: 4 additions & 0 deletions pkg/loader/openapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ func getOpenAPITools(t *openapi3.T, defaultHost string) ([]types.Tool, error) {
toolDesc = operation.Summary
}

if len(toolDesc) > 1024 {
toolDesc = toolDesc[:1024]
}

var (
// auths are represented as a list of maps, where each map contains the names of the required security schemes.
// Items within the same map are a logical AND. The maps themselves are a logical OR. For example:
Expand Down

0 comments on commit 4074644

Please sign in to comment.