You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
As of version 5.4.0, Golang generated code appears to not compile correctly when using the --generate-alias-as-model option. Specifically, when referencing a schema within an array, the generated code now no longer uses pointer variables, which causes a compile error in the Unset() method.
Suppose the following schema snippet:
components:
schemas:
webhook:
type: object
properties:
somefield:
type: string
webhook.list:
description: List of webhooks.
type: array
items:
$ref: '#/components/schemas/webhook'
This generates the following Go code (relevant parts shown):
// WebhookList List of webhooks.
type WebhookList struct {
Items []Webhook
}
type NullableWebhookList struct {
value WebhookList
isSet bool
}
func (v *NullableWebhookList) Unset() {
v.value = nil // This line causes a compilation error as assigning nil to a struct
v.isSet = false
}
Previously the value variable was a pointer i.e. value *WebhookList as opposed to value WebhookList), so the nil assignment in Unset() worked. However this behaviour has changed in 5.4.0.
openapi-generator version
5.4.0
Appears to be a regression, this was working fine in 5.3.0
OpenAPI declaration file content or url
---
openapi: 3.0.1
info:
title: Test
version: 20200511-01
paths:
/test:
post:
tags:
- Test
summary: Test
requestBody:
description: Test
content:
application/json:
schema:
$ref: '#/components/schemas/webhook.list'
required: true
responses:
200:
description: The request has been accepted.
content:
application/json:
schema:
type: array
items:
type: string
components:
schemas:
webhook:
type: object
properties:
somefield:
type: string
webhook.list:
description: List of webhooks.
type: array
items:
$ref: '#/components/schemas/webhook'
Generation Details
Option --generate-alias-as-model is used to generate the above Go code.
The text was updated successfully, but these errors were encountered:
Bug Report Checklist
Description
As of version 5.4.0, Golang generated code appears to not compile correctly when using the
--generate-alias-as-model
option. Specifically, when referencing a schema within an array, the generated code now no longer uses pointer variables, which causes a compile error in theUnset()
method.Suppose the following schema snippet:
This generates the following Go code (relevant parts shown):
Previously the
value
variable was a pointer i.e.value *WebhookList
as opposed tovalue WebhookList
), so the nil assignment inUnset()
worked. However this behaviour has changed in 5.4.0.openapi-generator version
5.4.0
Appears to be a regression, this was working fine in 5.3.0
OpenAPI declaration file content or url
Generation Details
Option
--generate-alias-as-model
is used to generate the above Go code.The text was updated successfully, but these errors were encountered: