chore: clean up some bad habits
This commit is contained in:
@ -25,11 +25,11 @@ class DeleteInfo private constructor(
|
|||||||
|
|
||||||
class Builder : MethodInfo.Builder<DeleteInfo>() {
|
class Builder : MethodInfo.Builder<DeleteInfo>() {
|
||||||
override fun build() = DeleteInfo(
|
override fun build() = DeleteInfo(
|
||||||
response = response!!,
|
response = response ?: error("Response info must be present"),
|
||||||
errors = errors,
|
errors = errors,
|
||||||
tags = tags,
|
tags = tags,
|
||||||
summary = summary!!,
|
summary = summary ?: error("Summary must be present"),
|
||||||
description = description!!,
|
description = description ?: error("Description must be present"),
|
||||||
externalDocumentation = externalDocumentation,
|
externalDocumentation = externalDocumentation,
|
||||||
operationId = operationId,
|
operationId = operationId,
|
||||||
deprecated = deprecated,
|
deprecated = deprecated,
|
||||||
|
@ -25,11 +25,11 @@ class HeadInfo private constructor(
|
|||||||
|
|
||||||
class Builder : MethodInfo.Builder<HeadInfo>() {
|
class Builder : MethodInfo.Builder<HeadInfo>() {
|
||||||
override fun build() = HeadInfo(
|
override fun build() = HeadInfo(
|
||||||
response = response!!,
|
response = response ?: error("Response info must be present"),
|
||||||
errors = errors,
|
errors = errors,
|
||||||
tags = tags,
|
tags = tags,
|
||||||
summary = summary!!,
|
summary = summary ?: error("Summary must be present"),
|
||||||
description = description!!,
|
description = description ?: error("Description must be present"),
|
||||||
externalDocumentation = externalDocumentation,
|
externalDocumentation = externalDocumentation,
|
||||||
operationId = operationId,
|
operationId = operationId,
|
||||||
deprecated = deprecated,
|
deprecated = deprecated,
|
||||||
|
@ -25,11 +25,11 @@ class OptionsInfo private constructor(
|
|||||||
|
|
||||||
class Builder : MethodInfo.Builder<OptionsInfo>() {
|
class Builder : MethodInfo.Builder<OptionsInfo>() {
|
||||||
override fun build() = OptionsInfo(
|
override fun build() = OptionsInfo(
|
||||||
response = response!!,
|
response = response ?: error("Response info must be provided!"),
|
||||||
errors = errors,
|
errors = errors,
|
||||||
tags = tags,
|
tags = tags,
|
||||||
summary = summary!!,
|
summary = summary ?: error("Summary must be provided!"),
|
||||||
description = description!!,
|
description = description ?: error("Description must be provided!"),
|
||||||
externalDocumentation = externalDocumentation,
|
externalDocumentation = externalDocumentation,
|
||||||
operationId = operationId,
|
operationId = operationId,
|
||||||
deprecated = deprecated,
|
deprecated = deprecated,
|
||||||
|
@ -26,12 +26,12 @@ class PatchInfo private constructor(
|
|||||||
|
|
||||||
class Builder : MethodInfoWithRequest.Builder<PatchInfo>() {
|
class Builder : MethodInfoWithRequest.Builder<PatchInfo>() {
|
||||||
override fun build() = PatchInfo(
|
override fun build() = PatchInfo(
|
||||||
request = request!!,
|
request = request ?: error("request info must be present"),
|
||||||
errors = errors,
|
errors = errors,
|
||||||
response = response!!,
|
response = response ?: error("response info must be present"),
|
||||||
tags = tags,
|
tags = tags,
|
||||||
summary = summary!!,
|
summary = summary ?: error("Summary must be present"),
|
||||||
description = description!!,
|
description = description ?: error("Description must be present"),
|
||||||
externalDocumentation = externalDocumentation,
|
externalDocumentation = externalDocumentation,
|
||||||
operationId = operationId,
|
operationId = operationId,
|
||||||
deprecated = deprecated,
|
deprecated = deprecated,
|
||||||
|
@ -26,12 +26,12 @@ class PostInfo private constructor(
|
|||||||
|
|
||||||
class Builder : MethodInfoWithRequest.Builder<PostInfo>() {
|
class Builder : MethodInfoWithRequest.Builder<PostInfo>() {
|
||||||
override fun build() = PostInfo(
|
override fun build() = PostInfo(
|
||||||
request = request!!,
|
request = request ?: error("request info must be present"),
|
||||||
errors = errors,
|
errors = errors,
|
||||||
response = response!!,
|
response = response ?: error("response info must be present"),
|
||||||
tags = tags,
|
tags = tags,
|
||||||
summary = summary!!,
|
summary = summary ?: error("Summary must be present"),
|
||||||
description = description!!,
|
description = description ?: error("Description must be present"),
|
||||||
externalDocumentation = externalDocumentation,
|
externalDocumentation = externalDocumentation,
|
||||||
operationId = operationId,
|
operationId = operationId,
|
||||||
deprecated = deprecated,
|
deprecated = deprecated,
|
||||||
|
@ -26,12 +26,12 @@ class PutInfo private constructor(
|
|||||||
|
|
||||||
class Builder : MethodInfoWithRequest.Builder<PutInfo>() {
|
class Builder : MethodInfoWithRequest.Builder<PutInfo>() {
|
||||||
override fun build() = PutInfo(
|
override fun build() = PutInfo(
|
||||||
request = request!!,
|
request = request ?: error("request info must be present"),
|
||||||
errors = errors,
|
errors = errors,
|
||||||
response = response!!,
|
response = response ?: error("response info must be present"),
|
||||||
tags = tags,
|
tags = tags,
|
||||||
summary = summary!!,
|
summary = summary ?: error("Summary must be present"),
|
||||||
description = description!!,
|
description = description ?: error("Description must be present"),
|
||||||
externalDocumentation = externalDocumentation,
|
externalDocumentation = externalDocumentation,
|
||||||
operationId = operationId,
|
operationId = operationId,
|
||||||
deprecated = deprecated,
|
deprecated = deprecated,
|
||||||
|
@ -37,8 +37,8 @@ class RequestInfo private constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun build() = RequestInfo(
|
fun build() = RequestInfo(
|
||||||
requestType = requestType!!,
|
requestType = requestType ?: error("Request type must be present"),
|
||||||
description = description!!,
|
description = description ?: error("Description must be present"),
|
||||||
examples = examples
|
examples = examples
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,8 @@ object NotarizedRoute {
|
|||||||
Please make sure that all notarized paths are unique
|
Please make sure that all notarized paths are unique
|
||||||
""".trimIndent()
|
""".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]
|
val spec = application.attributes[KompendiumAttributes.openApiSpec]
|
||||||
|
@ -14,7 +14,8 @@ import kotlin.reflect.KType
|
|||||||
object CollectionHandler {
|
object CollectionHandler {
|
||||||
|
|
||||||
fun handle(type: KType, cache: MutableMap<String, JsonSchema>): JsonSchema {
|
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 {
|
val typeSchema = SchemaGenerator.fromTypeToSchema(collectionType, cache).let {
|
||||||
if (it is TypeDefinition && it.type == "object") {
|
if (it is TypeDefinition && it.type == "object") {
|
||||||
cache[collectionType.getSimpleSlug()] = it
|
cache[collectionType.getSimpleSlug()] = it
|
||||||
|
@ -15,10 +15,10 @@ import kotlin.reflect.KType
|
|||||||
object MapHandler {
|
object MapHandler {
|
||||||
|
|
||||||
fun handle(type: KType, cache: MutableMap<String, JsonSchema>): JsonSchema {
|
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}"
|
"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 {
|
val valueSchema = SchemaGenerator.fromTypeToSchema(valueType, cache).let {
|
||||||
if (it is TypeDefinition && it.type == "object") {
|
if (it is TypeDefinition && it.type == "object") {
|
||||||
cache[valueType.getSimpleSlug()] = it
|
cache[valueType.getSimpleSlug()] = it
|
||||||
|
@ -92,7 +92,8 @@ object SimpleObjectHandler {
|
|||||||
typeMap: Map<KTypeParameter, KTypeProjection>,
|
typeMap: Map<KTypeParameter, KTypeProjection>,
|
||||||
cache: MutableMap<String, JsonSchema>
|
cache: MutableMap<String, JsonSchema>
|
||||||
): 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 {
|
return SchemaGenerator.fromTypeToSchema(type, cache).let {
|
||||||
if (it.isOrContainsObjectDef()) {
|
if (it.isOrContainsObjectDef()) {
|
||||||
cache[type.getSimpleSlug()] = it
|
cache[type.getSimpleSlug()] = it
|
||||||
@ -119,5 +120,5 @@ object SimpleObjectHandler {
|
|||||||
return isTypeDef || isTypeDefOneOf
|
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 }
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user