File tree 1 file changed +13
-2
lines changed
Sources/JSONAPISwiftGen/Swift Generators
1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change 8
8
import Foundation
9
9
import OpenAPIKit
10
10
11
+ fileprivate let collidingNames = [
12
+ " Metadata "
13
+ ]
14
+
11
15
/// Given some JSON Schema, attempt to generate Swift code for
12
16
/// a `struct` that is capable of parsing data adhering to the schema.
13
17
public struct StructureSwiftGen : JSONSchemaSwiftGenerator {
@@ -31,7 +35,14 @@ public struct StructureSwiftGen: JSONSchemaSwiftGenerator {
31
35
cascadingConformances: [ String ] = [ ] ,
32
36
rootConformances: [ String ] ? = nil
33
37
) 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
35
46
self . structure = structure
36
47
37
48
switch structure {
@@ -102,7 +113,7 @@ public struct StructureSwiftGen: JSONSchemaSwiftGenerator {
102
113
}
103
114
104
115
let poly = Typealias (
105
- alias: . def( . init( name: " Poly \( name) " ) ) ,
116
+ alias: . def( . init( name: name) ) ,
106
117
existingType: . def(
107
118
. init(
108
119
name: " Poly \( dependencies. count) " ,
You can’t perform that action at this time.
0 commit comments