Closed
Description
This test exists:
func test_decodeNullType() throws {
let nullTypeData = """
{
"type": "null"
}
""".data(using: .utf8)!
let decoded = try orderUnstableDecode(JSONSchema.self, from: nullTypeData)
XCTAssertEqual(decoded, .null())
}
However, adding a similar test for Yaml highlights the bug:
diff --git a/Tests/OpenAPIKitTests/Schema Object/SchemaObjectYamsTests.swift b/Tests/OpenAPIKitTests/Schema Object/SchemaObjectYamsTests.swift
index 12c7c10c..1d32f5d7 100644
--- a/Tests/OpenAPIKitTests/Schema Object/SchemaObjectYamsTests.swift
+++ b/Tests/OpenAPIKitTests/Schema Object/SchemaObjectYamsTests.swift
@@ -16,6 +16,20 @@ import OpenAPIKit
import Yams
final class SchemaObjectYamsTests: XCTestCase {
+ func test_nullTypeDecode() throws {
+ let nullString =
+ """
+ type: 'null'
+ """
+
+ let null = try YAMLDecoder().decode(JSONSchema.self, from: nullString)
+
+ XCTAssertEqual(
+ null,
+ JSONSchema.null()
+ )
+ }
+
func test_floatingPointWholeNumberIntegerDecode() throws {
let integerString =
"""
In short, nil
is returned, when JSONType.null
is expected.
Metadata
Metadata
Assignees
Labels
No labels