File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed
Sources/JSONAPISwiftGen/Swift Generators Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change 88import Foundation
99import OpenAPIKit
1010
11+ fileprivate let collidingNames = [
12+ " Metadata "
13+ ]
14+
1115/// Given some JSON Schema, attempt to generate Swift code for
1216/// a `struct` that is capable of parsing data adhering to the schema.
1317public struct StructureSwiftGen : JSONSchemaSwiftGenerator {
@@ -31,7 +35,14 @@ public struct StructureSwiftGen: JSONSchemaSwiftGenerator {
3135 cascadingConformances: [ String ] = [ ] ,
3236 rootConformances: [ String ] ? = nil
3337 ) throws {
34- self . swiftTypeName = swiftTypeName
38+ let typeName : String
39+ if collidingNames. contains ( swiftTypeName) {
40+ typeName = " Gen " + swiftTypeName
41+ } else {
42+ typeName = swiftTypeName
43+ }
44+
45+ self . swiftTypeName = typeName
3546 self . structure = structure
3647
3748 switch structure {
@@ -102,7 +113,7 @@ public struct StructureSwiftGen: JSONSchemaSwiftGenerator {
102113 }
103114
104115 let poly = Typealias (
105- alias: . def( . init( name: " Poly \( name) " ) ) ,
116+ alias: . def( . init( name: name) ) ,
106117 existingType: . def(
107118 . init(
108119 name: " Poly \( dependencies. count) " ,
You can’t perform that action at this time.
0 commit comments