@@ -104,6 +104,27 @@ class Test_TypeAssigner: Test_Core {
104
104
}
105
105
}
106
106
107
+ func testTypeNameForReferenceProperties( ) throws {
108
+ let parent = TypeName ( swiftKeyPath: [ " MyType " ] )
109
+ let components : OpenAPI . Components = . init( schemas: [
110
+ " SomeString " : . string( ) ,
111
+ " MaybeString " : . one( of: [ . reference( . component( named: " SomeString " ) ) , . null( ) ] ) ,
112
+ ] )
113
+ func assertTypeName( _ property: String , _ schema: JSONSchema , _ typeName: String , file: StaticString = #file, line: UInt = #line) throws {
114
+ let actual = try typeAssigner. typeUsage (
115
+ forObjectPropertyNamed: property,
116
+ withSchema: schema,
117
+ components: components,
118
+ inParent: parent
119
+ ) . fullyQualifiedSwiftName
120
+ XCTAssertEqual ( typeName, actual, file: file, line: line)
121
+ }
122
+ try assertTypeName ( " someString " , . reference( . component( named: " SomeString " ) ) , " Components.Schemas.SomeString " )
123
+ try assertTypeName ( " maybeString " , . reference( . component( named: " MaybeString " ) ) , " Components.Schemas.MaybeString " )
124
+ try assertTypeName ( " optionalSomeString " , . reference( . component( named: " SomeString " ) , required: false ) , " Components.Schemas.SomeString? " )
125
+ try assertTypeName ( " optionalMaybeString " , . reference( . component( named: " MaybeString " ) , required: false ) , " Components.Schemas.MaybeString " )
126
+ }
127
+
107
128
func testContentSwiftName( ) throws {
108
129
let nameMaker = makeTranslator ( ) . typeAssigner. contentSwiftName
109
130
let cases : [ ( String , String ) ] = [
0 commit comments