diff --git a/build.gradle.kts b/build.gradle.kts index 27c3d19..b06db1d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -69,7 +69,7 @@ subprojects { sign(publishing.publications) } configure { - publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL) + publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL, true) val projectGroup = property("project.group").toString() val projectArtifactId = name.replace("-gradle-plugin", ".gradle.plugin") diff --git a/documentify-project/documentify-core/src/main/kotlin/io/github/bgmsound/documentify/core/environment/AbstractStandaloneContextEnvironment.kt b/documentify-project/documentify-core/src/main/kotlin/io/github/bgmsound/documentify/core/environment/AbstractStandaloneContextEnvironment.kt index a971f43..73fe151 100644 --- a/documentify-project/documentify-core/src/main/kotlin/io/github/bgmsound/documentify/core/environment/AbstractStandaloneContextEnvironment.kt +++ b/documentify-project/documentify-core/src/main/kotlin/io/github/bgmsound/documentify/core/environment/AbstractStandaloneContextEnvironment.kt @@ -1,11 +1,13 @@ package io.github.bgmsound.documentify.core.environment import com.fasterxml.jackson.databind.ObjectMapper +import org.springframework.core.convert.converter.Converter @Suppress("UNCHECKED_CAST") abstract class AbstractStandaloneContextEnvironment> : StandaloneContextEnvironment, AbstractDocumentContextEnvironment() { protected val controllers: MutableList = mutableListOf() protected val controllerAdvices: MutableList = mutableListOf() + protected val converters: MutableList> = mutableListOf() protected var codec: ObjectMapper? = null override fun codec(codec: ObjectMapper): T { @@ -42,4 +44,19 @@ abstract class AbstractStandaloneContextEnvironment): T { + this.converters.add(converter) + return this as T + } + + override fun converters(vararg converters: Converter<*, *>): T { + this.converters.addAll(converters) + return this as T + } + + override fun converters(converters: List>): T { + this.converters.addAll(converters) + return this as T + } } \ No newline at end of file diff --git a/documentify-project/documentify-core/src/main/kotlin/io/github/bgmsound/documentify/core/environment/StandaloneContextEnvironment.kt b/documentify-project/documentify-core/src/main/kotlin/io/github/bgmsound/documentify/core/environment/StandaloneContextEnvironment.kt index 38123de..4464ca1 100644 --- a/documentify-project/documentify-core/src/main/kotlin/io/github/bgmsound/documentify/core/environment/StandaloneContextEnvironment.kt +++ b/documentify-project/documentify-core/src/main/kotlin/io/github/bgmsound/documentify/core/environment/StandaloneContextEnvironment.kt @@ -1,6 +1,7 @@ package io.github.bgmsound.documentify.core.environment import com.fasterxml.jackson.databind.ObjectMapper +import org.springframework.core.convert.converter.Converter interface StandaloneContextEnvironment> : DocumentContextEnvironment { @@ -18,4 +19,10 @@ interface StandaloneContextEnvironment> : Do fun controllerAdvices(controllerAdvices: List): T + fun converter(converter: Converter<*, *>): T + + fun converters(vararg converters: Converter<*, *>): T + + fun converters(converters: List>): T + } \ No newline at end of file diff --git a/documentify-project/documentify-mvc/src/main/kotlin/io/github/bgmsound/documentify/mvc/environment/StandaloneMvcContextEnvironment.kt b/documentify-project/documentify-mvc/src/main/kotlin/io/github/bgmsound/documentify/mvc/environment/StandaloneMvcContextEnvironment.kt index d36d5d6..92d6444 100644 --- a/documentify-project/documentify-mvc/src/main/kotlin/io/github/bgmsound/documentify/mvc/environment/StandaloneMvcContextEnvironment.kt +++ b/documentify-project/documentify-mvc/src/main/kotlin/io/github/bgmsound/documentify/mvc/environment/StandaloneMvcContextEnvironment.kt @@ -2,6 +2,7 @@ package io.github.bgmsound.documentify.mvc.environment import io.github.bgmsound.documentify.core.environment.AbstractStandaloneContextEnvironment import io.github.bgmsound.documentify.mvc.MvcDocumentContextEnvironment +import org.springframework.format.support.FormattingConversionService import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter import org.springframework.restdocs.RestDocumentationContextProvider import org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.documentationConfiguration @@ -35,6 +36,11 @@ class StandaloneMvcContextEnvironment private constructor( .standaloneSetup(*controllers.toTypedArray()) .setControllerAdvice(*controllerAdvices.toTypedArray()) .setCustomArgumentResolvers(*argumentResolvers.toTypedArray()) + .setConversionService(FormattingConversionService().apply { + converters.forEach { converter -> + addConverter(converter) + } + }) .apply(documentationConfiguration(provider)) .apply { if (codec != null) { val objectMapper = codec!! diff --git a/documentify-project/documentify-reactive/src/main/kotlin/io/github/bgmsound/documentify/reactive/environment/StandaloneReactiveContextEnvironment.kt b/documentify-project/documentify-reactive/src/main/kotlin/io/github/bgmsound/documentify/reactive/environment/StandaloneReactiveContextEnvironment.kt index 6b9220d..b57bd4e 100644 --- a/documentify-project/documentify-reactive/src/main/kotlin/io/github/bgmsound/documentify/reactive/environment/StandaloneReactiveContextEnvironment.kt +++ b/documentify-project/documentify-reactive/src/main/kotlin/io/github/bgmsound/documentify/reactive/environment/StandaloneReactiveContextEnvironment.kt @@ -40,6 +40,11 @@ class StandaloneReactiveContextEnvironment private constructor( .argumentResolvers { configurer -> configurer.addCustomResolver(*argumentResolvers.toTypedArray()) } + .formatters { registry -> + converters.forEach { converter -> + registry.addConverter(converter) + } + } .httpMessageCodecs { configurer -> if (codec != null) { val objectMapper = codec!! configurer.defaultCodecs().jackson2JsonDecoder(Jackson2JsonDecoder(objectMapper, MediaType.APPLICATION_JSON)) diff --git a/documentify-starters/build.gradle.kts b/documentify-starters/build.gradle.kts index 3028c0b..e3d517b 100644 --- a/documentify-starters/build.gradle.kts +++ b/documentify-starters/build.gradle.kts @@ -1,7 +1,3 @@ -plugins { - alias(libs.plugins.gradle.mavenCentral.publish) apply false -} - subprojects { with(pluginManager) { apply(rootProject.libs.plugins.gradle.mavenCentral.publish.get().pluginId) diff --git a/gradle.properties b/gradle.properties index 4b1d305..ba9944c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,7 +1,7 @@ project.name=documentify project.group=io.github.bgmsound -project.version.id=1.3.7 +project.version.id=1.3.8 project.artifact=documentify project.description=Documentify is a tool to generate API documentation from source code.