Skip to content

fix: openapi: description length and default bearer auth #221

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 5, 2024
Merged
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
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