This repository has been archived by the owner on Nov 2, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
swagger use default response messages is false by default
- Loading branch information
sokomishalov
committed
Oct 22, 2019
1 parent
817f275
commit 8805f96
Showing
1 changed file
with
32 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,38 +52,42 @@ fun Docket.customizeDocket( | |
securityScheme: SecurityScheme? = null, | ||
ignoredParameterTypes: List<Class<out Any>> = listOf(ServerHttpRequest::class.java, Continuation::class.java), | ||
genericModelSubstitutes: List<Class<out Any>> = listOf(ResponseEntity::class.java), | ||
useDefaultResponseMessages: Boolean = false, | ||
title: String = EMPTY, | ||
description: String = EMPTY, | ||
contact: Contact = Contact("Sokolov Mikhael", "https://sokomishalov.github.io/about-me", "[email protected]"), | ||
version: String = "1.0.0" | ||
): Docket = this | ||
.securityContexts(when { | ||
securityContext != null -> listOf(securityContext) | ||
else -> emptyList() | ||
}) | ||
.securitySchemes(when { | ||
securityScheme != null -> listOf(securityScheme) | ||
else -> emptyList() | ||
}) | ||
.ignoredParameterTypes(*ignoredParameterTypes.toTypedArray()) | ||
.genericModelSubstitutes(*genericModelSubstitutes.toTypedArray()) | ||
.alternateTypeRules( | ||
newRule( | ||
TYPE_RESOLVER.resolve(Flux::class.java, FilePart::class.java), | ||
TYPE_RESOLVER.resolve(List::class.java, MultipartFile::class.java) | ||
), | ||
newRule( | ||
TYPE_RESOLVER.resolve(Mono::class.java, FilePart::class.java), | ||
TYPE_RESOLVER.resolve(MultipartFile::class.java) | ||
) | ||
) | ||
.apiInfo(ApiInfoBuilder() | ||
.title(title) | ||
.description(description) | ||
.contact(contact) | ||
.version(version) | ||
.build() | ||
) | ||
): Docket { | ||
return this | ||
.useDefaultResponseMessages(useDefaultResponseMessages) | ||
.securityContexts(when { | ||
securityContext != null -> listOf(securityContext) | ||
else -> emptyList() | ||
}) | ||
.securitySchemes(when { | ||
securityScheme != null -> listOf(securityScheme) | ||
else -> emptyList() | ||
}) | ||
.ignoredParameterTypes(*ignoredParameterTypes.toTypedArray()) | ||
.genericModelSubstitutes(*genericModelSubstitutes.toTypedArray()) | ||
.alternateTypeRules( | ||
newRule( | ||
TYPE_RESOLVER.resolve(Flux::class.java, FilePart::class.java), | ||
TYPE_RESOLVER.resolve(List::class.java, MultipartFile::class.java) | ||
), | ||
newRule( | ||
TYPE_RESOLVER.resolve(Mono::class.java, FilePart::class.java), | ||
TYPE_RESOLVER.resolve(MultipartFile::class.java) | ||
) | ||
) | ||
.apiInfo(ApiInfoBuilder() | ||
.title(title) | ||
.description(description) | ||
.contact(contact) | ||
.version(version) | ||
.build() | ||
) | ||
} | ||
|
||
|
||
private val TYPE_RESOLVER = TypeResolver() |