Skip to content

Commit

Permalink
simplify generated code again
Browse files Browse the repository at this point in the history
  • Loading branch information
Karitham committed Aug 25, 2023
1 parent 0ac89ab commit 93ed632
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 32 deletions.
35 changes: 7 additions & 28 deletions examples/petstore-expanded/api/client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions templates/client.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,9 @@ func (c *Client) {{.OperationID}}(ctx context.Context
read := false // flag such that empty responses are kept nil
{{end -}}
{{range .GetResponseTypeDefinitions -}}
is{{.ResponseName}} := func(resp *http.Response) bool {
return resp.StatusCode {{.ResponseName | statusCodeRange}}
}
var _{{.ResponseName}} *{{.Schema.TypeDecl}}
handle{{.ResponseName}} := func(resp *http.Response) error {
if !is{{.ResponseName}}(resp) {
if resp.StatusCode {{.ResponseName | statusCodeRange}} {
return nil
}

Expand Down

0 comments on commit 93ed632

Please sign in to comment.