-
-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Open
Labels
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
In the Swift 6 codegen array item types cannot be nullable.
openapi-generator version
Latest: 7.17.0
Not a regression
OpenAPI declaration file content or url
ArrayWithNullableItemsModel:
required:
- foo
properties:
foo:
type: array
items:
type: string
nullable: trueGeneration Details
Expected:
public struct ArrayWithNullableItemsModel: Sendable, Codable, ParameterConvertible, Hashable {
public var foo: [String?]
public init(foo: [String?]) {
self.foo = foo
}
...
}Actual:
public struct ArrayWithNullableItemsModel: Sendable, Codable, ParameterConvertible, Hashable {
public var foo: [String]
public init(foo: [String]) {
self.foo = foo
}
...
}Steps to reproduce
See above.
Related issues/PRs
#19070 - Kotlin bug report
#19080 - Kotlin PR
#19157 - TypeScript PR
Suggest a fix
On line 742:
Line 742 in fd72d4d
| return ModelUtils.isSet(p) ? "Set<" + getTypeDeclaration(inner) + ">" : "[" + getTypeDeclaration(inner) + "]"; |
Account for nullable item schemas in the way the Kotlin generator does since PR 19080, with a getItemsTypeDeclaration(Schema items) function.