@@ -315,6 +315,48 @@ final class ValidationConvenienceTests: XCTestCase {
315
315
)
316
316
}
317
317
318
+ func test_subject_unwrapAndlookup( ) {
319
+ let v = Validation < OpenAPI . Parameter > (
320
+ description: " parameter is named test " ,
321
+ check: \. name == " test "
322
+ )
323
+
324
+ let document = OpenAPI . Document (
325
+ info: . init( title: " test " , version: " 1.0 " ) ,
326
+ servers: [ ] ,
327
+ paths: [
328
+ " /test " : . init(
329
+ parameters: [
330
+ . reference( . component( named: " test1 " ) ) , // passes validation
331
+ . reference( . component( named: " test2 " ) ) , // wrong name
332
+ . reference( . component( named: " test3 " ) ) // not found
333
+ ]
334
+ )
335
+ ] ,
336
+ components: . init(
337
+ parameters: [
338
+ " test1 " : . init( name: " test " , context: . header, content: [ : ] ) ,
339
+ " test2 " : . init( name: " test2 " , context: . query, content: [ : ] )
340
+ ]
341
+ )
342
+ )
343
+
344
+ let context = ValidationContext < OpenAPI . Document > ( document: document, subject: document, codingPath: [ ] )
345
+
346
+ XCTAssertTrue (
347
+ unwrapAndLookup ( \OpenAPI . Document. paths [ " /test " ] ? . parameters [ 0 ] , thenApply: v) ( context) . isEmpty
348
+ )
349
+ XCTAssertFalse (
350
+ unwrapAndLookup ( \OpenAPI . Document. paths [ " /test " ] ? . parameters [ 1 ] , thenApply: v) ( context) . isEmpty
351
+ )
352
+ XCTAssertFalse (
353
+ unwrapAndLookup ( \OpenAPI . Document. paths [ " /test " ] ? . parameters [ 2 ] , thenApply: v) ( context) . isEmpty
354
+ )
355
+ XCTAssertFalse (
356
+ unwrapAndLookup ( \OpenAPI . Document. paths [ " /test2 " ] ? . parameters. first, thenApply: v) ( context) . isEmpty
357
+ )
358
+ }
359
+
318
360
func test_allCombinator( ) {
319
361
let v1 = Validation < String > (
320
362
description: " String is more than 5 characters " ,
0 commit comments