Skip to content
This repository has been archived by the owner on Nov 2, 2021. It is now read-only.

Commit

Permalink
1.1.19
Browse files Browse the repository at this point in the history
  • Loading branch information
sokomishalov committed Aug 2, 2020
1 parent 706dc2b commit d8106f4
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 17 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Add the dependency:
<dependency>
<groupId>com.github.sokomishalov.commons</groupId>
<artifactId>commons-[module]</artifactId>
<version>1.1.18</version>
<version>1.1.19</version>
</dependency>
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,5 @@ import ru.sokomishalov.commons.core.serialization.OBJECT_MAPPER
* @author sokomishalov
*/


val JACKSON_ENCODER = Jackson2JsonEncoder(OBJECT_MAPPER)


val JACKSON_DECODER = Jackson2JsonDecoder(OBJECT_MAPPER)
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package ru.sokomishalov.commons.spring.swagger

import com.fasterxml.classmate.ResolvedType
import com.fasterxml.classmate.TypeResolver
import org.springframework.web.method.HandlerMethod
import springfox.documentation.spring.web.readers.operation.HandlerMethodResolver
import kotlin.reflect.jvm.javaType
import kotlin.reflect.jvm.kotlinFunction

/**
* @author sokomishalov
*/
class KotlinFriendlyHandlerMethodResolver(
private val typeResolver: TypeResolver
) : HandlerMethodResolver(typeResolver) {

override fun methodReturnType(handlerMethod: HandlerMethod?): ResolvedType {
val kFunction = handlerMethod?.method?.kotlinFunction
return when {
kFunction != null -> typeResolver.resolve(kFunction.returnType.javaType)
else -> super.methodReturnType(handlerMethod)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import com.fasterxml.classmate.TypeResolver
import org.springframework.boot.info.BuildProperties
import org.springframework.http.ResponseEntity
import org.springframework.http.codec.multipart.FilePart
import org.springframework.http.server.reactive.ServerHttpRequest
import org.springframework.web.multipart.MultipartFile
import reactor.core.publisher.Flux
import reactor.core.publisher.Mono
Expand All @@ -30,11 +29,12 @@ import springfox.documentation.builders.RequestHandlerSelectors.basePackage
import springfox.documentation.schema.AlternateTypeRules.newRule
import springfox.documentation.service.Contact
import springfox.documentation.service.SecurityScheme
import springfox.documentation.spi.DocumentationType.SWAGGER_2
import springfox.documentation.spi.DocumentationType
import springfox.documentation.spi.DocumentationType.OAS_30
import springfox.documentation.spi.service.contexts.SecurityContext
import springfox.documentation.spring.web.plugins.Docket
import java.util.concurrent.CompletableFuture
import kotlin.coroutines.Continuation
import java.util.concurrent.Future

/**
* @author sokomishalov
Expand All @@ -45,8 +45,8 @@ const val REDIRECT_TO_SWAGGER = "redirect:${SWAGGER_UI_PAGE}"
private val DEFAULT_AUTHOR = Contact("Sokolov Mikhael", "https://sokomishalov.github.io/about-me", "sokomishalov@mail.ru")
private val TYPE_RESOLVER = TypeResolver()

inline fun <reified T : Any> initDocket(): Docket {
return Docket(SWAGGER_2)
inline fun <reified T : Any> initDocket(type: DocumentationType = OAS_30): Docket {
return Docket(type)
.select()
.apis(basePackage(T::class.java.`package`.name))
.paths { true }
Expand All @@ -56,8 +56,8 @@ inline fun <reified T : Any> initDocket(): Docket {
fun Docket.customize(
securityContext: SecurityContext? = null,
securityScheme: SecurityScheme? = null,
ignoredParameterTypes: List<Class<out Any>> = listOf(ServerHttpRequest::class.java, Continuation::class.java),
genericModelSubstitutes: List<Class<out Any>> = listOf(ResponseEntity::class.java, CompletableFuture::class.java),
ignoredParameterTypes: List<Class<out Any>> = emptyList(),
genericModelSubstitutes: List<Class<out Any>> = listOf(ResponseEntity::class.java, CompletableFuture::class.java, Future::class.java),
useDefaultResponseMessages: Boolean = false,
buildProperties: BuildProperties? = null,
title: String = buildProperties?.name.orEmpty(),
Expand Down
12 changes: 6 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@
<packaging>pom</packaging>

<properties>
<revision>1.1.18</revision>
<revision>1.1.19</revision>

<java.version>1.8</java.version>
<kotlin.version>1.3.72</kotlin.version>
<kotlinx-coroutines.version>1.3.7</kotlinx-coroutines.version>
<kotlinx-coroutines.version>1.3.8</kotlinx-coroutines.version>
<jackson.version>2.11.1</jackson.version>
<reactor.version>3.3.7.RELEASE</reactor.version>
<reactor-netty.version>0.9.9.RELEASE</reactor-netty.version>
<reactor.version>3.3.8.RELEASE</reactor.version>
<reactor-netty.version>0.9.10.RELEASE</reactor-netty.version>
<javax-servlet-api.version>4.0.1</javax-servlet-api.version>
<slf4j.version>1.7.30</slf4j.version>
<logback.version>1.2.3</logback.version>
<spring.boot.version>2.3.1.RELEASE</spring.boot.version>
<spring.version>5.2.7.RELEASE</spring.version>
<spring.boot.version>2.3.2.RELEASE</spring.boot.version>
<spring.version>5.2.8.RELEASE</spring.version>
<springfox.version>3.0.0</springfox.version>
</properties>

Expand Down

0 comments on commit d8106f4

Please sign in to comment.