@@ -25,6 +25,7 @@ public struct ResourceObjectSwiftGen: JSONSchemaSwiftGenerator, ResourceTypeSwif
2525 public let structure : DereferencedJSONSchema
2626 public let decls : [ Decl ]
2727 public let resourceTypeName : String
28+ public let jsonTypeName : String
2829 public let exportedSwiftTypeNames : Set < String >
2930 public let relatives : Set < Relative >
3031 public let relationshipStubGenerators : Set < ResourceObjectStubSwiftGen >
@@ -41,7 +42,7 @@ public struct ResourceObjectSwiftGen: JSONSchemaSwiftGenerator, ResourceTypeSwif
4142 ) throws {
4243 self . structure = structure
4344
44- ( decls, relatives, relationshipStubGenerators) = try ResourceObjectSwiftGen . swiftDecls (
45+ ( decls, jsonTypeName , relatives, relationshipStubGenerators) = try ResourceObjectSwiftGen . swiftDecls (
4546 from: structure,
4647 allowPlaceholders: allowPlaceholders
4748 )
@@ -56,12 +57,12 @@ public struct ResourceObjectSwiftGen: JSONSchemaSwiftGenerator, ResourceTypeSwif
5657 static func swiftDecls(
5758 from structure: DereferencedJSONSchema ,
5859 allowPlaceholders: Bool
59- ) throws -> ( decls: [ Decl ] , relatives: Set < Relative > , relationshipStubs: Set < ResourceObjectStubSwiftGen > ) {
60+ ) throws -> ( decls: [ Decl ] , jsonTypeName : String , relatives: Set < Relative > , relationshipStubs: Set < ResourceObjectStubSwiftGen > ) {
6061 guard case let . object( _, resourceObjectContextB) = structure else {
6162 throw Error . rootNotJSONObject
6263 }
6364
64- let ( typeName, typeNameDecl) = try jsonAPITypeNameSnippet (
65+ let ( jsonTypeName , typeName, typeNameDecl) = try jsonAPITypeNameSnippet (
6566 contextB: resourceObjectContextB,
6667 allowPlaceholders: allowPlaceholders
6768 )
@@ -130,7 +131,7 @@ public struct ResourceObjectSwiftGen: JSONSchemaSwiftGenerator, ResourceTypeSwif
130131 }
131132 )
132133
133- return ( decls: decls, relatives: Set ( relationships. relatives) , relationshipStubs: relationshipStubs)
134+ return ( decls: decls, jsonTypeName : jsonTypeName , relatives: Set ( relationships. relatives) , relationshipStubs: relationshipStubs)
134135 }
135136
136137 /// Creates a snippet of code that declares the static Swift property
@@ -140,13 +141,14 @@ public struct ResourceObjectSwiftGen: JSONSchemaSwiftGenerator, ResourceTypeSwif
140141 private static func jsonAPITypeNameSnippet(
141142 contextB: DereferencedJSONSchema . ObjectContext ,
142143 allowPlaceholders: Bool
143- ) throws -> ( typeName: String , typeNameDeclCode: Decl ) {
144+ ) throws -> ( jsonTypeName : String , typeName: String , typeNameDeclCode: Decl ) {
144145 let typeNameString = try jsonAPITypeName (
145146 from: contextB,
146147 allowPlaceholders: allowPlaceholders
147148 )
148149
149150 return (
151+ jsonTypeName: typeNameString,
150152 typeName: typeCased ( typeNameString) ,
151153 typeNameDeclCode: StaticDecl ( . let( propName: " jsonType " , swiftType: . init( String . self) , . init( value: " \" \( typeNameString) \" " ) ) )
152154 )
0 commit comments