diff --git a/core/src/main/kotlin/io/bkbn/kompendium/core/metadata/DeleteInfo.kt b/core/src/main/kotlin/io/bkbn/kompendium/core/metadata/DeleteInfo.kt index 2e5752cec..4920ce19e 100644 --- a/core/src/main/kotlin/io/bkbn/kompendium/core/metadata/DeleteInfo.kt +++ b/core/src/main/kotlin/io/bkbn/kompendium/core/metadata/DeleteInfo.kt @@ -25,11 +25,11 @@ class DeleteInfo private constructor( class Builder : MethodInfo.Builder() { override fun build() = DeleteInfo( - response = response!!, + response = response ?: error("Response info must be present"), errors = errors, tags = tags, - summary = summary!!, - description = description!!, + summary = summary ?: error("Summary must be present"), + description = description ?: error("Description must be present"), externalDocumentation = externalDocumentation, operationId = operationId, deprecated = deprecated, diff --git a/core/src/main/kotlin/io/bkbn/kompendium/core/metadata/HeadInfo.kt b/core/src/main/kotlin/io/bkbn/kompendium/core/metadata/HeadInfo.kt index accee2de0..4fafac050 100644 --- a/core/src/main/kotlin/io/bkbn/kompendium/core/metadata/HeadInfo.kt +++ b/core/src/main/kotlin/io/bkbn/kompendium/core/metadata/HeadInfo.kt @@ -25,11 +25,11 @@ class HeadInfo private constructor( class Builder : MethodInfo.Builder() { override fun build() = HeadInfo( - response = response!!, + response = response ?: error("Response info must be present"), errors = errors, tags = tags, - summary = summary!!, - description = description!!, + summary = summary ?: error("Summary must be present"), + description = description ?: error("Description must be present"), externalDocumentation = externalDocumentation, operationId = operationId, deprecated = deprecated, diff --git a/core/src/main/kotlin/io/bkbn/kompendium/core/metadata/OptionsInfo.kt b/core/src/main/kotlin/io/bkbn/kompendium/core/metadata/OptionsInfo.kt index c56fc319f..03894baa4 100644 --- a/core/src/main/kotlin/io/bkbn/kompendium/core/metadata/OptionsInfo.kt +++ b/core/src/main/kotlin/io/bkbn/kompendium/core/metadata/OptionsInfo.kt @@ -25,11 +25,11 @@ class OptionsInfo private constructor( class Builder : MethodInfo.Builder() { override fun build() = OptionsInfo( - response = response!!, + response = response ?: error("Response info must be provided!"), errors = errors, tags = tags, - summary = summary!!, - description = description!!, + summary = summary ?: error("Summary must be provided!"), + description = description ?: error("Description must be provided!"), externalDocumentation = externalDocumentation, operationId = operationId, deprecated = deprecated, diff --git a/core/src/main/kotlin/io/bkbn/kompendium/core/metadata/PatchInfo.kt b/core/src/main/kotlin/io/bkbn/kompendium/core/metadata/PatchInfo.kt index 4551a670a..22af59a9d 100644 --- a/core/src/main/kotlin/io/bkbn/kompendium/core/metadata/PatchInfo.kt +++ b/core/src/main/kotlin/io/bkbn/kompendium/core/metadata/PatchInfo.kt @@ -26,12 +26,12 @@ class PatchInfo private constructor( class Builder : MethodInfoWithRequest.Builder() { override fun build() = PatchInfo( - request = request!!, + request = request ?: error("request info must be present"), errors = errors, - response = response!!, + response = response ?: error("response info must be present"), tags = tags, - summary = summary!!, - description = description!!, + summary = summary ?: error("Summary must be present"), + description = description ?: error("Description must be present"), externalDocumentation = externalDocumentation, operationId = operationId, deprecated = deprecated, diff --git a/core/src/main/kotlin/io/bkbn/kompendium/core/metadata/PostInfo.kt b/core/src/main/kotlin/io/bkbn/kompendium/core/metadata/PostInfo.kt index 666137fcb..1af5f603b 100644 --- a/core/src/main/kotlin/io/bkbn/kompendium/core/metadata/PostInfo.kt +++ b/core/src/main/kotlin/io/bkbn/kompendium/core/metadata/PostInfo.kt @@ -26,12 +26,12 @@ class PostInfo private constructor( class Builder : MethodInfoWithRequest.Builder() { override fun build() = PostInfo( - request = request!!, + request = request ?: error("request info must be present"), errors = errors, - response = response!!, + response = response ?: error("response info must be present"), tags = tags, - summary = summary!!, - description = description!!, + summary = summary ?: error("Summary must be present"), + description = description ?: error("Description must be present"), externalDocumentation = externalDocumentation, operationId = operationId, deprecated = deprecated, diff --git a/core/src/main/kotlin/io/bkbn/kompendium/core/metadata/PutInfo.kt b/core/src/main/kotlin/io/bkbn/kompendium/core/metadata/PutInfo.kt index b6a0af0f7..e064a04bf 100644 --- a/core/src/main/kotlin/io/bkbn/kompendium/core/metadata/PutInfo.kt +++ b/core/src/main/kotlin/io/bkbn/kompendium/core/metadata/PutInfo.kt @@ -26,12 +26,12 @@ class PutInfo private constructor( class Builder : MethodInfoWithRequest.Builder() { override fun build() = PutInfo( - request = request!!, + request = request ?: error("request info must be present"), errors = errors, - response = response!!, + response = response ?: error("response info must be present"), tags = tags, - summary = summary!!, - description = description!!, + summary = summary ?: error("Summary must be present"), + description = description ?: error("Description must be present"), externalDocumentation = externalDocumentation, operationId = operationId, deprecated = deprecated, diff --git a/core/src/main/kotlin/io/bkbn/kompendium/core/metadata/RequestInfo.kt b/core/src/main/kotlin/io/bkbn/kompendium/core/metadata/RequestInfo.kt index 99a4c4473..b1dee885f 100644 --- a/core/src/main/kotlin/io/bkbn/kompendium/core/metadata/RequestInfo.kt +++ b/core/src/main/kotlin/io/bkbn/kompendium/core/metadata/RequestInfo.kt @@ -37,8 +37,8 @@ class RequestInfo private constructor( } fun build() = RequestInfo( - requestType = requestType!!, - description = description!!, + requestType = requestType ?: error("Request type must be present"), + description = description ?: error("Description must be present"), examples = examples ) } diff --git a/core/src/main/kotlin/io/bkbn/kompendium/core/plugin/NotarizedRoute.kt b/core/src/main/kotlin/io/bkbn/kompendium/core/plugin/NotarizedRoute.kt index 4a3df5477..fd9455f4b 100644 --- a/core/src/main/kotlin/io/bkbn/kompendium/core/plugin/NotarizedRoute.kt +++ b/core/src/main/kotlin/io/bkbn/kompendium/core/plugin/NotarizedRoute.kt @@ -55,7 +55,8 @@ object NotarizedRoute { Please make sure that all notarized paths are unique """.trimIndent() } - spec.paths[routePath] = pluginConfig.path!! + spec.paths[routePath] = pluginConfig.path + ?: error("This indicates a bug in Kompendium. Please file a GitHub issue!") } val spec = application.attributes[KompendiumAttributes.openApiSpec] diff --git a/json-schema/src/main/kotlin/io/bkbn/kompendium/json/schema/handler/CollectionHandler.kt b/json-schema/src/main/kotlin/io/bkbn/kompendium/json/schema/handler/CollectionHandler.kt index 316904189..2d2a3d365 100644 --- a/json-schema/src/main/kotlin/io/bkbn/kompendium/json/schema/handler/CollectionHandler.kt +++ b/json-schema/src/main/kotlin/io/bkbn/kompendium/json/schema/handler/CollectionHandler.kt @@ -14,7 +14,8 @@ import kotlin.reflect.KType object CollectionHandler { fun handle(type: KType, cache: MutableMap): JsonSchema { - val collectionType = type.arguments.first().type!! + val collectionType = type.arguments.first().type + ?: error("This indicates a bug in Kompendium, please open a GitHub issue!") val typeSchema = SchemaGenerator.fromTypeToSchema(collectionType, cache).let { if (it is TypeDefinition && it.type == "object") { cache[collectionType.getSimpleSlug()] = it diff --git a/json-schema/src/main/kotlin/io/bkbn/kompendium/json/schema/handler/MapHandler.kt b/json-schema/src/main/kotlin/io/bkbn/kompendium/json/schema/handler/MapHandler.kt index 5b57cf033..9d8b3bda7 100644 --- a/json-schema/src/main/kotlin/io/bkbn/kompendium/json/schema/handler/MapHandler.kt +++ b/json-schema/src/main/kotlin/io/bkbn/kompendium/json/schema/handler/MapHandler.kt @@ -15,10 +15,10 @@ import kotlin.reflect.KType object MapHandler { fun handle(type: KType, cache: MutableMap): JsonSchema { - require(type.arguments.first().type!!.classifier as KClass<*> == String::class) { + require(type.arguments.first().type?.classifier as KClass<*> == String::class) { "JSON requires that map keys MUST be Strings. You provided ${type.arguments.first().type}" } - val valueType = type.arguments[1].type!! + val valueType = type.arguments[1].type ?: error("this indicates a bug in Kompendium, please open a GitHub issue") val valueSchema = SchemaGenerator.fromTypeToSchema(valueType, cache).let { if (it is TypeDefinition && it.type == "object") { cache[valueType.getSimpleSlug()] = it diff --git a/json-schema/src/main/kotlin/io/bkbn/kompendium/json/schema/handler/SimpleObjectHandler.kt b/json-schema/src/main/kotlin/io/bkbn/kompendium/json/schema/handler/SimpleObjectHandler.kt index 4373b0f3e..5f487c26c 100644 --- a/json-schema/src/main/kotlin/io/bkbn/kompendium/json/schema/handler/SimpleObjectHandler.kt +++ b/json-schema/src/main/kotlin/io/bkbn/kompendium/json/schema/handler/SimpleObjectHandler.kt @@ -92,7 +92,8 @@ object SimpleObjectHandler { typeMap: Map, cache: MutableMap ): JsonSchema { - val type = typeMap[prop.returnType.classifier]?.type!! + val type = typeMap[prop.returnType.classifier]?.type + ?: error("This indicates a bug in Kompendium, please open a GitHub issue") return SchemaGenerator.fromTypeToSchema(type, cache).let { if (it.isOrContainsObjectDef()) { cache[type.getSimpleSlug()] = it @@ -119,5 +120,5 @@ object SimpleObjectHandler { return isTypeDef || isTypeDefOneOf } - private fun JsonSchema.isNullable(): Boolean = this is OneOfDefinition && this.oneOf.any{ it is NullableDefinition } + private fun JsonSchema.isNullable(): Boolean = this is OneOfDefinition && this.oneOf.any { it is NullableDefinition } }