Skip to content

Commit

Permalink
feat: fix usage snippet lib parsing snake care operation IDs (#1299)
Browse files Browse the repository at this point in the history
The lib wasn't correctly parsing out snake case operation IDs causing
downstream issues

Also we weren't handling single operations vs multi operation requests
correctly
  • Loading branch information
ryan-timothy-albert authored Feb 27, 2025
1 parent 0f2899e commit 9a18e92
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion internal/usagegen/usagegen.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ func parseOperationInfoAndCodeSample(lang, usageOutputSection string) (*UsageSni
}

// Define a regular expression to capture the API name, method, and endpoint
apiDetailsRegex := regexp.MustCompile(`([/\w{}_]+)\s+\((\w+)\s+(.*)\)`)
apiDetailsRegex := regexp.MustCompile(`([\w{}_/-]+)\s+\((\w+)\s+(.*)\)`)

// Find and extract the API details
matches := apiDetailsRegex.FindStringSubmatch(parts[0])
Expand Down
2 changes: 1 addition & 1 deletion pkg/codesamples/codesamples.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func GenerateUsageSnippet(ctx context.Context, schema, header, token, configPath
specifiedOperation,
"",
filepath.Join(configPath, "speakeasyusagegen"),
true,
specifiedOperation == "",
usageOutput,
); err != nil {
return nil, err
Expand Down

0 comments on commit 9a18e92

Please sign in to comment.