Skip to content

Commit

Permalink
Remove LoggingInterceptor. (#143)
Browse files Browse the repository at this point in the history
We should not be generating a Logging interceptor that is pinned to specific logging implementation. Removing this so people can choose whatever logging framework they like
  • Loading branch information
cjbooms authored Aug 3, 2022
1 parent 10afd15 commit 6aa99f5
Show file tree
Hide file tree
Showing 9 changed files with 2 additions and 175 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,6 @@ class OkHttpSimpleClientGenerator(
input = packages,
path = clientDir,
fileName = "OAuth.kt"
),
HandlebarsTemplates.applyTemplate(
template = HandlebarsTemplates.clientLoggingInterceptor,
input = packages,
path = clientDir,
fileName = "LoggingInterceptor.kt"
)
)
}
Expand Down Expand Up @@ -194,7 +188,8 @@ data class SimpleClientOperationStatement(
.filter { it.parameterLocation == HeaderParam }
.forEach {
this.add(
"\n.%T(%S, %L)", "header".toClassName(packages.client),
"\n.%T(%S, %L)",
"header".toClassName(packages.client),
it.originalName,
it.name + if (it.typeInfo is KotlinTypeInfo.Enum) "?.value" else ""
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ object HandlebarsTemplates {
val clientOAuth = handlebars.compile("/templates/client-code/oauth.kt")!!
val clientHttpUtils = handlebars.compile("/templates/client-code/http-util.kt")!!
val clientHttpResilience4jUtils = handlebars.compile("/templates/client-code/http-resilience4j-util.kt")!!
val clientLoggingInterceptor = handlebars.compile("/templates/client-code/logging-interceptor.kt")!!

fun applyTemplate(
template: Template,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -120,23 +120,6 @@ class OkHttpClientGeneratorTest {
assertThat(generatedHttpUtils.content).isEqualTo(expectedHttpUtils)
}

@ParameterizedTest
@MethodSource("fullApiTestCases")
fun `correct logging interceptor libraries are generated`(testCaseName: String) {
val packages = Packages("examples.$testCaseName")
val sourceApi = SourceApi(readTextResource("/examples/$testCaseName/api.yaml"))

val expectedLoggingInterceptor = readTextResource("/examples/$testCaseName/client/LoggingInterceptor.kt")

val generatedLoggingInterceptor = OkHttpSimpleClientGenerator(
packages,
sourceApi
).generateLibrary().filterIsInstance<SimpleFile>()
.first { it.path.fileName.toString() == "LoggingInterceptor.kt" }

assertThat(generatedLoggingInterceptor.content).isEqualTo(expectedLoggingInterceptor)
}

private fun Collection<ClientType>.toSingleFile(): String {
val destPackage = if (this.isNotEmpty()) first().destinationPackage else ""
val singleFileBuilder = FileSpec.builder(destPackage, "dummyFilename")
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit 6aa99f5

Please sign in to comment.