Skip to content

fix(go): disable strict validation and enable additional properties#251

Merged
rubenhoenle merged 1 commit intomainfrom
fix/go-disable-strict-validation
Mar 12, 2026
Merged

fix(go): disable strict validation and enable additional properties#251
rubenhoenle merged 1 commit intomainfrom
fix/go-disable-strict-validation

Conversation

@rubenhoenle
Copy link
Member

@rubenhoenle rubenhoenle commented Mar 12, 2026

Description

See https://openapi-generator.tech/docs/generators/go/

disallowAdditionalPropertiesIfNotPresent: If false, the 'additionalProperties' implementation (set to true by default) is compliant with the OAS and JSON schema specifications. If true (default), keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default.

false: The 'additionalProperties' implementation is compliant with the OAS and JSON schema specifications.
true: Keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default.

Changing this setting will cause the following changes in our SDK.

  • Strict validation of API responses will be disabled (good for backward compatibility)
  • Additional fields sent by the API are accessible in each response struct via a map
-       decoder := json.NewDecoder(bytes.NewReader(data))
-       decoder.DisallowUnknownFields()
-       err = decoder.Decode(&varUpdateVPNGatewayPayloadAvailabilityZones)
+       err = json.Unmarshal(data, &varUpdateVPNGatewayPayloadAvailabilityZones)
 type VPNTunnels struct {
        BgpStatus     NullableBGPStatus `json:"bgpStatus,omitempty"`
        InstanceState *GatewayStatus    `json:"instanceState,omitempty"`
        Name          *string           `json:"name,omitempty"`
        PublicIP      *string           `json:"publicIP,omitempty"`
+       AdditionalProperties map[string]interface{}
 }

Testing instructions

Generate the SDK with this bugfix. Look at the diff in sdk-repo-updated. Strict validation should be disabled as described above. AdditionalProperties map should be added to the structs.

@rubenhoenle rubenhoenle requested a review from a team as a code owner March 12, 2026 10:24
@rubenhoenle rubenhoenle merged commit c7276e7 into main Mar 12, 2026
21 checks passed
@rubenhoenle rubenhoenle deleted the fix/go-disable-strict-validation branch March 12, 2026 12:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants