@@ -35,7 +35,7 @@ open class SchemaInfo(
3535 /* *
3636 * the OpenAPI schema
3737 */
38- private val schema : Schema ? , // todo not null
38+ private val schema : Schema ,
3939
4040 /* *
4141 * resolver of $ref'erences
@@ -81,7 +81,7 @@ open class SchemaInfo(
8181 * @return schema type
8282 */
8383 override fun getType (): String? {
84- return schema? .getType()
84+ return schema.getType()
8585 }
8686
8787 /* *
@@ -90,7 +90,7 @@ open class SchemaInfo(
9090 * @return schema type format
9191 */
9292 override fun getFormat (): String? {
93- return schema? .getFormat()
93+ return schema.getFormat()
9494 }
9595
9696 fun getTypeFormat (): String {
@@ -107,7 +107,7 @@ open class SchemaInfo(
107107 * @return schema $ref
108108 */
109109 fun getRef (): String? {
110- return schema? .getRef()
110+ return schema.getRef()
111111 }
112112
113113 /* *
@@ -116,23 +116,23 @@ open class SchemaInfo(
116116 * @return default value or null
117117 */
118118 fun getDefaultValue (): Any? {
119- return schema? .getDefault()
119+ return schema.getDefault()
120120 }
121121
122122 /* *
123123 * get description.
124124 *
125125 * @return description or null
126126 */
127- val description: String? = schema? .description
127+ val description: String? = schema.description
128128
129129 /* *
130130 * get deprecated value
131131 *
132132 * @return true or false
133133 */
134134 fun getDeprecated (): Boolean {
135- return schema? .isDeprecated()!!
135+ return schema.isDeprecated()
136136 }
137137
138138 /* *
@@ -141,7 +141,7 @@ open class SchemaInfo(
141141 * @return true or false
142142 */
143143 fun getRequired (): List <String > {
144- return schema? .getRequired()!!
144+ return schema.getRequired()
145145 }
146146
147147 /* *
@@ -150,7 +150,7 @@ open class SchemaInfo(
150150 * @return nullable, true or false
151151 */
152152 fun getNullable (): Boolean {
153- return schema? .getNullable()!!
153+ return schema.getNullable()
154154 }
155155
156156 /* *
@@ -159,7 +159,7 @@ open class SchemaInfo(
159159 * @return minLength value >= 0
160160 */
161161 fun getMinLength (): Int {
162- return schema? .getMinLength() ? : 0
162+ return schema.getMinLength() ? : 0
163163 }
164164
165165 /* *
@@ -168,7 +168,7 @@ open class SchemaInfo(
168168 * @return maxLength value or null
169169 */
170170 fun getMaxLength (): Int? {
171- return schema? .getMaxLength()
171+ return schema.getMaxLength()
172172 }
173173
174174 /* *
@@ -177,7 +177,7 @@ open class SchemaInfo(
177177 * @return minItems value or null
178178 */
179179 fun getMinItems (): Int? {
180- return schema? .getMinItems()
180+ return schema.getMinItems()
181181 }
182182
183183 /* *
@@ -186,7 +186,7 @@ open class SchemaInfo(
186186 * @return maxItems value or null
187187 */
188188 fun getMaxItems (): Int? {
189- return schema? .getMaxItems()
189+ return schema.getMaxItems()
190190 }
191191
192192 /* *
@@ -195,7 +195,7 @@ open class SchemaInfo(
195195 * @return maximum value or null
196196 */
197197 fun getMaximum (): Number ? {
198- return schema? .getMaximum()
198+ return schema.getMaximum()
199199 }
200200
201201 /* *
@@ -204,7 +204,7 @@ open class SchemaInfo(
204204 * @return true or false
205205 */
206206 fun getExclusiveMaximum (): Boolean {
207- return schema? .isExclusiveMaximum()!!
207+ return schema.isExclusiveMaximum()
208208 }
209209
210210 /* *
@@ -213,7 +213,7 @@ open class SchemaInfo(
213213 * @return minimum value or null
214214 */
215215 fun getMinimum (): Number ? {
216- return schema? .getMinimum()
216+ return schema.getMinimum()
217217 }
218218
219219 /* *
@@ -222,23 +222,23 @@ open class SchemaInfo(
222222 * @return exclusiveMinimum value or null
223223 */
224224 fun getExclusiveMinimum (): Boolean {
225- return schema? .isExclusiveMinimum()!!
225+ return schema.isExclusiveMinimum()
226226 }
227227
228228 val pattern: String?
229- get() = schema? .pattern
229+ get() = schema.pattern
230230
231231 val readOnly: Boolean
232- get() = schema? .readOnly ? : false
232+ get() = schema.readOnly
233233
234234 val writeOnly: Boolean
235- get() = schema? .writeOnly ? : false
235+ get() = schema.writeOnly
236236
237237 /* *
238238 * iterate over properties
239239 */
240240 fun eachProperty (action : (name: String , info: SchemaInfo ) -> Unit ) {
241- schema? .getProperties()? .forEach { (name, schema) ->
241+ schema.getProperties().forEach { (name, schema) ->
242242 action(name, buildForNestedType(name, schema))
243243 }
244244 }
@@ -247,7 +247,7 @@ open class SchemaInfo(
247247 * iterate over composed items
248248 */
249249 fun eachItemOf (action : (info: SchemaInfo ) -> Unit ) {
250- if (schema? .getProperties()? .isNotEmpty() == true ) {
250+ if (schema.getProperties().isNotEmpty()) {
251251 action(SchemaInfoAllOf (
252252 endpoint = endpoint,
253253 name = " ${name} _${itemOf()!! .capitalizeFirstChar()} " ,
@@ -256,7 +256,7 @@ open class SchemaInfo(
256256 ))
257257 }
258258
259- schema? .getItems()? .forEachIndexed { index, schema ->
259+ schema.getItems().forEachIndexed { index, schema ->
260260 action(SchemaInfo (
261261 endpoint = endpoint,
262262 name = " ${name} _${itemOf()!! .capitalizeFirstChar()} _${index} " ,
@@ -270,13 +270,10 @@ open class SchemaInfo(
270270 * allOf, oneOf, anyOf.
271271 */
272272 fun itemOf (): String? {
273- return schema? .itemsOf()
273+ return schema.itemsOf()
274274 }
275275
276276 fun getExtensions (): Map <String , * > {
277- if (schema == null )
278- return emptyMap<String , Any >()
279-
280277 return schema.extensions
281278 }
282279
@@ -286,7 +283,7 @@ open class SchemaInfo(
286283 * @return a new {@link SchemaInfo}
287284 */
288285 fun buildForRef (): SchemaInfo {
289- val resolved = resolver.resolve(schema!! )
286+ val resolved = resolver.resolve(schema)
290287 val resolvedName = if (refName || resolved.hasNoName) {
291288 name // propagate "parent" name
292289 } else {
@@ -326,7 +323,7 @@ open class SchemaInfo(
326323 * @return a new {@link SchemaInfo}
327324 */
328325 fun buildForItem (): SchemaInfo {
329- val item = schema!! .getItem()
326+ val item = schema.getItem()
330327
331328 return SchemaInfo (
332329 endpoint = endpoint,
@@ -342,7 +339,7 @@ open class SchemaInfo(
342339 * @return a new {@link SchemaInfo}
343340 */
344341 fun buildForAdditionalProperties (): SchemaInfo ? {
345- val additionalProperties = schema? .getAdditionalProperties() ? : return null
342+ val additionalProperties = schema.getAdditionalProperties() ? : return null
346343
347344 return SchemaInfo (
348345 endpoint = endpoint,
@@ -371,7 +368,7 @@ open class SchemaInfo(
371368 )
372369
373370 override fun isPrimitive (): Boolean {
374- return listOf (" boolean" , " integer" , " number" , " string" ).contains(schema? .getType())
371+ return listOf (" boolean" , " integer" , " number" , " string" ).contains(schema.getType())
375372 }
376373
377374 override fun isArray (): Boolean {
@@ -382,11 +379,8 @@ open class SchemaInfo(
382379 if (getType().equals(" object" ))
383380 return true
384381
385- val properties = schema?.getProperties()
386- if (! properties.isNullOrEmpty())
387- return true
388-
389- return false
382+ val properties = schema.getProperties()
383+ return properties.isNotEmpty()
390384 }
391385
392386 fun isComposedObject (): Boolean {
@@ -402,23 +396,19 @@ open class SchemaInfo(
402396 }
403397
404398 fun isTypeLess (): Boolean {
405- return schema? .getType() == null
399+ return schema.getType() == null
406400 }
407401
408402 fun isRefObject (): Boolean {
409- return schema?.getRef() != null
410- }
411-
412- fun isEmpty (): Boolean {
413- return schema == null
403+ return schema.getRef() != null
414404 }
415405
416406 fun isEnum (): Boolean {
417- return schema!! .getEnum().isNotEmpty()
407+ return schema.getEnum().isNotEmpty()
418408 }
419409
420410 fun getEnumValues (): List <* > {
421- return schema!! .getEnum()
411+ return schema.getEnum()
422412 }
423413
424414 private fun getArrayItemName (): String {
@@ -428,5 +418,4 @@ open class SchemaInfo(
428418 private fun getNestedTypeName (nestedName : String ): String {
429419 return name + nestedName.capitalizeFirstChar()
430420 }
431-
432421}
0 commit comments