From ab093fd26e96c709601b0f5fd9f7d310e008bb1d Mon Sep 17 00:00:00 2001 From: Murad Biashimov Date: Wed, 22 Jan 2025 11:51:47 +0100 Subject: [PATCH] feat: mark project vpc id nullable (#227) --- generator/main.go | 4 +++- generator/models.go | 1 + handler/service/service.go | 4 ++-- openapi_patch.yaml | 10 ++++++++++ 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/generator/main.go b/generator/main.go index c36995e..c03e001 100644 --- a/generator/main.go +++ b/generator/main.go @@ -553,7 +553,9 @@ func fmtStruct(s *Schema) *jen.Statement { // Adds json tags tag := jsonName - if !p.required { + if !(p.required || p.Nullable) { + // There are optional nullable fields. + // Which become required in Go. tag += ",omitempty" } diff --git a/generator/models.go b/generator/models.go index 3846f76..692b7c4 100644 --- a/generator/models.go +++ b/generator/models.go @@ -163,6 +163,7 @@ type Schema struct { Ref string `json:"$ref"` Description string `json:"description"` CamelName string `json:"for-hash-only!"` + Nullable bool `json:"nullable"` required bool name string propertyNames []string diff --git a/handler/service/service.go b/handler/service/service.go index be3e37e..f8ed2cb 100644 --- a/handler/service/service.go +++ b/handler/service/service.go @@ -1814,7 +1814,7 @@ type ServiceCreateIn struct { GroupName *string `json:"group_name,omitempty"` // Service group name (DEPRECATED: do not use) Maintenance *MaintenanceIn `json:"maintenance,omitempty"` // Automatic maintenance settings Plan string `json:"plan"` // Subscription plan - ProjectVpcId *string `json:"project_vpc_id,omitempty"` // Project VPC ID + ProjectVpcId *string `json:"project_vpc_id"` // Project VPC ID ServiceIntegrations *[]ServiceIntegrationIn `json:"service_integrations,omitempty"` // Service integrations to enable for the service. Some integration types affect how a service is created and they must be provided as part of the creation call instead of being defined later. ServiceName string `json:"service_name"` // Service name ServiceType string `json:"service_type"` // Service type code @@ -2211,7 +2211,7 @@ type ServiceUpdateIn struct { Maintenance *MaintenanceIn `json:"maintenance,omitempty"` // Automatic maintenance settings Plan *string `json:"plan,omitempty"` // Subscription plan Powered *bool `json:"powered,omitempty"` // Power-on the service (true) or power-off (false) - ProjectVpcId *string `json:"project_vpc_id,omitempty"` // Project VPC ID + ProjectVpcId *string `json:"project_vpc_id"` // Project VPC ID SchemaRegistryAuthz *bool `json:"schema_registry_authz,omitempty"` // Enable or disable Schema Registry authorization TechEmails *[]TechEmailIn `json:"tech_emails,omitempty"` // List of service technical email addresses TerminationProtection *bool `json:"termination_protection,omitempty"` // Service is protected against termination and powering off diff --git a/openapi_patch.yaml b/openapi_patch.yaml index 1b58cd1..569d8a9 100644 --- a/openapi_patch.yaml +++ b/openapi_patch.yaml @@ -307,6 +307,16 @@ components: items: type: string type: array + ServiceCreateRequestBody: + properties: + project_vpc_id: + # When VPC is not specified, the service will be created in the existing VPC. + # We must send null to create a service in the public network. + nullable: true + ServiceUpdateRequestBody: + properties: + project_vpc_id: + nullable: true parameters: service_kafka_quota_user: in: query