File tree Expand file tree Collapse file tree 1 file changed +51
-0
lines changed
Tests/OpenAPIKitTests/Schema Object Expand file tree Collapse file tree 1 file changed +51
-0
lines changed Original file line number Diff line number Diff line change @@ -1918,6 +1918,57 @@ extension SchemaObjectTests {
19181918 JSONSchema . fragment ( . init( examples: [ " hello " ] ) ) . with ( vendorExtensions: [ " x-hello " : " hello " ] )
19191919 )
19201920 }
1921+
1922+ func test_decodeAnyOfWithVendorExtension( ) throws {
1923+ let extensionSchema = """
1924+ {
1925+ " anyOf " : [
1926+ { " type " : " string " },
1927+ { " type " : " number " }
1928+ ],
1929+ " x-hello " : " hello "
1930+ }
1931+ """ . data ( using: . utf8) !
1932+
1933+ XCTAssertEqual (
1934+ try orderUnstableDecode ( JSONSchema . self, from: extensionSchema) ,
1935+ JSONSchema . any ( of: [ JSONSchema . string, JSONSchema . number] ) . with ( vendorExtensions: [ " x-hello " : " hello " ] )
1936+ )
1937+ }
1938+
1939+ func test_decodeAllOfWithVendorExtension( ) throws {
1940+ let extensionSchema = """
1941+ {
1942+ " allOf " : [
1943+ { " type " : " string " },
1944+ { " type " : " number " }
1945+ ],
1946+ " x-hello " : " hello "
1947+ }
1948+ """ . data ( using: . utf8) !
1949+
1950+ XCTAssertEqual (
1951+ try orderUnstableDecode ( JSONSchema . self, from: extensionSchema) ,
1952+ JSONSchema . all ( of: [ JSONSchema . string, JSONSchema . number] ) . with ( vendorExtensions: [ " x-hello " : " hello " ] )
1953+ )
1954+ }
1955+
1956+ func test_decodeOneOfWithVendorExtension( ) throws {
1957+ let extensionSchema = """
1958+ {
1959+ " oneOf " : [
1960+ { " type " : " string " },
1961+ { " type " : " number " }
1962+ ],
1963+ " x-hello " : " hello "
1964+ }
1965+ """ . data ( using: . utf8) !
1966+
1967+ XCTAssertEqual (
1968+ try orderUnstableDecode ( JSONSchema . self, from: extensionSchema) ,
1969+ JSONSchema . one ( of: [ JSONSchema . string, JSONSchema . number] ) . with ( vendorExtensions: [ " x-hello " : " hello " ] )
1970+ )
1971+ }
19211972
19221973 func test_encodeExamplesVendorExtension( ) throws {
19231974 let fragment = JSONSchema . fragment ( . init( examples: [ " hello " ] ) ) . with ( vendorExtensions: [ " x-hello " : " hello " ] )
You can’t perform that action at this time.
0 commit comments