Files
influx-cli/internal/api/templates
Daniel Moran f95668ada6 refactor: improve codegen to support influx query rewrite (#60)
* build: add goimports to fmt target to remove unused imports
* feat: update codegen template to support returning raw response body
* feat: add support for gunzip-ing response bodies
* refactor: remove unused piece from codegen return values
2021-05-05 10:30:22 -04:00
..

Custom OpenAPI Templates

This directory contains custom mustache templates used by the OpenAPI code generator. The original templates were extracted by running:

openapi-generator author template -g go

NOTE: This command extracts a copy of every template used by the generator, but we only track templates that we've modified here. The generator can handle sourcing templates from multiple locations.

What have we changed?

api.mustache

  • Add GetX() methods for each request parameter X, for use in unit tests
  • Add checks for isByteArray to generate []byte request fields instead of *string
  • Update creation of GenericOpenAPIError to track sub-error models by reference
  • Add checks for isResponseBinary to directly return the response-body-reader, instead of pulling the entire body into memory and transforming it into an *os.File
  • GUnzip response bodies when Content-Encoding: gzip is set
  • Remove *http.Responses from the return values of generated operations

client.mustache

  • Removed use of golang.org/x/oauth2 to avoid its heavy dependencies
  • Fixed error strings to be idiomatic according to staticcheck (lowercase, no punctuation)
  • Use strings.EqualFold instead of comparing two strings.ToLower calls
  • GZip request bodies when Content-Encoding: gzip is set
  • Update the GenericOpenAPIError type to enforce that error response models implement the error interface

configuration.mustache

  • Deleted ContextOAuth2 key to match modification in client
  • Fixed error strings to be idiomatic according to staticcheck (lowercase, no punctuation)