Skip to content

Conversation

@nachogiljaldo
Copy link

The model template seems to have a bug where arrays and maps generate a wrong condition to check if the property is set:

// HasLabels returns a boolean if a field has been set.
func (o *PostHMClustersRequest) HasLabels() bool {
	if o != nil && IsNil(o.Labels) {
		return true
	}

That seems to be wrong, because o.Labels is not set if nil, but it returns true.

@nachogiljaldo nachogiljaldo changed the title generate-openapi-clients: fix error on model template generation. generate-openapi-clients: fix error on model template generation Jan 22, 2026
Copy link

@nikimanoledaki nikimanoledaki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, the example you shared shows that this change to the template outputs the expected logic for returning a given resource:

-- if o != nil && IsNil(o.Labels) {
++ if o != nil && !IsNil(o.Labels) {

@nachogiljaldo nachogiljaldo changed the title generate-openapi-clients: fix error on model template generation fix(generate-openapi-clients): fix error on model template generation Jan 22, 2026
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.

3 participants