@@ -25,6 +25,7 @@ public struct ResourceObjectSwiftGen: JSONSchemaSwiftGenerator, ResourceTypeSwif
25
25
public let structure : DereferencedJSONSchema
26
26
public let decls : [ Decl ]
27
27
public let resourceTypeName : String
28
+ public let jsonTypeName : String
28
29
public let exportedSwiftTypeNames : Set < String >
29
30
public let relatives : Set < Relative >
30
31
public let relationshipStubGenerators : Set < ResourceObjectStubSwiftGen >
@@ -41,7 +42,7 @@ public struct ResourceObjectSwiftGen: JSONSchemaSwiftGenerator, ResourceTypeSwif
41
42
) throws {
42
43
self . structure = structure
43
44
44
- ( decls, relatives, relationshipStubGenerators) = try ResourceObjectSwiftGen . swiftDecls (
45
+ ( decls, jsonTypeName , relatives, relationshipStubGenerators) = try ResourceObjectSwiftGen . swiftDecls (
45
46
from: structure,
46
47
allowPlaceholders: allowPlaceholders
47
48
)
@@ -56,12 +57,12 @@ public struct ResourceObjectSwiftGen: JSONSchemaSwiftGenerator, ResourceTypeSwif
56
57
static func swiftDecls(
57
58
from structure: DereferencedJSONSchema ,
58
59
allowPlaceholders: Bool
59
- ) throws -> ( decls: [ Decl ] , relatives: Set < Relative > , relationshipStubs: Set < ResourceObjectStubSwiftGen > ) {
60
+ ) throws -> ( decls: [ Decl ] , jsonTypeName : String , relatives: Set < Relative > , relationshipStubs: Set < ResourceObjectStubSwiftGen > ) {
60
61
guard case let . object( _, resourceObjectContextB) = structure else {
61
62
throw Error . rootNotJSONObject
62
63
}
63
64
64
- let ( typeName, typeNameDecl) = try jsonAPITypeNameSnippet (
65
+ let ( jsonTypeName , typeName, typeNameDecl) = try jsonAPITypeNameSnippet (
65
66
contextB: resourceObjectContextB,
66
67
allowPlaceholders: allowPlaceholders
67
68
)
@@ -130,7 +131,7 @@ public struct ResourceObjectSwiftGen: JSONSchemaSwiftGenerator, ResourceTypeSwif
130
131
}
131
132
)
132
133
133
- return ( decls: decls, relatives: Set ( relationships. relatives) , relationshipStubs: relationshipStubs)
134
+ return ( decls: decls, jsonTypeName : jsonTypeName , relatives: Set ( relationships. relatives) , relationshipStubs: relationshipStubs)
134
135
}
135
136
136
137
/// Creates a snippet of code that declares the static Swift property
@@ -140,13 +141,14 @@ public struct ResourceObjectSwiftGen: JSONSchemaSwiftGenerator, ResourceTypeSwif
140
141
private static func jsonAPITypeNameSnippet(
141
142
contextB: DereferencedJSONSchema . ObjectContext ,
142
143
allowPlaceholders: Bool
143
- ) throws -> ( typeName: String , typeNameDeclCode: Decl ) {
144
+ ) throws -> ( jsonTypeName : String , typeName: String , typeNameDeclCode: Decl ) {
144
145
let typeNameString = try jsonAPITypeName (
145
146
from: contextB,
146
147
allowPlaceholders: allowPlaceholders
147
148
)
148
149
149
150
return (
151
+ jsonTypeName: typeNameString,
150
152
typeName: typeCased ( typeNameString) ,
151
153
typeNameDeclCode: StaticDecl ( . let( propName: " jsonType " , swiftType: . init( String . self) , . init( value: " \" \( typeNameString) \" " ) ) )
152
154
)
0 commit comments