refactor: update codegen to clean old files, use new extension (#57)

This commit is contained in:
Daniel Moran 2021-05-03 11:06:18 -04:00 committed by GitHub
parent 3414e1a983
commit cf2b2f2791
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
41 changed files with 12 additions and 182 deletions

View File

@ -2,10 +2,15 @@
declare -r ETC_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd)"
declare -r ROOT_DIR="$(dirname ${ETC_DIR})"
declare -r API_DIR="${ROOT_DIR}/internal/api"
declare -r GENERATED_PATTERN='^// Code generated .* DO NOT EDIT\.$'
declare -r GENERATOR_DOCKER_IMG=openapitools/openapi-generator-cli:v5.1.0
declare -r OPENAPI_COMMIT=e41d5e327a67e472a46cd6edfe673496e1b066dd
# Clean up all the generated files in the target directory.
rm $(grep -Elr "${GENERATED_PATTERN}" "${API_DIR}")
# Download our target API spec.
# NOTE: openapi-generator supports HTTP references to API docs, but using that feature
# causes the host of the URL to be injected into the base paths of generated code.
@ -25,9 +30,15 @@ docker run --rm -it -u "$(id -u):$(id -g)" \
# Edit the generated files.
(
# Clean up files we don't care about.
cd "${ROOT_DIR}/internal/api"
cd "${API_DIR}"
rm -rf go.mod go.sum git_push.sh api docs .openapi-generator .travis.yml .gitignore
# Change extension of generated files.
for f in $(grep -El "${GENERATED_PATTERN}" *.go); do
base=$(basename ${f} .go)
mv ${f} ${base}.gen.go
done
# Clean up the generated code.
cd "${ROOT_DIR}"
>/dev/null make fmt

View File

@ -1,181 +0,0 @@
/*
* Subset of Influx API covered by Influx CLI
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* API version: 2.0.0
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package api
import (
"encoding/json"
)
// BucketsLinks struct for BucketsLinks
type BucketsLinks struct {
// URI of resource.
Next *string `json:"next,omitempty"`
// URI of resource.
Self string `json:"self"`
// URI of resource.
Prev *string `json:"prev,omitempty"`
}
// NewBucketsLinks instantiates a new BucketsLinks object
// This constructor will assign default values to properties that have it defined,
// and makes sure properties required by API are set, but the set of arguments
// will change when the set of required properties is changed
func NewBucketsLinks(self string) *BucketsLinks {
this := BucketsLinks{}
this.Self = self
return &this
}
// NewBucketsLinksWithDefaults instantiates a new BucketsLinks object
// This constructor will only assign default values to properties that have it defined,
// but it doesn't guarantee that properties required by API are set
func NewBucketsLinksWithDefaults() *BucketsLinks {
this := BucketsLinks{}
return &this
}
// GetNext returns the Next field value if set, zero value otherwise.
func (o *BucketsLinks) GetNext() string {
if o == nil || o.Next == nil {
var ret string
return ret
}
return *o.Next
}
// GetNextOk returns a tuple with the Next field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *BucketsLinks) GetNextOk() (*string, bool) {
if o == nil || o.Next == nil {
return nil, false
}
return o.Next, true
}
// HasNext returns a boolean if a field has been set.
func (o *BucketsLinks) HasNext() bool {
if o != nil && o.Next != nil {
return true
}
return false
}
// SetNext gets a reference to the given string and assigns it to the Next field.
func (o *BucketsLinks) SetNext(v string) {
o.Next = &v
}
// GetSelf returns the Self field value
func (o *BucketsLinks) GetSelf() string {
if o == nil {
var ret string
return ret
}
return o.Self
}
// GetSelfOk returns a tuple with the Self field value
// and a boolean to check if the value has been set.
func (o *BucketsLinks) GetSelfOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.Self, true
}
// SetSelf sets field value
func (o *BucketsLinks) SetSelf(v string) {
o.Self = v
}
// GetPrev returns the Prev field value if set, zero value otherwise.
func (o *BucketsLinks) GetPrev() string {
if o == nil || o.Prev == nil {
var ret string
return ret
}
return *o.Prev
}
// GetPrevOk returns a tuple with the Prev field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *BucketsLinks) GetPrevOk() (*string, bool) {
if o == nil || o.Prev == nil {
return nil, false
}
return o.Prev, true
}
// HasPrev returns a boolean if a field has been set.
func (o *BucketsLinks) HasPrev() bool {
if o != nil && o.Prev != nil {
return true
}
return false
}
// SetPrev gets a reference to the given string and assigns it to the Prev field.
func (o *BucketsLinks) SetPrev(v string) {
o.Prev = &v
}
func (o BucketsLinks) MarshalJSON() ([]byte, error) {
toSerialize := map[string]interface{}{}
if o.Next != nil {
toSerialize["next"] = o.Next
}
if true {
toSerialize["self"] = o.Self
}
if o.Prev != nil {
toSerialize["prev"] = o.Prev
}
return json.Marshal(toSerialize)
}
type NullableBucketsLinks struct {
value *BucketsLinks
isSet bool
}
func (v NullableBucketsLinks) Get() *BucketsLinks {
return v.value
}
func (v *NullableBucketsLinks) Set(val *BucketsLinks) {
v.value = val
v.isSet = true
}
func (v NullableBucketsLinks) IsSet() bool {
return v.isSet
}
func (v *NullableBucketsLinks) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableBucketsLinks(val *BucketsLinks) *NullableBucketsLinks {
return &NullableBucketsLinks{value: val, isSet: true}
}
func (v NullableBucketsLinks) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableBucketsLinks) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}