From 6dd84aa1e2859de403522e76d28528f3e037ac6a Mon Sep 17 00:00:00 2001 From: "Sai Ram Varma Gadiraju -X (sagadira - XORIANT SOLUTIONS PRIVATE LIMITED at Cisco)" Date: Wed, 10 Jun 2026 11:37:58 +0530 Subject: [PATCH] ISSDK-1876: Skip x-createOnly defaults in NewXxx and NewXxxWithDefaults Go constructors Properties marked x-createOnly must not be injected into the struct by the generated constructors -- the Intersight API rejects them in POST if they arrive with a stale default value (e.g. ServerFamily='All' on server.Profile / server.ProfileTemplate). Add {{^vendorExtensions.x-createOnly}} guards around the default-value assignment blocks in both New{{classname}} and New{{classname}}WithDefaults in model_simple.mustache, mirroring the existing {{^isReadOnly}} pattern. --- .../src/main/resources/go/model_simple.mustache | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/openapi-generator/src/main/resources/go/model_simple.mustache b/modules/openapi-generator/src/main/resources/go/model_simple.mustache index 6e60c6a180df..3de2411c1eb5 100644 --- a/modules/openapi-generator/src/main/resources/go/model_simple.mustache +++ b/modules/openapi-generator/src/main/resources/go/model_simple.mustache @@ -51,6 +51,7 @@ func New{{classname}}({{#requiredVars}}{{nameInCamelCase}} {{dataType}}{{^-last} {{#defaultValue}} {{^vendorExtensions.x-golang-is-container}} {{^isReadOnly}} +{{^vendorExtensions.x-createOnly}} {{#isNullable}} var {{nameInCamelCase}} {{{datatypeWithEnum}}} = {{{.}}} this.{{name}} = *New{{{dataType}}}(&{{nameInCamelCase}}) @@ -59,6 +60,7 @@ func New{{classname}}({{#requiredVars}}{{nameInCamelCase}} {{dataType}}{{^-last} var {{nameInCamelCase}} {{{dataType}}} = {{{.}}} this.{{name}} = &{{nameInCamelCase}} {{/isNullable}} +{{/vendorExtensions.x-createOnly}} {{/isReadOnly}} {{/vendorExtensions.x-golang-is-container}} {{/defaultValue}} @@ -76,6 +78,7 @@ func New{{classname}}WithDefaults() *{{classname}} { {{#defaultValue}} {{^vendorExtensions.x-golang-is-container}} {{^isReadOnly}} +{{^vendorExtensions.x-createOnly}} {{#isNullable}} {{!we use datatypeWithEnum here, since it will represent the non-nullable name of the datatype, e.g. int64 for NullableInt64}} var {{nameInCamelCase}} {{{datatypeWithEnum}}} = {{{.}}} @@ -85,6 +88,7 @@ func New{{classname}}WithDefaults() *{{classname}} { var {{nameInCamelCase}} {{{dataType}}} = {{{.}}} this.{{name}} = {{^required}}&{{/required}}{{nameInCamelCase}} {{/isNullable}} +{{/vendorExtensions.x-createOnly}} {{/isReadOnly}} {{/vendorExtensions.x-golang-is-container}} {{/defaultValue}}