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 589694b commit 4bceffe
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions internal/cmd/generate/commands/gensource/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,17 @@ func NewEndpoint(f io.Reader) (*Endpoint, error) {
endpoint = e
endpoint.Name = name
}

// Join "deprecated_paths" with paths
for _, p := range endpoint.URL.DeprecatedPaths {
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 4bceffe

Please sign in to comment.