@@ -30,28 +30,28 @@ public class Schema {
30
30
}
31
31
32
32
/// The data type.
33
- let type : DataType
33
+ public let type : DataType
34
34
35
35
/// The format of the data.
36
- let format : String ?
36
+ public let format : String ?
37
37
38
38
/// A brief description of the parameter.
39
- let description : String ?
39
+ public let description : String ?
40
40
41
41
/// Indicates if the value may be null.
42
- let nullable : Bool ?
42
+ public let nullable : Bool ?
43
43
44
44
/// Possible values of the element of type ``DataType/string`` with "enum" format.
45
- let enumValues : [ String ] ?
45
+ public let enumValues : [ String ] ?
46
46
47
47
/// Schema of the elements of type ``DataType/array``.
48
- let items : Schema ?
48
+ public let items : Schema ?
49
49
50
50
/// Properties of type ``DataType/object``.
51
- let properties : [ String : Schema ] ?
51
+ public let properties : [ String : Schema ] ?
52
52
53
53
/// Required properties of type ``DataType/object``.
54
- let requiredProperties : [ String ] ?
54
+ public let requiredProperties : [ String ] ?
55
55
56
56
/// Constructs a new `Schema`.
57
57
///
@@ -74,8 +74,7 @@ public class Schema {
74
74
etc., instead.
75
75
""" )
76
76
public convenience init ( type: DataType , format: String ? = nil , description: String ? = nil ,
77
- nullable: Bool ? = nil ,
78
- enumValues: [ String ] ? = nil , items: Schema ? = nil ,
77
+ nullable: Bool ? = nil , enumValues: [ String ] ? = nil , items: Schema ? = nil ,
79
78
properties: [ String : Schema ] ? = nil ,
80
79
requiredProperties: [ String ] ? = nil ) {
81
80
self . init (
@@ -91,10 +90,8 @@ public class Schema {
91
90
}
92
91
93
92
required init ( type: DataType , format: String ? = nil , description: String ? = nil ,
94
- nullable: Bool = false ,
95
- enumValues: [ String ] ? = nil , items: Schema ? = nil ,
96
- properties: [ String : Schema ] ? = nil ,
97
- requiredProperties: [ String ] ? = nil ) {
93
+ nullable: Bool = false , enumValues: [ String ] ? = nil , items: Schema ? = nil ,
94
+ properties: [ String : Schema ] ? = nil , requiredProperties: [ String ] ? = nil ) {
98
95
self . type = type
99
96
self . format = format
100
97
self . description = description
@@ -109,33 +106,36 @@ public class Schema {
109
106
format: StringFormat ? = nil ) -> Schema {
110
107
return self . init (
111
108
type: . string,
112
- format: format? . rawValue, description: description,
109
+ format: format? . rawValue,
110
+ description: description,
113
111
nullable: nullable
114
112
)
115
113
}
116
114
117
- public static func enumeration( values: [ String ] , description: String ? , nullable: Bool ) -> Schema {
115
+ public static func enumeration( values: [ String ] , description: String ? = nil ,
116
+ nullable: Bool = false ) -> Schema {
118
117
return self . init (
119
118
type: . string,
120
- format: " enum " , description: description,
119
+ format: " enum " ,
120
+ description: description,
121
121
nullable: nullable,
122
122
enumValues: values
123
123
)
124
124
}
125
125
126
- public static func double ( description: String ? = nil , nullable: Bool = false ) -> Schema {
126
+ public static func float ( description: String ? = nil , nullable: Bool = false ) -> Schema {
127
127
return self . init (
128
128
type: . number,
129
- format: " double " ,
129
+ format: " float " ,
130
130
description: description,
131
131
nullable: nullable
132
132
)
133
133
}
134
134
135
- public static func float ( description: String ? = nil , nullable: Bool = false ) -> Schema {
135
+ public static func double ( description: String ? = nil , nullable: Bool = false ) -> Schema {
136
136
return self . init (
137
137
type: . number,
138
- format: " float " ,
138
+ format: " double " ,
139
139
description: description,
140
140
nullable: nullable
141
141
)
@@ -155,13 +155,13 @@ public class Schema {
155
155
return self . init ( type: . boolean, description: description, nullable: nullable)
156
156
}
157
157
158
- public static func array( items: Schema , description: String ? = nil , nullable: Bool = false ) -> Schema {
158
+ public static func array( items: Schema , description: String ? = nil ,
159
+ nullable: Bool = false ) -> Schema {
159
160
return self . init ( type: . array, description: description, nullable: nullable, items: items)
160
161
}
161
162
162
- public static func object( description: String ? = nil , nullable: Bool = false ,
163
- properties: [ String : Schema ] ,
164
- optionalProperties: [ String ] = [ ] ) -> Schema {
163
+ public static func object( properties: [ String : Schema ] , optionalProperties: [ String ] = [ ] ,
164
+ description: String ? = nil , nullable: Bool = false ) -> Schema {
165
165
var requiredProperties = Set ( properties. keys)
166
166
for optionalProperty in optionalProperties {
167
167
guard properties. keys. contains ( optionalProperty) else {
0 commit comments