From 2e57e1abb09fddbae507050e0299f7990c8cb5b5 Mon Sep 17 00:00:00 2001 From: Xiang Zhang Date: Thu, 21 Nov 2024 10:54:09 +0800 Subject: [PATCH] fix invalid swagger and upgrade to go 1.23 (#253) --- .github/workflows/lint.yml | 4 +- .golangci.yml | 2 +- Makefile | 6 +- go.mod | 2 +- pkg/go.mod | 2 +- .../v1beta1/serverless/cluster.swagger.json | 21 ++-- .../cluster/.openapi-generator/FILES | 1 + .../v1beta1/serverless/cluster/README.md | 1 + .../serverless/cluster/api/openapi.yaml | 19 ++- .../model_cluster_high_availability_type.go | 110 ++++++++++++++++++ ...cloud_open_apiserverlessv1beta1_cluster.go | 39 ++++++- ...erverlessv1beta1_create_cluster_request.go | 57 ++++----- 12 files changed, 210 insertions(+), 54 deletions(-) create mode 100644 pkg/tidbcloud/v1beta1/serverless/cluster/model_cluster_high_availability_type.go diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 74ef459a..0913121c 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -28,9 +28,9 @@ jobs: go-version-file: './go.mod' - name: golangci-lint - uses: golangci/golangci-lint-action@v3.3.0 + uses: golangci/golangci-lint-action@v6 with: - version: v1.56.2 + version: v1.62.0 fmt: name: fmt diff --git a/.golangci.yml b/.golangci.yml index 530b0cfd..ec3319d6 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -7,7 +7,6 @@ linters: - bodyclose - durationcheck - errcheck - - exportloopref - goimports - gosec - gosimple @@ -31,6 +30,7 @@ linters-settings: confidence: "low" excludes: - G101 + - G115 - G404 # exclude warnings of using crypto/sha1 - G505 diff --git a/Makefile b/Makefile index d0c9fe2e..1af5da21 100644 --- a/Makefile +++ b/Makefile @@ -31,7 +31,7 @@ generate-pingchat-client: ## Generate PingChat client @echo "==> Generating PingChat client" rm -rf pkg/tidbcloud/pingchat cd tools/openapi-generator && npx openapi-generator-cli generate --inline-schema-options RESOLVE_INLINE_ENUMS=true --additional-properties=withGoMod=false,enumClassPrefix=true --global-property=apiTests=false,apiDocs=false,modelDocs=false,modelTests=false -i ../../pkg/tidbcloud/pingchat.swagger.json -g go -o ../../pkg/tidbcloud/pingchat --package-name pingchat - go fmt ./pkg/tidbcloud/pingchat/... + cd pkg && go fmt ./tidbcloud/pingchat/... .PHONY: addcopy addcopy: ## Add copyright to all files @@ -44,7 +44,7 @@ generate-v1beta1-client: install-openapi-generator ## Generate v1beta1 client cd tools/openapi-generator && npx openapi-generator-cli generate --inline-schema-options RESOLVE_INLINE_ENUMS=true --additional-properties=withGoMod=false,enumClassPrefix=true,disallowAdditionalPropertiesIfNotPresent=false --global-property=apiTests=false,apiDocs=false,modelDocs=false,modelTests=false -i ../../pkg/tidbcloud/v1beta1/serverless/branch.swagger.json -g go -o ../../pkg/tidbcloud/v1beta1/serverless/branch --package-name branch @echo "==> Generating serverless cluster client" rm -rf pkg/tidbcloud/v1beta1/serverless/cluster - cd tools/openapi-generator && npx openapi-generator-cli generate --inline-schema-options RESOLVE_INLINE_ENUMS=true --additional-properties=withGoMod=false,enumClassPrefix=true,disallowAdditionalPropertiesIfNotPresent=false --global-property=apiTests=false,apiDocs=false,modelDocs=false,modelTests=false -i ../../pkg/tidbcloud/v1beta1/serverless/cluster.swagger.json -g go -o ../../pkg/tidbcloud/v1beta1/serverless/cluster --package-name cluster --skip-validate-spec + cd tools/openapi-generator && npx openapi-generator-cli generate --inline-schema-options RESOLVE_INLINE_ENUMS=true --additional-properties=withGoMod=false,enumClassPrefix=true,disallowAdditionalPropertiesIfNotPresent=false --global-property=apiTests=false,apiDocs=false,modelDocs=false,modelTests=false -i ../../pkg/tidbcloud/v1beta1/serverless/cluster.swagger.json -g go -o ../../pkg/tidbcloud/v1beta1/serverless/cluster --package-name cluster @echo "==> Generating serverless export client" rm -rf pkg/tidbcloud/v1beta1/serverless/export cd tools/openapi-generator && npx openapi-generator-cli generate --inline-schema-options RESOLVE_INLINE_ENUMS=true --additional-properties=withGoMod=false,enumClassPrefix=true,disallowAdditionalPropertiesIfNotPresent=false --global-property=apiTests=false,apiDocs=false,modelDocs=false,modelTests=false -i ../../pkg/tidbcloud/v1beta1/serverless/export.swagger.json -g go -o ../../pkg/tidbcloud/v1beta1/serverless/export --package-name export @@ -57,7 +57,7 @@ generate-v1beta1-client: install-openapi-generator ## Generate v1beta1 client @echo "==> Generating serverless import client" rm -rf pkg/tidbcloud/v1beta1/serverless/imp cd tools/openapi-generator && npx openapi-generator-cli generate --inline-schema-options RESOLVE_INLINE_ENUMS=true --additional-properties=withGoMod=false,enumClassPrefix=true,disallowAdditionalPropertiesIfNotPresent=false --global-property=apiTests=false,apiDocs=false,modelDocs=false,modelTests=false -i ../../pkg/tidbcloud/v1beta1/serverless/import.swagger.json -g go -o ../../pkg/tidbcloud/v1beta1/serverless/imp --package-name imp - go fmt ./pkg/tidbcloud/v1beta1/... + cd pkg && go fmt ./tidbcloud/v1beta1/... .PHONY: install-openapi-generator install-openapi-generator: diff --git a/go.mod b/go.mod index afed64c8..e085a0d7 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/tidbcloud/tidbcloud-cli -go 1.22 +go 1.23 require ( github.com/AlecAivazis/survey/v2 v2.3.6 diff --git a/pkg/go.mod b/pkg/go.mod index 6e85ac08..e36c610b 100644 --- a/pkg/go.mod +++ b/pkg/go.mod @@ -1,3 +1,3 @@ module github.com/tidbcloud/tidbcloud-cli/pkg -go 1.22 +go 1.23 diff --git a/pkg/tidbcloud/v1beta1/serverless/cluster.swagger.json b/pkg/tidbcloud/v1beta1/serverless/cluster.swagger.json index 53b062e3..46df0c1d 100644 --- a/pkg/tidbcloud/v1beta1/serverless/cluster.swagger.json +++ b/pkg/tidbcloud/v1beta1/serverless/cluster.swagger.json @@ -107,10 +107,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/tidb_cloud_open_apiserverlessv1beta1Cluster", - "required": [ - "cluster" - ] + "$ref": "#/definitions/tidb_cloud_open_apiserverlessv1beta1Cluster" } } ], @@ -378,6 +375,14 @@ } }, "definitions": { + "ClusterHighAvailabilityType": { + "type": "string", + "enum": [ + "ZONAL", + "REGIONAL" + ], + "title": "- ZONAL: High availability within a single zone\n - REGIONAL: High availability across multiple zones within a region" + }, "ClusterSpendingLimit": { "type": "object", "properties": { @@ -648,6 +653,9 @@ } ] }, + "highAvailabilityType": { + "$ref": "#/definitions/ClusterHighAvailabilityType" + }, "version": { "type": "string", "description": "Output_only. The TiDB version of the cluster.", @@ -727,10 +735,7 @@ ] } }, - "description": "Message for requesting to create a TiDB Cloud Serverless cluster.", - "required": [ - "cluster" - ] + "description": "Message for requesting to create a TiDB Cloud Serverless cluster." }, "tidb_cloud_open_apiserverlessv1beta1ListClustersResponse": { "type": "object", diff --git a/pkg/tidbcloud/v1beta1/serverless/cluster/.openapi-generator/FILES b/pkg/tidbcloud/v1beta1/serverless/cluster/.openapi-generator/FILES index d5c3e76e..12536a2f 100644 --- a/pkg/tidbcloud/v1beta1/serverless/cluster/.openapi-generator/FILES +++ b/pkg/tidbcloud/v1beta1/serverless/cluster/.openapi-generator/FILES @@ -7,6 +7,7 @@ api_serverless_service.go client.go configuration.go git_push.sh +model_cluster_high_availability_type.go model_cluster_spending_limit.go model_commonv1beta1_cluster_state.go model_commonv1beta1_region.go diff --git a/pkg/tidbcloud/v1beta1/serverless/cluster/README.md b/pkg/tidbcloud/v1beta1/serverless/cluster/README.md index 78010242..b686e1d5 100644 --- a/pkg/tidbcloud/v1beta1/serverless/cluster/README.md +++ b/pkg/tidbcloud/v1beta1/serverless/cluster/README.md @@ -91,6 +91,7 @@ Class | Method | HTTP request | Description ## Documentation For Models + - [ClusterHighAvailabilityType](docs/ClusterHighAvailabilityType.md) - [ClusterSpendingLimit](docs/ClusterSpendingLimit.md) - [Commonv1beta1ClusterState](docs/Commonv1beta1ClusterState.md) - [Commonv1beta1Region](docs/Commonv1beta1Region.md) diff --git a/pkg/tidbcloud/v1beta1/serverless/cluster/api/openapi.yaml b/pkg/tidbcloud/v1beta1/serverless/cluster/api/openapi.yaml index a2993446..dcde0b62 100644 --- a/pkg/tidbcloud/v1beta1/serverless/cluster/api/openapi.yaml +++ b/pkg/tidbcloud/v1beta1/serverless/cluster/api/openapi.yaml @@ -304,6 +304,14 @@ paths: - ServerlessService components: schemas: + ClusterHighAvailabilityType: + enum: + - ZONAL + - REGIONAL + title: |- + - ZONAL: High availability within a single zone + - REGIONAL: High availability across multiple zones within a region + type: string ClusterSpendingLimit: description: Message for spending limit configuration. properties: @@ -652,6 +660,7 @@ components: spendingLimit: "{}" createdBy: createdBy createTime: 2000-01-23T04:56:07.000+00:00 + highAvailabilityType: ZONAL name: name userPrefix: userPrefix state: "{}" @@ -700,6 +709,8 @@ components: - $ref: '#/components/schemas/v1beta1ClusterEncryptionConfig' description: Optional. Encryption settings for the cluster. type: object + highAvailabilityType: + $ref: '#/components/schemas/ClusterHighAvailabilityType' version: description: Output_only. The TiDB version of the cluster. readOnly: true @@ -761,8 +772,6 @@ components: - $ref: '#/components/schemas/tidb_cloud_open_apiserverlessv1beta1Cluster' description: Required. The cluster to be created. type: object - required: - - cluster type: object tidb_cloud_open_apiserverlessv1beta1ListClustersResponse: description: Responses message to the request for listing of TiDB Cloud Serverless @@ -786,6 +795,7 @@ components: spendingLimit: "{}" createdBy: createdBy createTime: 2000-01-23T04:56:07.000+00:00 + highAvailabilityType: ZONAL name: name userPrefix: userPrefix state: "{}" @@ -806,6 +816,7 @@ components: spendingLimit: "{}" createdBy: createdBy createTime: 2000-01-23T04:56:07.000+00:00 + highAvailabilityType: ZONAL name: name userPrefix: userPrefix state: "{}" @@ -881,6 +892,7 @@ components: spendingLimit: "{}" createdBy: createdBy createTime: 2000-01-23T04:56:07.000+00:00 + highAvailabilityType: ZONAL name: name userPrefix: userPrefix state: "{}" @@ -901,6 +913,7 @@ components: spendingLimit: "{}" createdBy: createdBy createTime: 2000-01-23T04:56:07.000+00:00 + highAvailabilityType: ZONAL name: name userPrefix: userPrefix state: "{}" @@ -933,6 +946,7 @@ components: spendingLimit: "{}" createdBy: createdBy createTime: 2000-01-23T04:56:07.000+00:00 + highAvailabilityType: ZONAL name: name userPrefix: userPrefix state: "{}" @@ -953,6 +967,7 @@ components: spendingLimit: "{}" createdBy: createdBy createTime: 2000-01-23T04:56:07.000+00:00 + highAvailabilityType: ZONAL name: name userPrefix: userPrefix state: "{}" diff --git a/pkg/tidbcloud/v1beta1/serverless/cluster/model_cluster_high_availability_type.go b/pkg/tidbcloud/v1beta1/serverless/cluster/model_cluster_high_availability_type.go new file mode 100644 index 00000000..ff24a488 --- /dev/null +++ b/pkg/tidbcloud/v1beta1/serverless/cluster/model_cluster_high_availability_type.go @@ -0,0 +1,110 @@ +/* +TiDB Cloud Serverless Open API + +TiDB Cloud Serverless Open API + +API version: v1beta1 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package cluster + +import ( + "encoding/json" + "fmt" +) + +// ClusterHighAvailabilityType the model 'ClusterHighAvailabilityType' +type ClusterHighAvailabilityType string + +// List of ClusterHighAvailabilityType +const ( + CLUSTERHIGHAVAILABILITYTYPE_ZONAL ClusterHighAvailabilityType = "ZONAL" + CLUSTERHIGHAVAILABILITYTYPE_REGIONAL ClusterHighAvailabilityType = "REGIONAL" +) + +// All allowed values of ClusterHighAvailabilityType enum +var AllowedClusterHighAvailabilityTypeEnumValues = []ClusterHighAvailabilityType{ + "ZONAL", + "REGIONAL", +} + +func (v *ClusterHighAvailabilityType) UnmarshalJSON(src []byte) error { + var value string + err := json.Unmarshal(src, &value) + if err != nil { + return err + } + enumTypeValue := ClusterHighAvailabilityType(value) + for _, existing := range AllowedClusterHighAvailabilityTypeEnumValues { + if existing == enumTypeValue { + *v = enumTypeValue + return nil + } + } + + return fmt.Errorf("%+v is not a valid ClusterHighAvailabilityType", value) +} + +// NewClusterHighAvailabilityTypeFromValue returns a pointer to a valid ClusterHighAvailabilityType +// for the value passed as argument, or an error if the value passed is not allowed by the enum +func NewClusterHighAvailabilityTypeFromValue(v string) (*ClusterHighAvailabilityType, error) { + ev := ClusterHighAvailabilityType(v) + if ev.IsValid() { + return &ev, nil + } else { + return nil, fmt.Errorf("invalid value '%v' for ClusterHighAvailabilityType: valid values are %v", v, AllowedClusterHighAvailabilityTypeEnumValues) + } +} + +// IsValid return true if the value is valid for the enum, false otherwise +func (v ClusterHighAvailabilityType) IsValid() bool { + for _, existing := range AllowedClusterHighAvailabilityTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to ClusterHighAvailabilityType value +func (v ClusterHighAvailabilityType) Ptr() *ClusterHighAvailabilityType { + return &v +} + +type NullableClusterHighAvailabilityType struct { + value *ClusterHighAvailabilityType + isSet bool +} + +func (v NullableClusterHighAvailabilityType) Get() *ClusterHighAvailabilityType { + return v.value +} + +func (v *NullableClusterHighAvailabilityType) Set(val *ClusterHighAvailabilityType) { + v.value = val + v.isSet = true +} + +func (v NullableClusterHighAvailabilityType) IsSet() bool { + return v.isSet +} + +func (v *NullableClusterHighAvailabilityType) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableClusterHighAvailabilityType(val *ClusterHighAvailabilityType) *NullableClusterHighAvailabilityType { + return &NullableClusterHighAvailabilityType{value: val, isSet: true} +} + +func (v NullableClusterHighAvailabilityType) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableClusterHighAvailabilityType) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/pkg/tidbcloud/v1beta1/serverless/cluster/model_tidb_cloud_open_apiserverlessv1beta1_cluster.go b/pkg/tidbcloud/v1beta1/serverless/cluster/model_tidb_cloud_open_apiserverlessv1beta1_cluster.go index c3189485..c7495e6b 100644 --- a/pkg/tidbcloud/v1beta1/serverless/cluster/model_tidb_cloud_open_apiserverlessv1beta1_cluster.go +++ b/pkg/tidbcloud/v1beta1/serverless/cluster/model_tidb_cloud_open_apiserverlessv1beta1_cluster.go @@ -37,7 +37,8 @@ type TidbCloudOpenApiserverlessv1beta1Cluster struct { Endpoints *V1beta1ClusterEndpoints `json:"endpoints,omitempty"` RootPassword *string `json:"rootPassword,omitempty" validate:"regexp=^.{8,64}$"` // Optional. Encryption settings for the cluster. - EncryptionConfig *V1beta1ClusterEncryptionConfig `json:"encryptionConfig,omitempty"` + EncryptionConfig *V1beta1ClusterEncryptionConfig `json:"encryptionConfig,omitempty"` + HighAvailabilityType *ClusterHighAvailabilityType `json:"highAvailabilityType,omitempty"` // Output_only. The TiDB version of the cluster. Version *string `json:"version,omitempty"` // Output_only. The email of the creator of the cluster. @@ -352,6 +353,38 @@ func (o *TidbCloudOpenApiserverlessv1beta1Cluster) SetEncryptionConfig(v V1beta1 o.EncryptionConfig = &v } +// GetHighAvailabilityType returns the HighAvailabilityType field value if set, zero value otherwise. +func (o *TidbCloudOpenApiserverlessv1beta1Cluster) GetHighAvailabilityType() ClusterHighAvailabilityType { + if o == nil || IsNil(o.HighAvailabilityType) { + var ret ClusterHighAvailabilityType + return ret + } + return *o.HighAvailabilityType +} + +// GetHighAvailabilityTypeOk returns a tuple with the HighAvailabilityType field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *TidbCloudOpenApiserverlessv1beta1Cluster) GetHighAvailabilityTypeOk() (*ClusterHighAvailabilityType, bool) { + if o == nil || IsNil(o.HighAvailabilityType) { + return nil, false + } + return o.HighAvailabilityType, true +} + +// HasHighAvailabilityType returns a boolean if a field has been set. +func (o *TidbCloudOpenApiserverlessv1beta1Cluster) HasHighAvailabilityType() bool { + if o != nil && !IsNil(o.HighAvailabilityType) { + return true + } + + return false +} + +// SetHighAvailabilityType gets a reference to the given ClusterHighAvailabilityType and assigns it to the HighAvailabilityType field. +func (o *TidbCloudOpenApiserverlessv1beta1Cluster) SetHighAvailabilityType(v ClusterHighAvailabilityType) { + o.HighAvailabilityType = &v +} + // GetVersion returns the Version field value if set, zero value otherwise. func (o *TidbCloudOpenApiserverlessv1beta1Cluster) GetVersion() string { if o == nil || IsNil(o.Version) { @@ -673,6 +706,9 @@ func (o TidbCloudOpenApiserverlessv1beta1Cluster) ToMap() (map[string]interface{ if !IsNil(o.EncryptionConfig) { toSerialize["encryptionConfig"] = o.EncryptionConfig } + if !IsNil(o.HighAvailabilityType) { + toSerialize["highAvailabilityType"] = o.HighAvailabilityType + } if !IsNil(o.Version) { toSerialize["version"] = o.Version } @@ -753,6 +789,7 @@ func (o *TidbCloudOpenApiserverlessv1beta1Cluster) UnmarshalJSON(data []byte) (e delete(additionalProperties, "endpoints") delete(additionalProperties, "rootPassword") delete(additionalProperties, "encryptionConfig") + delete(additionalProperties, "highAvailabilityType") delete(additionalProperties, "version") delete(additionalProperties, "createdBy") delete(additionalProperties, "userPrefix") diff --git a/pkg/tidbcloud/v1beta1/serverless/cluster/model_tidb_cloud_open_apiserverlessv1beta1_create_cluster_request.go b/pkg/tidbcloud/v1beta1/serverless/cluster/model_tidb_cloud_open_apiserverlessv1beta1_create_cluster_request.go index b8cbb2bb..1500a888 100644 --- a/pkg/tidbcloud/v1beta1/serverless/cluster/model_tidb_cloud_open_apiserverlessv1beta1_create_cluster_request.go +++ b/pkg/tidbcloud/v1beta1/serverless/cluster/model_tidb_cloud_open_apiserverlessv1beta1_create_cluster_request.go @@ -12,7 +12,6 @@ package cluster import ( "encoding/json" - "fmt" ) // checks if the TidbCloudOpenApiserverlessv1beta1CreateClusterRequest type satisfies the MappedNullable interface at compile time @@ -21,7 +20,7 @@ var _ MappedNullable = &TidbCloudOpenApiserverlessv1beta1CreateClusterRequest{} // TidbCloudOpenApiserverlessv1beta1CreateClusterRequest Message for requesting to create a TiDB Cloud Serverless cluster. type TidbCloudOpenApiserverlessv1beta1CreateClusterRequest struct { // Required. The cluster to be created. - Cluster TidbCloudOpenApiserverlessv1beta1Cluster `json:"cluster"` + Cluster *TidbCloudOpenApiserverlessv1beta1Cluster `json:"cluster,omitempty"` AdditionalProperties map[string]interface{} } @@ -31,9 +30,8 @@ type _TidbCloudOpenApiserverlessv1beta1CreateClusterRequest TidbCloudOpenApiserv // 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 NewTidbCloudOpenApiserverlessv1beta1CreateClusterRequest(cluster TidbCloudOpenApiserverlessv1beta1Cluster) *TidbCloudOpenApiserverlessv1beta1CreateClusterRequest { +func NewTidbCloudOpenApiserverlessv1beta1CreateClusterRequest() *TidbCloudOpenApiserverlessv1beta1CreateClusterRequest { this := TidbCloudOpenApiserverlessv1beta1CreateClusterRequest{} - this.Cluster = cluster return &this } @@ -45,28 +43,36 @@ func NewTidbCloudOpenApiserverlessv1beta1CreateClusterRequestWithDefaults() *Tid return &this } -// GetCluster returns the Cluster field value +// GetCluster returns the Cluster field value if set, zero value otherwise. func (o *TidbCloudOpenApiserverlessv1beta1CreateClusterRequest) GetCluster() TidbCloudOpenApiserverlessv1beta1Cluster { - if o == nil { + if o == nil || IsNil(o.Cluster) { var ret TidbCloudOpenApiserverlessv1beta1Cluster return ret } - - return o.Cluster + return *o.Cluster } -// GetClusterOk returns a tuple with the Cluster field value +// GetClusterOk returns a tuple with the Cluster field value if set, nil otherwise // and a boolean to check if the value has been set. func (o *TidbCloudOpenApiserverlessv1beta1CreateClusterRequest) GetClusterOk() (*TidbCloudOpenApiserverlessv1beta1Cluster, bool) { - if o == nil { + if o == nil || IsNil(o.Cluster) { return nil, false } - return &o.Cluster, true + return o.Cluster, true +} + +// HasCluster returns a boolean if a field has been set. +func (o *TidbCloudOpenApiserverlessv1beta1CreateClusterRequest) HasCluster() bool { + if o != nil && !IsNil(o.Cluster) { + return true + } + + return false } -// SetCluster sets field value +// SetCluster gets a reference to the given TidbCloudOpenApiserverlessv1beta1Cluster and assigns it to the Cluster field. func (o *TidbCloudOpenApiserverlessv1beta1CreateClusterRequest) SetCluster(v TidbCloudOpenApiserverlessv1beta1Cluster) { - o.Cluster = v + o.Cluster = &v } func (o TidbCloudOpenApiserverlessv1beta1CreateClusterRequest) MarshalJSON() ([]byte, error) { @@ -79,7 +85,9 @@ func (o TidbCloudOpenApiserverlessv1beta1CreateClusterRequest) MarshalJSON() ([] func (o TidbCloudOpenApiserverlessv1beta1CreateClusterRequest) ToMap() (map[string]interface{}, error) { toSerialize := map[string]interface{}{} - toSerialize["cluster"] = o.Cluster + if !IsNil(o.Cluster) { + toSerialize["cluster"] = o.Cluster + } for key, value := range o.AdditionalProperties { toSerialize[key] = value @@ -89,27 +97,6 @@ func (o TidbCloudOpenApiserverlessv1beta1CreateClusterRequest) ToMap() (map[stri } func (o *TidbCloudOpenApiserverlessv1beta1CreateClusterRequest) UnmarshalJSON(data []byte) (err error) { - // This validates that all required properties are included in the JSON object - // by unmarshalling the object into a generic map with string keys and checking - // that every required field exists as a key in the generic map. - requiredProperties := []string{ - "cluster", - } - - allProperties := make(map[string]interface{}) - - err = json.Unmarshal(data, &allProperties) - - if err != nil { - return err - } - - for _, requiredProperty := range requiredProperties { - if _, exists := allProperties[requiredProperty]; !exists { - return fmt.Errorf("no value given for required property %v", requiredProperty) - } - } - varTidbCloudOpenApiserverlessv1beta1CreateClusterRequest := _TidbCloudOpenApiserverlessv1beta1CreateClusterRequest{} err = json.Unmarshal(data, &varTidbCloudOpenApiserverlessv1beta1CreateClusterRequest)