Skip to content

Commit 003ee34

Browse files
committed
Add a hint for allowed values types
1 parent f604619 commit 003ee34

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Sources/OpenAPIKit/Schema Object/JSONSchemaContext.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,11 @@ extension JSONSchema.CoreContext: Decodable {
699699
description = try container.decodeIfPresent(String.self, forKey: .description)
700700
discriminator = try container.decodeIfPresent(OpenAPI.Discriminator.self, forKey: .discriminator)
701701
externalDocs = try container.decodeIfPresent(OpenAPI.ExternalDocumentation.self, forKey: .externalDocs)
702-
allowedValues = try container.decodeIfPresent([AnyCodable].self, forKey: .allowedValues)
702+
if Format.self == JSONTypeFormat.StringFormat.self {
703+
allowedValues = try container.decodeIfPresent([String].self, forKey: .allowedValues)?.map(AnyCodable.init)
704+
} else {
705+
allowedValues = try container.decodeIfPresent([AnyCodable].self, forKey: .allowedValues)
706+
}
703707
defaultValue = try container.decodeIfPresent(AnyCodable.self, forKey: .defaultValue)
704708
_nullable = try container.decodeIfPresent(Bool.self, forKey: .nullable)
705709

0 commit comments

Comments
 (0)