Skip to content

Commit a2407d9

Browse files
committed
Update checks for null values
1 parent 3aaabd7 commit a2407d9

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Sources/_OpenAPIGeneratorCore/Translator/CommonTranslations/translateRawEnum.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,9 @@ extension FileTranslator {
100100
// In nullable enum schemas, empty strings are parsed as Void.
101101
// This is unlikely to be fixed, so handling that case here.
102102
// https://github.com/apple/swift-openapi-generator/issues/118
103-
if isNullable && anyValue is Void {
103+
// Also handle nil values in nullable schemas.
104+
let isNullValue = anyValue is Void || (anyValue as? String) == nil
105+
if isNullable && isNullValue {
104106
try addIfUnique(id: .string(""), caseName: context.safeNameGenerator.swiftMemberName(for: ""))
105107
} else {
106108
guard let rawValue = anyValue as? String else {

0 commit comments

Comments
 (0)