Skip to content

Commit de7726c

Browse files
committed
Generator: API: Handle empty endpoint path
If the endpoint.URL.Path is empty, use the first path from endpoint.URL.Paths. Related: elastic/elasticsearch#41452 (cherry picked from commit 234280d)
1 parent 37ae3d1 commit de7726c

File tree

1 file changed

+5
-0
lines changed
  • internal/cmd/generate/commands/gensource

1 file changed

+5
-0
lines changed

internal/cmd/generate/commands/gensource/model.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ func NewEndpoint(f io.Reader) (*Endpoint, error) {
4242
endpoint.URL.Paths = append(endpoint.URL.Paths, p.Path)
4343
}
4444

45+
// Add Path when it's empty
46+
if endpoint.URL.Path == "" {
47+
endpoint.URL.Path = endpoint.URL.Paths[0]
48+
}
49+
4550
for partName, p := range endpoint.URL.Parts {
4651
p.Endpoint = &endpoint
4752
p.Name = partName

0 commit comments

Comments
 (0)