Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ subprojects {
sign(publishing.publications)
}
configure<MavenPublishBaseExtension> {
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL)
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL, true)

val projectGroup = property("project.group").toString()
val projectArtifactId = name.replace("-gradle-plugin", ".gradle.plugin")
Expand Down
Original file line number Diff line number Diff line change
@@ -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<T : StandaloneContextEnvironment<T>> : StandaloneContextEnvironment<T>, AbstractDocumentContextEnvironment() {
protected val controllers: MutableList<Any> = mutableListOf()
protected val controllerAdvices: MutableList<Any> = mutableListOf()
protected val converters: MutableList<Converter<*, *>> = mutableListOf()
protected var codec: ObjectMapper? = null

override fun codec(codec: ObjectMapper): T {
Expand Down Expand Up @@ -42,4 +44,19 @@ abstract class AbstractStandaloneContextEnvironment<T : StandaloneContextEnviron
this.controllerAdvices.addAll(controllerAdvices)
return this as T
}

override fun converter(converter: Converter<*, *>): 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<Converter<*, *>>): T {
this.converters.addAll(converters)
return this as T
}
}
Original file line number Diff line number Diff line change
@@ -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<T : StandaloneContextEnvironment<T>> : DocumentContextEnvironment {

Expand All @@ -18,4 +19,10 @@ interface StandaloneContextEnvironment<T : StandaloneContextEnvironment<T>> : Do

fun controllerAdvices(controllerAdvices: List<Any>): T

fun converter(converter: Converter<*, *>): T

fun converters(vararg converters: Converter<*, *>): T

fun converters(converters: List<Converter<*, *>>): T

}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<StandaloneMockMvcBuilder>(documentationConfiguration(provider))
.apply { if (codec != null) {
val objectMapper = codec!!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
4 changes: 0 additions & 4 deletions documentify-starters/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
Loading