Repository: cjbooms/fabrikt
Pull request #48 (2021-05-14 22:42:18)

Removing lots of redundant code and fixing warnings
Removing lots of redundant code and fixing warnings

cjbooms: 👍 

Patch:
diff --git a/src/main/kotlin/com/cjbooms/fabrikt/cli/CodeGenOptions.kt b/src/main/kotlin/com/cjbooms/fabrikt/cli/CodeGenOptions.kt
index c244a3c..77e16cc 100644
--- a/src/main/kotlin/com/cjbooms/fabrikt/cli/CodeGenOptions.kt
+++ b/src/main/kotlin/com/cjbooms/fabrikt/cli/CodeGenOptions.kt
@@ -1,44 +1,22 @@
 package com.cjbooms.fabrikt.cli
 
-enum class CodeGenerationType(val description: String, val requires: Set<InternalCodeGenGenType>) {
+enum class CodeGenerationType(val description: String) {
     HTTP_MODELS(
-        "Jackson annotated data classes to represent the schema objects defined in the input.",
-        setOf(InternalCodeGenGenType.MODELS)
+        "Jackson annotated data classes to represent the schema objects defined in the input."
     ),
     CONTROLLERS(
-        "Spring annotated HTTP controllers for each of the endpoints defined in the input.",
-        setOf(
-            InternalCodeGenGenType.MODELS,
-            InternalCodeGenGenType.SERVICE_INTERFACES,
-            InternalCodeGenGenType.CONTROLLERS
-        )
+        "Spring annotated HTTP controllers for each of the endpoints defined in the input."
     ),
     CLIENT(
-        "Simple http rest client.",
-        setOf(
-            InternalCodeGenGenType.MODELS,
-            InternalCodeGenGenType.CLIENT
-        )
+        "Simple http rest client."
     ),
     QUARKUS_REFLECTION_CONFIG(
-        "This options generates the reflection-config.json file for quarkus integration projects",
-        setOf(
-            InternalCodeGenGenType.QUARKUS_REFLECTION_RESOURCE
-        )
+        "This options generates the reflection-config.json file for quarkus integration projects"
     );
 
     override fun toString() = "`${super.toString()}` - $description"
 }
 
-// Ordering is important here...
-enum class InternalCodeGenGenType {
-    MODELS,
-    CONTROLLERS,
-    SERVICE_INTERFACES,
-    CLIENT,
-    QUARKUS_REFLECTION_RESOURCE
-}
-
 enum class ClientCodeGenOptionType(private val description: String) {
     RESILIENCE4J("Generates a fault tolerance service for the client using the following library \"io.github.resilience4j:resilience4j-all:+\"");
 
diff --git a/src/main/kotlin/com/cjbooms/fabrikt/cli/CodeGenerator.kt b/src/main/kotlin/com/cjbooms/fabrikt/cli/CodeGenerator.kt
index fb88d82..d5730b9 100644
--- a/src/main/kotlin/com/cjbooms/fabrikt/cli/CodeGenerator.kt
+++ b/src/main/kotlin/com/cjbooms/fabrikt/cli/CodeGenerator.kt
@@ -55,7 +55,7 @@ class CodeGenerator(private val packages: Packages, private val sourceApi: Sourc
         listOfNotNull(QuarkusReflectionModelGenerator(models, MutableSettings.generationTypes()).generate())
 
     private fun controllers(): Controllers =
-        SpringControllerInterfaceGenerator(packages, sourceApi, models().models).generate()
+        SpringControllerInterfaceGenerator(packages, sourceApi).generate()
 
     private fun client(): Clients =
         OkHttpClientGenerator(packages, sourceApi).generate(MutableSettings.clientOptions())
diff --git a/src/main/kotlin/com/cjbooms/fabrikt/cli/MarkdownUsageFormatter.kt b/src/main/kotlin/com/cjbooms/fabrikt/cli/MarkdownUsageFormatter.kt
index 80db19d..e704223 100644
--- a/src/main/kotlin/com/cjbooms/fabrikt/cli/MarkdownUsageFormatter.kt
+++ b/src/main/kotlin/com/cjbooms/fabrikt/cli/MarkdownUsageFormatter.kt
@@ -63,10 +63,10 @@ class MarkdownUsageFormatter(commander: JCommander) : DefaultUsageFormatter(comm
     private fun Parameterized.isSingleEnum() = Enum::class.java.isAssignableFrom(type)
 
     private fun getFirstColumnWidth(sortedParameters: List<ParameterDescription>): Int =
-        sortedParameters.fold(0, { currentMaxWidth, pd ->
+        sortedParameters.fold(0) { currentMaxWidth, pd ->
             val entry = pd.getParameterKey()
             if (entry.length > currentMaxWidth) entry.length else currentMaxWidth
-        })
+        }
 
     @Suppress("UNCHECKED_CAST")
     private fun getEnumValues(parameterized: Parameterized): List<Enum<*>> {
diff --git a/src/main/kotlin/com/cjbooms/fabrikt/generators/controller/ControllerGeneratorUtils.kt b/src/main/kotlin/com/cjbooms/fabrikt/generators/controller/ControllerGeneratorUtils.kt
index 7dde895..6565364 100644
--- a/src/main/kotlin/com/cjbooms/fabrikt/generators/controller/ControllerGeneratorUtils.kt
+++ b/src/main/kotlin/com/cjbooms/fabrikt/generators/controller/ControllerGeneratorUtils.kt
@@ -39,10 +39,10 @@ object ControllerGeneratorUtils {
             }.toMap()
 
         // Happy path, just pull out the http code with the lowest value. Later we may have conditional responses
-        val code: Int = toResponseMapping.keys.minOrNull() ?: throw IllegalStateException("Could not extract the response for $this")
-        val response = toResponseMapping[code]!!
+        val code: Int = toResponseMapping.keys.minOrNull()
+            ?: throw IllegalStateException("Could not extract the response for $this")
 
-        return response
+        return toResponseMapping[code]!!
     }
 
     /**
diff --git a/src/main/kotlin/com/cjbooms/fabrikt/generators/controller/SpringControllerInterfaceGenerator.kt b/src/main/kotlin/com/cjbooms/fabrikt/generators/controller/SpringControllerInterfaceGenerator.kt
index f233ac3..4721a9c 100644
--- a/src/main/kotlin/com/cjbooms/fabrikt/generators/controller/SpringControllerInterfaceGenerator.kt
+++ b/src/main/kotlin/com/cjbooms/fabrikt/generators/controller/SpringControllerInterfaceGenerator.kt
@@ -13,7 +13,6 @@ import com.cjbooms.fabrikt.model.BodyParameter
 import com.cjbooms.fabrikt.model.ControllerType
 import com.cjbooms.fabrikt.model.Controllers
 import com.cjbooms.fabrikt.model.HeaderParam
-import com.cjbooms.fabrikt.model.ModelType
 import com.cjbooms.fabrikt.model.PathParam
 import com.cjbooms.fabrikt.model.QueryParam
 import com.cjbooms.fabrikt.model.RequestParameter
@@ -31,8 +30,7 @@ import com.squareup.kotlinpoet.TypeSpec
 
 class SpringControllerInterfaceGenerator(
     private val packages: Packages,
-    private val api: SourceApi,
-    private val models: Collection<ModelType>
+    private val api: SourceApi
 ) {
 
     fun generate(): Controllers =
@@ -95,16 +93,18 @@ class SpringControllerInterfaceGenerator(
         parameters
             .map {
                 when (it) {
-                    is BodyParameter -> it
-                        .toParameterSpecBuilder()
-                        .addAnnotation(SpringAnnotations.requestBodyBuilder().build())
-                        .addAnnotation(JavaXAnnotations.validBuilder().build())
-                        .build()
-                    is RequestParameter -> it
-                        .toParameterSpecBuilder()
-                        .addValidationAnnotations(it)
-                        .addSpringParamAnnotation(it)
-                        .build()
+                    is BodyParameter ->
+                        it
+                            .toParameterSpecBuilder()
+                            .addAnnotation(SpringAnnotations.requestBodyBuilder().build())
+                            .addAnnotation(JavaXAnnotations.validBuilder().build())
+                            .build()
+                    is RequestParameter ->
+                        it
+                            .toParameterSpecBuilder()
+                            .addValidationAnnotations(it)
+                            .addSpringParamAnnotation(it)
+                            .build()
                 }
             }
             .forEach { funcSpec.addParameter(it) }
diff --git a/src/main/kotlin/com/cjbooms/fabrikt/generators/controller/metadata/Java.kt b/src/main/kotlin/com/cjbooms/fabrikt/generators/controller/metadata/Java.kt
index 633c46f..a87ce01 100644
--- a/src/main/kotlin/com/cjbooms/fabrikt/generators/controller/metadata/Java.kt
+++ b/src/main/kotlin/com/cjbooms/fabrikt/generators/controller/metadata/Java.kt
@@ -19,8 +19,6 @@ object JavaXAnnotations {
         AnnotationSpec
             .builder(Imports.VALID)
 
-    fun fieldValid(): AnnotationSpec = validBuilder().useSiteTarget(AnnotationSpec.UseSiteTarget.GET).build()
-
     private fun minBuilder(): AnnotationSpec.Builder =
         AnnotationSpec
             .builder(Imports.MIN)
diff --git a/src/main/kotlin/com/cjbooms/fabrikt/generators/controller/metadata/Spring.kt b/src/main/kotlin/com/cjbooms/fabrikt/generators/controller/metadata/Spring.kt
index 73ce5ed..c9dfe74 100644
--- a/src/main/kotlin/com/cjbooms/fabrikt/generators/controller/metadata/Spring.kt
+++ b/src/main/kotlin/com/cjbooms/fabrikt/generators/controller/metadata/Spring.kt
@@ -14,8 +14,6 @@ object SpringImports {
 
         const val WEB_BIND_ANNOTATION = "$SPRING_BASE.web.bind.annotation"
 
-        const val SERVLET_SUPPORT = "$SPRING_BASE.web.servlet.support"
-
         const val VALIDATION_ANNOTATION = "$SPRING_BASE.validation.annotation"
     }
 
@@ -35,8 +33,6 @@ object SpringImports {
 
     val VALIDATED = ClassName(Packages.VALIDATION_ANNOTATION, "Validated")
 
-    val URI_BUILDER = ClassName(Packages.SERVLET_SUPPORT, "ServletUriComponentsBuilder")
-
     object Static {
         val RESPONSE_STATUS = Pair(Packages.HTTP, "HttpStatus")
 
diff --git a/src/main/kotlin/com/cjbooms/fabrikt/generators/model/JacksonModelGenerator.kt b/src/main/kotlin/com/cjbooms/fabrikt/generators/model/JacksonModelGenerator.kt
index 0cfd2e4..8409ad1 100644
--- a/src/main/kotlin/com/cjbooms/fabrikt/generators/model/JacksonModelGenerator.kt
+++ b/src/main/kotlin/com/cjbooms/fabrikt/generators/model/JacksonModelGenerator.kt
@@ -26,7 +26,6 @@ import com.cjbooms.fabrikt.model.SourceApi
 import com.cjbooms.fabrikt.util.KaizenParserExtensions.getSuperType
 import com.cjbooms.fabrikt.util.KaizenParserExtensions.isComplexTypedAdditionalProperties
 import com.cjbooms.fabrikt.util.KaizenParserExtensions.isEnumDefinition
-import com.cjbooms.fabrikt.util.KaizenParserExtensions.isInlineableMapDefinition
 import com.cjbooms.fabrikt.util.KaizenParserExtensions.isInlinedObjectDefinition
 import com.cjbooms.fabrikt.util.KaizenParserExtensions.isPolymorphicSubType
 import com.cjbooms.fabrikt.util.KaizenParserExtensions.isPolymorphicSuperType
@@ -290,14 +289,12 @@ class JacksonModelGenerator(
                 model.schema.allOfSchemas.any { allOfRef ->
                     allOfRef.name == modelName && allOfRef.discriminator == discriminator
                 }
-            }
-            .map {
+            }.associate {
                 discriminator.mappingKey(it.schema) to toModelType(
                     packages.base,
                     KotlinTypeInfo.from(it.schema, it.name)
                 )
             }
-            .toMap()
         classBuilder.addAnnotation(polymorphicSubTypes(subTypes)).addQuarkusReflectionAnnotation()
 
         return properties.addToClass(
diff --git a/src/main/kotlin/com/cjbooms/fabrikt/model/Destinations.kt b/src/main/kotlin/com/cjbooms/fabrikt/model/Destinations.kt
index f8741d3..6fb63e7 100644
--- a/src/main/kotlin/com/cjbooms/fabrikt/model/Destinations.kt
+++ b/src/main/kotlin/com/cjbooms/fabrikt/model/Destinations.kt
@@ -4,7 +4,7 @@ import java.nio.file.Path
 import java.nio.file.Paths
 
 object Destinations {
-    val PATH_ROOT: Path = Paths.get("")
+    private val PATH_ROOT: Path = Paths.get("")
 
     const val MAIN_KT_SOURCE = "src/main/kotlin/"
     const val MAIN_RESOURCES = "src/main/resources"
diff --git a/src/main/kotlin/com/cjbooms/fabrikt/model/HandlebarsTemplates.kt b/src/main/kotlin/com/cjbooms/fabrikt/model/HandlebarsTemplates.kt
index 98edcf4..5a9d671 100644
--- a/src/main/kotlin/com/cjbooms/fabrikt/model/HandlebarsTemplates.kt
+++ b/src/main/kotlin/com/cjbooms/fabrikt/model/HandlebarsTemplates.kt
@@ -1,6 +1,5 @@
 package com.cjbooms.fabrikt.model
 
-import com.github.javaparser.utils.CodeGenerationUtils.packageToPath
 import com.github.jknack.handlebars.Handlebars
 import com.github.jknack.handlebars.Helper
 import com.github.jknack.handlebars.Options
@@ -40,15 +39,6 @@ object HandlebarsTemplates {
         FirstOccurrenceChecker.STATE_BAG.clear()
         return SimpleFile(outputDirPath.resolve(fileName), fileContents)
     }
-
-    fun applyTemplate(
-        template: Template,
-        input: Any,
-        srcDir: Path,
-        basePackage: String,
-        fileName: String,
-        postProcessor: (String) -> String = { it }
-    ) = applyTemplate(template, input, srcDir.resolve(packageToPath(basePackage)), fileName, postProcessor)
 }
 
 private class FirstOccurrenceChecker : Helper<String> {
diff --git a/src/main/kotlin/com/cjbooms/fabrikt/util/KaizenParserExtensions.kt b/src/main/kotlin/com/cjbooms/fabrikt/util/KaizenParserExtensions.kt
index 4386cab..058bf12 100644
--- a/src/main/kotlin/com/cjbooms/fabrikt/util/KaizenParserExtensions.kt
+++ b/src/main/kotlin/com/cjbooms/fabrikt/util/KaizenParserExtensions.kt
@@ -188,12 +188,4 @@ object KaizenParserExtensions {
 
     fun String.isSingleResource(): Boolean =
         count { it == '/' } % 2 == 0 && endsWith("}")
-
-    fun Path.isSingleResource(): Boolean =
-        pathString.isSingleResource()
-
-    fun Path.getResourceName() = pathString
-        .split("/")
-        .filterNot { it.isBlank() || it.matches("\\{.*}".toRegex()) }
-        .last()
 }
diff --git a/src/main/kotlin/com/cjbooms/fabrikt/util/NormalisedString.kt b/src/main/kotlin/com/cjbooms/fabrikt/util/NormalisedString.kt
index e14a74a..3b63623 100644
--- a/src/main/kotlin/com/cjbooms/fabrikt/util/NormalisedString.kt
+++ b/src/main/kotlin/com/cjbooms/fabrikt/util/NormalisedString.kt
@@ -18,10 +18,6 @@ object NormalisedString {
 
     fun String.toKotlinParameterName(): String = this.camelCase()
 
-    fun String.toDbTableName(): String = this.removeSuffix("Entity").camelToSnakeCase()
-
-    fun String.toDbFieldName(): String = this.camelToSnakeCase()
-
     fun String.camelToSnakeCase(): String =
         Regex("[A-Z]").replace(this.camelCase()) {
             "_${it.value.toLowerCase()}"
diff --git a/src/main/kotlin/com/cjbooms/fabrikt/util/OperationUtils.kt b/src/main/kotlin/com/cjbooms/fabrikt/util/OperationUtils.kt
deleted file mode 100644
index d13cc3c..0000000
--- a/src/main/kotlin/com/cjbooms/fabrikt/util/OperationUtils.kt
+++ /dev/null
@@ -1,233 +0,0 @@
-package com.cjbooms.fabrikt.util
-
-import com.cjbooms.fabrikt.model.SourceApi
-import com.cjbooms.fabrikt.util.KaizenParserExtensions.getResourceName
-import com.cjbooms.fabrikt.util.KaizenParserExtensions.isSingleResource
-import com.cjbooms.fabrikt.util.KaizenParserExtensions.safeName
-import com.reprezen.kaizen.oasparser.model3.Operation
-import com.reprezen.kaizen.oasparser.model3.Path
-
-enum class SupportedOperation {
-    // Top level resources
-    CREATE,
-    READ,
-    UPDATE,
-    QUERY,
-    // Subresource which is not a top level resource
-    CREATE_SUBRESOURCE,
-    QUERY_SUBRESOURCE,
-    UPDATE_SUBRESOURCE,
-    READ_SUBRESOURCE,
-    // Subresource which is a top level resource
-    ADD_TOP_LEVEL_SUBRESOURCE,
-    READ_TOP_LEVEL_SUBRESOURCE,
-    QUERY_TOP_LEVEL_SUBRESOURCE,
-    REMOVE_TOP_LEVEL_SUBRESOURCE,
-
-    // Fallback operations when we can't understand what's happening with the API
-    DEFAULT_GET,
-    DEFAULT_PUT,
-    DEFAULT_POST,
-    DEFAULT_DELETE
-}
-
-object OperationUtils {
-
-    private fun isTopLevelResource(path: Path): Boolean =
-        path.pathString.split("/").filterNot { it.isEmpty() }.count() <= 2
-
-    private fun isTopLevelSubResource(path: Path, api: SourceApi): Boolean =
-        !isTopLevelResource(path) && isAlsoExposedAsTopLevelResource(
-            path,
-            api
-        )
-
-    private fun isNonTopLevelSubresource(path: Path, api: SourceApi): Boolean =
-        !isTopLevelResource(path) && !isAlsoExposedAsTopLevelResource(
-            path,
-            api
-        )
-
-    private fun isAlsoExposedAsTopLevelResource(path: Path, api: SourceApi): Boolean {
-        val resourceName = path.getResourceName()
-        val indexInPath = path.pathString.split("/").indexOf(resourceName)
-        return api.openApi3.paths
-            .map { it.key }
-            .filterNot { it == path.pathString }
-            .map { it.split("/") }
-            .any {
-                val indexInDifferentPath = it.indexOf(resourceName)
-                indexInDifferentPath > -1 && indexInDifferentPath < indexInPath
-            }
-    }
-
-    private fun isGet(verb: String) = "GET" == verb.toUpperCase()
-    private fun isPost(verb: String) = "POST" == verb.toUpperCase()
-    private fun isPut(verb: String) = "PUT" == verb.toUpperCase()
-    private fun isHead(verb: String) = "HEAD" == verb.toUpperCase()
-    private fun isDelete(verb: String) = "DELETE" == verb.toUpperCase()
-
-    // Top level resources
-    private fun isRead(verb: String, path: Path): Boolean =
-        isTopLevelResource(path) && path.isSingleResource() && isGet(
-            verb
-        )
-
-    private fun isQuery(verb: String, path: Path, operation: Operation): Boolean =
-        isTopLevelResource(path) && !path.isSingleResource() && isGet(
-            verb
-        ) && operation.isListResponseType()
-
-    fun Operation.isListResponseType(): Boolean = responses
-        .filter { it.key != "default" }
-        .flatMap { resp -> resp.value.contentMediaTypes.map { it.value.schema.properties["items"]?.itemsSchema?.safeName() } }
-        .asSequence()
-        .filterNotNull()
-        .any()
-
-    private fun isCreate(verb: String, path: Path): Boolean =
-        isTopLevelResource(path) && !path.isSingleResource() && isPost(
-            verb
-        )
-
-    private fun isUpdate(verb: String, path: Path): Boolean =
-        isTopLevelResource(path) && path.isSingleResource() && isPut(
-            verb
-        )
-
-    // Subresource which is not a top level resource
-
-    private fun isReadSubresource(verb: String, path: Path, api: SourceApi): Boolean =
-        isNonTopLevelSubresource(
-            path,
-            api
-        ) && path.isSingleResource() && isGet(verb)
-
-    private fun isQuerySubresource(verb: String, path: Path, api: SourceApi, operation: Operation): Boolean =
-        isNonTopLevelSubresource(
-            path,
-            api
-        ) && !path.isSingleResource() && isGet(verb) && operation.isListResponseType()
-
-    private fun isCreateSubresource(verb: String, path: Path, api: SourceApi): Boolean =
-        isNonTopLevelSubresource(
-            path,
-            api
-        ) && !path.isSingleResource() && isPost(verb)
-
-    private fun isUpdateSubresource(verb: String, path: Path, api: SourceApi): Boolean =
-        isNonTopLevelSubresource(
-            path,
-            api
-        ) && path.isSingleResource() && isPut(verb)
-
-    // Subresource which is a top level resource
-
-    private fun isReadTopLevelSubresource(verb: String, path: Path, api: SourceApi): Boolean =
-        isTopLevelSubResource(
-            path,
-            api
-        ) && path.isSingleResource() && isGet(verb)
-
-    private fun isQueryTopLevelSubresource(verb: String, path: Path, api: SourceApi): Boolean =
-        isTopLevelSubResource(
-            path,
-            api
-        ) && !path.isSingleResource() && isGet(verb)
-
-    private fun isRemoveSubresource(verb: String, path: Path, api: SourceApi): Boolean =
-        isTopLevelSubResource(
-            path,
-            api
-        ) && path.isSingleResource() && isDelete(verb)
-
-    private fun isAddSubresource(verb: String, path: Path, api: SourceApi): Boolean =
-        isTopLevelSubResource(
-            path,
-            api
-        ) && path.isSingleResource() && isPut(verb)
-
-    private fun isHead(verb: String, path: Path): Boolean =
-        path.isSingleResource() && isHead(verb)
-
-    fun supportedOperationFrom(verb: String, operation: Operation, path: Path, api: SourceApi): SupportedOperation? {
-        return when {
-            isRead(
-                verb,
-                path
-            ) -> SupportedOperation.READ
-            isHead(
-                verb,
-                path
-            ) -> SupportedOperation.READ
-            isQuery(
-                verb,
-                path,
-                operation
-            ) -> SupportedOperation.QUERY
-            isCreate(
-                verb,
-                path
-            ) -> SupportedOperation.CREATE
-            isUpdate(
-                verb,
-                path
-            ) -> SupportedOperation.UPDATE
-
-            isReadSubresource(
-                verb,
-                path,
-                api
-            ) -> SupportedOperation.READ_SUBRESOURCE
-            isQuerySubresource(
-                verb,
-                path,
-                api,
-                operation
-            ) -> SupportedOperation.QUERY_SUBRESOURCE
-            isCreateSubresource(
-                verb,
-                path,
-                api
-            ) -> SupportedOperation.CREATE_SUBRESOURCE
-            isUpdateSubresource(
-                verb,
-                path,
-                api
-            ) -> SupportedOperation.UPDATE_SUBRESOURCE
-
-            isReadTopLevelSubresource(
-                verb,
-                path,
-                api
-            ) -> SupportedOperation.READ_TOP_LEVEL_SUBRESOURCE
-            isQueryTopLevelSubresource(
-                verb,
-                path,
-                api
-            ) -> SupportedOperation.QUERY_TOP_LEVEL_SUBRESOURCE
-            isAddSubresource(
-                verb,
-                path,
-                api
-            ) -> SupportedOperation.ADD_TOP_LEVEL_SUBRESOURCE
-            isRemoveSubresource(
-                verb,
-                path,
-                api
-            ) -> SupportedOperation.REMOVE_TOP_LEVEL_SUBRESOURCE
-
-            else -> when {
-                isGet(verb) -> SupportedOperation.DEFAULT_GET
-                isHead(verb) -> SupportedOperation.DEFAULT_GET
-                isPut(verb) -> SupportedOperation.DEFAULT_PUT
-                isPost(verb) -> SupportedOperation.DEFAULT_POST
-                isDelete(verb) -> SupportedOperation.DEFAULT_DELETE
-                else -> null
-            }
-        }
-    }
-
-    fun isResponseBodyPresent(operation: Operation): Boolean =
-        operation.responses["200"] != null
-}
diff --git a/src/main/kotlin/com/cjbooms/fabrikt/util/YamlUtils.kt b/src/main/kotlin/com/cjbooms/fabrikt/util/YamlUtils.kt
index 4853d07..f648e14 100644
--- a/src/main/kotlin/com/cjbooms/fabrikt/util/YamlUtils.kt
+++ b/src/main/kotlin/com/cjbooms/fabrikt/util/YamlUtils.kt
@@ -16,47 +16,30 @@ import java.nio.file.Paths
 object YamlUtils {
 
     val objectMapper: ObjectMapper =
-            ObjectMapper(
-                    YAMLFactory()
-                            .disable(YAMLGenerator.Feature.WRITE_DOC_START_MARKER)
-                            .enable(YAMLGenerator.Feature.MINIMIZE_QUOTES)
-            )
-                    .registerKotlinModule()
-                    .configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true)
-    private val internalMapper: ObjectMapper = ObjectMapper(YAMLFactory().disable(YAMLGenerator.Feature.WRITE_DOC_START_MARKER))
+        ObjectMapper(
+            YAMLFactory()
+                .disable(YAMLGenerator.Feature.WRITE_DOC_START_MARKER)
+                .enable(YAMLGenerator.Feature.MINIMIZE_QUOTES)
+        )
+            .registerKotlinModule()
+            .configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true)
+    private val internalMapper: ObjectMapper =
+        ObjectMapper(YAMLFactory().disable(YAMLGenerator.Feature.WRITE_DOC_START_MARKER))
 
     fun mergeYamlTrees(mainTree: String, updateTree: String) =
-            internalMapper.writeValueAsString(
-                    mergeNodes(
-                            internalMapper.readTree(mainTree),
-                            internalMapper.readTree(updateTree)
-                    )
-            )!!
-
-    fun removeNodesFromYaml(mainTree: String, nodesToStrip: List<String>): String {
-        val inputTree = objectMapper.readTree(mainTree)
-        recursivelyRemoveNodes(inputTree, nodesToStrip)
-        return objectMapper.writeValueAsString(inputTree)
-    }
+        internalMapper.writeValueAsString(
+            mergeNodes(
+                internalMapper.readTree(mainTree),
+                internalMapper.readTree(updateTree)
+            )
+        )!!
 
     fun parseOpenApi(input: String, inputDir: Path = Paths.get("").toAbsolutePath()): OpenApi3 =
-            try {
-                OpenApi3Parser().parse(input, inputDir.toUri().toURL())
-            } catch (e: NullPointerException) {
-                throw IllegalArgumentException("Failed to resolve references when parsing API. External Schema references require internet connection")
-            }
-
-    fun readYamlText(content: String): JsonNode {
-        return objectMapper.readTree(content)
-    }
-
-    private fun recursivelyRemoveNodes(currentTree: JsonNode, nodesToStrip: List<String>): JsonNode {
-        (currentTree as? ObjectNode)?.remove(nodesToStrip)
-        currentTree.map {
-            recursivelyRemoveNodes(it, nodesToStrip)
+        try {
+            OpenApi3Parser().parse(input, inputDir.toUri().toURL())
+        } catch (e: NullPointerException) {
+            throw IllegalArgumentException("Failed to resolve references when parsing API. External Schema references require internet connection")
         }
-        return currentTree
-    }
 
     /**
      * The below merge function has been shamelessly stolen from Stackoverflow: https://stackoverflow.com/a/32447591/1026785
@@ -69,8 +52,8 @@ object YamlUtils {
             if (currentNode is ArrayNode && incomingNode is ArrayNode) {
                 incomingNode.forEach {
                     if (currentNode.contains(it)) mergeNodes(
-                            currentNode.get(currentNode.indexOf(it)),
-                            it
+                        currentNode.get(currentNode.indexOf(it)),
+                        it
                     )
                     else currentNode.add(it)
                 }
diff --git a/src/main/kotlin/com/cjbooms/fabrikt/validation/Linter.kt b/src/main/kotlin/com/cjbooms/fabrikt/validation/Linter.kt
index 3a0dc62..bbeaad7 100644
--- a/src/main/kotlin/com/cjbooms/fabrikt/validation/Linter.kt
+++ b/src/main/kotlin/com/cjbooms/fabrikt/validation/Linter.kt
@@ -6,7 +6,6 @@ import java.nio.file.FileSystems
 import java.nio.file.Files
 import java.nio.file.Path
 import java.util.ServiceLoader
-import java.util.function.BiPredicate
 
 object Linter {
 
@@ -22,9 +21,10 @@ object Linter {
 
     fun lint(directory: Path) {
         val matcher = FileSystems.getDefault().getPathMatcher("glob:**.$KOTLIN_EXTENSION")
-        val ktSourceFiles = Files.find(directory, ARBITRARY_FOLDER_DEPTH, BiPredicate { file, _ ->
-            matcher.matches(file)
-        })
+        val ktSourceFiles = Files.find(
+            directory, ARBITRARY_FOLDER_DEPTH,
+            { file, _ -> matcher.matches(file) }
+        )
         ktSourceFiles.forEach { path ->
             val file = path.toFile()
             val fileContent = file.readText()
@@ -41,6 +41,7 @@ object Linter {
         KtLint.Params(
             text = rawText,
             ruleSets = lintRuleSets,
-            cb = { _, _ -> })
+            cb = { _, _ -> }
+        )
     )
 }


Test patch:
diff --git a/src/test/kotlin/com/cjbooms/fabrikt/generators/OkHttpClientGeneratorTest.kt b/src/test/kotlin/com/cjbooms/fabrikt/generators/OkHttpClientGeneratorTest.kt
index 7eb0e26..8933df7 100644
--- a/src/test/kotlin/com/cjbooms/fabrikt/generators/OkHttpClientGeneratorTest.kt
+++ b/src/test/kotlin/com/cjbooms/fabrikt/generators/OkHttpClientGeneratorTest.kt
@@ -11,18 +11,20 @@ import com.cjbooms.fabrikt.model.ClientType
 import com.cjbooms.fabrikt.model.Models
 import com.cjbooms.fabrikt.model.SimpleFile
 import com.cjbooms.fabrikt.model.SourceApi
+import com.cjbooms.fabrikt.util.ResourceHelper.readTextResource
 import com.cjbooms.fabrikt.validation.Linter
 import com.squareup.kotlinpoet.FileSpec
-import java.util.stream.Stream
 import org.assertj.core.api.Assertions.assertThat
 import org.junit.jupiter.api.BeforeEach
 import org.junit.jupiter.api.TestInstance
 import org.junit.jupiter.params.ParameterizedTest
 import org.junit.jupiter.params.provider.MethodSource
+import java.util.stream.Stream
 
 @TestInstance(TestInstance.Lifecycle.PER_CLASS)
 class OkHttpClientGeneratorTest {
 
+    @Suppress("unused")
     private fun fullApiTestCases(): Stream<String> = Stream.of(
         "okHttpClient"
     )
@@ -36,10 +38,10 @@ class OkHttpClientGeneratorTest {
     @MethodSource("fullApiTestCases")
     fun `correct api simple client is generated from a full API definition`(testCaseName: String) {
         val packages = Packages("examples.$testCaseName")
-        val sourceApi = SourceApi(javaClass.getResource("/examples/$testCaseName/api.yaml").readText())
+        val sourceApi = SourceApi(readTextResource("/examples/$testCaseName/api.yaml"))
 
-        val expectedModel = javaClass.getResource("/examples/$testCaseName/models/Models.kt").readText()
-        val expectedClient = javaClass.getResource("/examples/$testCaseName/client/ApiClient.kt").readText()
+        val expectedModel = readTextResource("/examples/$testCaseName/models/Models.kt")
+        val expectedClient = readTextResource("/examples/$testCaseName/client/ApiClient.kt")
 
         val models = JacksonModelGenerator(
             packages,
@@ -60,16 +62,16 @@ class OkHttpClientGeneratorTest {
     @MethodSource("fullApiTestCases")
     fun `correct api fault-tolerant service client is generated when the resilience4j option is set`(testCaseName: String) {
         val packages = Packages("examples.$testCaseName")
-        val sourceApi = SourceApi(javaClass.getResource("/examples/$testCaseName/api.yaml").readText())
+        val sourceApi = SourceApi(readTextResource("/examples/$testCaseName/api.yaml"))
 
-        val expectedLibUtil = javaClass.getResource("/examples/$testCaseName/client/HttpResilience4jUtil.kt").readText()
-        val expectedClientCode = javaClass.getResource("/examples/$testCaseName/client/ApiService.kt").readText()
+        val expectedLibUtil = readTextResource("/examples/$testCaseName/client/HttpResilience4jUtil.kt")
+        val expectedClientCode = readTextResource("/examples/$testCaseName/client/ApiService.kt")
 
         val generator =
             OkHttpEnhancedClientGenerator(packages, sourceApi)
         val enhancedLibUtil = generator.generateLibrary(setOf(ClientCodeGenOptionType.RESILIENCE4J))
-                .filterIsInstance<SimpleFile>()
-                .first { it.path.fileName.toString() == "HttpResilience4jUtil.kt" }
+            .filterIsInstance<SimpleFile>()
+            .first { it.path.fileName.toString() == "HttpResilience4jUtil.kt" }
         val enhancedClientCode = generator.generateDynamicClientCode(setOf(ClientCodeGenOptionType.RESILIENCE4J))
 
         assertThat(enhancedLibUtil.content).isEqualTo(expectedLibUtil)
@@ -80,7 +82,7 @@ class OkHttpClientGeneratorTest {
     @MethodSource("fullApiTestCases")
     fun `the enhanced client is not generated when no specific options are provided`(testCaseName: String) {
         val packages = Packages("examples.$testCaseName")
-        val sourceApi = SourceApi(javaClass.getResource("/examples/$testCaseName/api.yaml").readText())
+        val sourceApi = SourceApi(readTextResource("/examples/$testCaseName/api.yaml"))
 
         val enhancedClientCode = OkHttpEnhancedClientGenerator(
             packages,
@@ -93,11 +95,11 @@ class OkHttpClientGeneratorTest {
 
     @ParameterizedTest
     @MethodSource("fullApiTestCases")
-    fun `correct http utitlity libraries are generated`(testCaseName: String) {
+    fun `correct http utility libraries are generated`(testCaseName: String) {
         val packages = Packages("examples.$testCaseName")
-        val sourceApi = SourceApi(javaClass.getResource("/examples/$testCaseName/api.yaml").readText())
+        val sourceApi = SourceApi(readTextResource("/examples/$testCaseName/api.yaml"))
 
-        val expectedHttpUtils = javaClass.getResource("/examples/$testCaseName/client/HttpUtil.kt").readText()
+        val expectedHttpUtils = readTextResource("/examples/$testCaseName/client/HttpUtil.kt")
 
         val generatedHttpUtils = OkHttpSimpleClientGenerator(
             packages,
@@ -112,9 +114,9 @@ class OkHttpClientGeneratorTest {
     @MethodSource("fullApiTestCases")
     fun `correct logging interceptor libraries are generated`(testCaseName: String) {
         val packages = Packages("examples.$testCaseName")
-        val sourceApi = SourceApi(javaClass.getResource("/examples/$testCaseName/api.yaml").readText())
+        val sourceApi = SourceApi(readTextResource("/examples/$testCaseName/api.yaml"))
 
-        val expectedLoggingInterceptor = javaClass.getResource("/examples/$testCaseName/client/LoggingInterceptor.kt").readText()
+        val expectedLoggingInterceptor = readTextResource("/examples/$testCaseName/client/LoggingInterceptor.kt")
 
         val generatedLoggingInterceptor = OkHttpSimpleClientGenerator(
             packages,
diff --git a/src/test/kotlin/com/cjbooms/fabrikt/generators/SpringControllerGeneratorTest.kt b/src/test/kotlin/com/cjbooms/fabrikt/generators/SpringControllerGeneratorTest.kt
index 4ec2a5a..a90046d 100644
--- a/src/test/kotlin/com/cjbooms/fabrikt/generators/SpringControllerGeneratorTest.kt
+++ b/src/test/kotlin/com/cjbooms/fabrikt/generators/SpringControllerGeneratorTest.kt
@@ -4,7 +4,6 @@ import com.cjbooms.fabrikt.cli.CodeGenerationType
 import com.cjbooms.fabrikt.configurations.Packages
 import com.cjbooms.fabrikt.generators.controller.SpringControllerInterfaceGenerator
 import com.cjbooms.fabrikt.generators.controller.metadata.SpringImports
-import com.cjbooms.fabrikt.generators.model.JacksonModelGenerator
 import com.cjbooms.fabrikt.model.Controllers
 import com.cjbooms.fabrikt.model.Destinations.controllersPackage
 import com.cjbooms.fabrikt.model.SourceApi
@@ -32,8 +31,7 @@ class SpringControllerGeneratorTest {
 
     private fun setupGithubApiTestEnv() {
         val api = SourceApi(readTextResource("/examples/githubApi/api.yaml"))
-        val models = JacksonModelGenerator(Packages(basePackage), api).generate().models
-        generated = SpringControllerInterfaceGenerator(Packages(basePackage), api, models).generate().files
+        generated = SpringControllerInterfaceGenerator(Packages(basePackage), api).generate().files
     }
 
     @BeforeEach
@@ -85,8 +83,7 @@ class SpringControllerGeneratorTest {
     @Test
     fun `ensure that subresource specific controllers are created`() {
         val api = SourceApi(readTextResource("/examples/githubApi/api.yaml"))
-        val models = JacksonModelGenerator(Packages(basePackage), api).generate().models
-        val controllers = SpringControllerInterfaceGenerator(Packages(basePackage), api, models).generate()
+        val controllers = SpringControllerInterfaceGenerator(Packages(basePackage), api).generate()
 
         assertThat(controllers.files).size().isEqualTo(6)
         assertThat(controllers.files.map { it.name }).containsAll(
@@ -128,11 +125,9 @@ class SpringControllerGeneratorTest {
         val api = SourceApi(readTextResource("/examples/$testCaseName/api.yaml"))
         val expectedControllers = readTextResource("/examples/$testCaseName/controllers/Controllers.kt")
 
-        val models = JacksonModelGenerator(Packages(basePackage), api).generate().models
         val controllers = SpringControllerInterfaceGenerator(
             Packages(basePackage),
-            api,
-            models
+            api
         ).generate().toSingleFile()
 
         assertThat(controllers).isEqualTo(expectedControllers)