Skip to content

Commit

Permalink
Generator: API: Handle empty endpoint path
Browse files Browse the repository at this point in the history
If the endpoint.URL.Path is empty, use the first path from endpoint.URL.Paths.

Related: elastic/elasticsearch#41452
(cherry picked from commit 234280d)
  • Loading branch information
karmi committed Jul 5, 2019
1 parent 37ae3d1 commit de7726c
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions internal/cmd/generate/commands/gensource/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ func NewEndpoint(f io.Reader) (*Endpoint, error) {
endpoint.URL.Paths = append(endpoint.URL.Paths, p.Path)
}

// Add Path when it's empty
if endpoint.URL.Path == "" {
endpoint.URL.Path = endpoint.URL.Paths[0]
}

for partName, p := range endpoint.URL.Parts {
p.Endpoint = &endpoint
p.Name = partName
Expand Down

0 comments on commit de7726c

Please sign in to comment.