chore: clean up some bad habits
This commit is contained in:
@ -25,11 +25,11 @@ class DeleteInfo private constructor(
|
||||
|
||||
class Builder : MethodInfo.Builder<DeleteInfo>() {
|
||||
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,
|
||||
|
@ -25,11 +25,11 @@ class HeadInfo private constructor(
|
||||
|
||||
class Builder : MethodInfo.Builder<HeadInfo>() {
|
||||
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,
|
||||
|
@ -25,11 +25,11 @@ class OptionsInfo private constructor(
|
||||
|
||||
class Builder : MethodInfo.Builder<OptionsInfo>() {
|
||||
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,
|
||||
|
@ -26,12 +26,12 @@ class PatchInfo private constructor(
|
||||
|
||||
class Builder : MethodInfoWithRequest.Builder<PatchInfo>() {
|
||||
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,
|
||||
|
@ -26,12 +26,12 @@ class PostInfo private constructor(
|
||||
|
||||
class Builder : MethodInfoWithRequest.Builder<PostInfo>() {
|
||||
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,
|
||||
|
@ -26,12 +26,12 @@ class PutInfo private constructor(
|
||||
|
||||
class Builder : MethodInfoWithRequest.Builder<PutInfo>() {
|
||||
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,
|
||||
|
@ -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
|
||||
)
|
||||
}
|
||||
|
@ -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]
|
||||
|
@ -14,7 +14,8 @@ import kotlin.reflect.KType
|
||||
object CollectionHandler {
|
||||
|
||||
fun handle(type: KType, cache: MutableMap<String, JsonSchema>): 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
|
||||
|
@ -15,10 +15,10 @@ import kotlin.reflect.KType
|
||||
object MapHandler {
|
||||
|
||||
fun handle(type: KType, cache: MutableMap<String, JsonSchema>): 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
|
||||
|
@ -92,7 +92,8 @@ object SimpleObjectHandler {
|
||||
typeMap: Map<KTypeParameter, KTypeProjection>,
|
||||
cache: MutableMap<String, JsonSchema>
|
||||
): 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
|
||||
|
Reference in New Issue
Block a user