Skip to content

Commit

Permalink
Fix names of keyword arguments in examples (#560)
Browse files Browse the repository at this point in the history
## Changes
When generating the names of the arguments to use in methods named
XByYAndZ (e.g. DeleteByJobId), the field names are derived from the name
of the method. The logic for this was incorrect. This doesn't affect Go,
since Go examples don't use the `.Request()` method on `call` but
instead read from the call name and args directly.

## Tests
<!-- 
How is this tested? Please see the checklist below and also describe any
other relevant tests
-->

- [ ] `make test` passing
- [ ] `make fmt` applied
- [ ] relevant integration tests applied
  • Loading branch information
mgyucht authored Jul 26, 2023
1 parent b4fb746 commit 0ee49d8
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion openapi/roll/ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,11 @@ func (c *call) IsWait() bool {

func (c *call) Request() (fv []*fieldValue) {
if strings.Contains(c.Name, "By") {
fields := strings.Split(strings.Split(c.Name, "By")[0], "And")
// E.g. DeleteByJobId, DeleteByClusterIdAndWait
firstSplit := strings.SplitN(c.Name, "By", 2)
// And is used to separate field names, but some methods end with AndWait
joinedFields := strings.TrimSuffix(firstSplit[1], "AndWait")
fields := strings.Split(joinedFields, "And")
for i, name := range fields {
fv = append(fv, &fieldValue{
Named: code.Named{
Expand Down

0 comments on commit 0ee49d8

Please sign in to comment.