influxdb-client-go
influxdb-client-go copied to clipboard
feat(v3): optimized generated client code
Swagger generated code refactor according to the https://gist.github.com/rogpeppe/359e7465956e98bed4c5b9692b910a05:
- Single method for each operation
- Filtering operations only for those with JSON request body (POST and PATCH) and for those with a single JSON response with status code 2xx
- Returning concrete response type, instead of a wrapper
- Non 2xx responses result in error
- Single request parameter - path, query, cookie and header params merged into single struct along with request body
Requires oapi-codegen with extended template helpers: https://github.com/influxdata/oapi-codegen/pull/1
I've removed the default, not modified, templates
The goal of this PR is to review generated code.
In the general view, providing wrapper API over generated code is for having a consistent user-friendly API. As a first example, there is OrganizationAPI with a few implemented functions.
We will provide a getter for Client.apiClient so user can write a custom call to server using generated code.
I think that we should also consider relying upon the generated API, we can modify the templates to output documentation and links to the API doc. there are also comments from RogP that request improvements in the generated API, additional properties would be better represented as simple maps.
It would be also nice to distinguish our custom functions in the templates by some prefix, so it is then easier to read what are standard template functions and what are our extensions.
This PR has become obsolete. The modified templates and generated code are already used in the Go v2. The plan is to reuse the management API from Go v2 with a slightly modified API based on the Go V# API design.