mirror of https://github.com/usbharu/Hideout.git
feat: テンプレートを追加
This commit is contained in:
parent
16462198f6
commit
ca5779b35b
|
@ -0,0 +1,96 @@
|
||||||
|
package {{package}}
|
||||||
|
|
||||||
|
{{#imports}}import {{import}}
|
||||||
|
{{/imports}}
|
||||||
|
{{#swagger2AnnotationLibrary}}
|
||||||
|
import io.swagger.v3.oas.annotations.*
|
||||||
|
import io.swagger.v3.oas.annotations.enums.*
|
||||||
|
import io.swagger.v3.oas.annotations.media.*
|
||||||
|
import io.swagger.v3.oas.annotations.responses.*
|
||||||
|
import io.swagger.v3.oas.annotations.security.*
|
||||||
|
{{/swagger2AnnotationLibrary}}
|
||||||
|
{{#swagger1AnnotationLibrary}}
|
||||||
|
import io.swagger.annotations.Api
|
||||||
|
import io.swagger.annotations.ApiOperation
|
||||||
|
import io.swagger.annotations.ApiParam
|
||||||
|
import io.swagger.annotations.ApiResponse
|
||||||
|
import io.swagger.annotations.ApiResponses
|
||||||
|
import io.swagger.annotations.Authorization
|
||||||
|
import io.swagger.annotations.AuthorizationScope
|
||||||
|
{{/swagger1AnnotationLibrary}}
|
||||||
|
import org.springframework.http.HttpStatus
|
||||||
|
import org.springframework.http.MediaType
|
||||||
|
import org.springframework.http.ResponseEntity
|
||||||
|
|
||||||
|
import org.springframework.web.bind.annotation.*
|
||||||
|
{{#useBeanValidation}}
|
||||||
|
import org.springframework.validation.annotation.Validated
|
||||||
|
{{/useBeanValidation}}
|
||||||
|
import org.springframework.web.context.request.NativeWebRequest
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired
|
||||||
|
import dev.usbharu.hideout.config.JsonOrFormBind
|
||||||
|
|
||||||
|
{{#useBeanValidation}}
|
||||||
|
import {{javaxPackage}}.validation.Valid
|
||||||
|
import {{javaxPackage}}.validation.constraints.DecimalMax
|
||||||
|
import {{javaxPackage}}.validation.constraints.DecimalMin
|
||||||
|
import {{javaxPackage}}.validation.constraints.Email
|
||||||
|
import {{javaxPackage}}.validation.constraints.Max
|
||||||
|
import {{javaxPackage}}.validation.constraints.Min
|
||||||
|
import {{javaxPackage}}.validation.constraints.NotNull
|
||||||
|
import {{javaxPackage}}.validation.constraints.Pattern
|
||||||
|
import {{javaxPackage}}.validation.constraints.Size
|
||||||
|
{{/useBeanValidation}}
|
||||||
|
|
||||||
|
{{#reactive}}
|
||||||
|
import kotlinx.coroutines.flow.Flow
|
||||||
|
{{/reactive}}
|
||||||
|
import kotlin.collections.List
|
||||||
|
import kotlin.collections.Map
|
||||||
|
|
||||||
|
@RestController{{#beanQualifiers}}("{{package}}.{{classname}}Controller"){{/beanQualifiers}}
|
||||||
|
{{#useBeanValidation}}
|
||||||
|
@Validated
|
||||||
|
{{/useBeanValidation}}
|
||||||
|
{{#swagger1AnnotationLibrary}}
|
||||||
|
@Api(value = "{{{baseName}}}", description = "The {{{baseName}}} API")
|
||||||
|
{{/swagger1AnnotationLibrary}}
|
||||||
|
{{=<% %>=}}
|
||||||
|
@RequestMapping("\${api.base-path:<%contextPath%>}")
|
||||||
|
<%={{ }}=%>
|
||||||
|
{{#operations}}
|
||||||
|
class {{classname}}Controller({{#serviceInterface}}@Autowired(required = true) val service: {{classname}}Service{{/serviceInterface}}) {
|
||||||
|
{{#operation}}
|
||||||
|
|
||||||
|
{{#swagger2AnnotationLibrary}}
|
||||||
|
@Operation(
|
||||||
|
summary = "{{{summary}}}",
|
||||||
|
operationId = "{{{operationId}}}",
|
||||||
|
description = """{{{unescapedNotes}}}""",
|
||||||
|
responses = [{{#responses}}
|
||||||
|
ApiResponse(responseCode = "{{{code}}}", description = "{{{message}}}"{{#baseType}}, content = [Content({{#isArray}}array = ArraySchema({{/isArray}}schema = Schema(implementation = {{{baseType}}}::class)){{#isArray}}){{/isArray}}]{{/baseType}}){{^-last}},{{/-last}}{{/responses}} ]{{#hasAuthMethods}},
|
||||||
|
security = [ {{#authMethods}}SecurityRequirement(name = "{{name}}"{{#isOAuth}}, scopes = [ {{#scopes}}"{{scope}}"{{^-last}}, {{/-last}}{{/scopes}} ]{{/isOAuth}}){{^-last}},{{/-last}}{{/authMethods}} ]{{/hasAuthMethods}}
|
||||||
|
){{/swagger2AnnotationLibrary}}{{#swagger1AnnotationLibrary}}
|
||||||
|
@ApiOperation(
|
||||||
|
value = "{{{summary}}}",
|
||||||
|
nickname = "{{{operationId}}}",
|
||||||
|
notes = "{{{notes}}}"{{#returnBaseType}},
|
||||||
|
response = {{{.}}}::class{{/returnBaseType}}{{#returnContainer}},
|
||||||
|
responseContainer = "{{{.}}}"{{/returnContainer}}{{#hasAuthMethods}},
|
||||||
|
authorizations = [{{#authMethods}}Authorization(value = "{{name}}"{{#isOAuth}}, scopes = [{{#scopes}}AuthorizationScope(scope = "{{scope}}", description = "{{description}}"){{^-last}}, {{/-last}}{{/scopes}}]{{/isOAuth}}){{^-last}}, {{/-last}}{{/authMethods}}]{{/hasAuthMethods}})
|
||||||
|
@ApiResponses(
|
||||||
|
value = [{{#responses}}ApiResponse(code = {{{code}}}, message = "{{{message}}}"{{#baseType}}, response = {{{.}}}::class{{/baseType}}{{#containerType}}, responseContainer = "{{{.}}}"{{/containerType}}){{^-last}},{{/-last}}{{/responses}}]){{/swagger1AnnotationLibrary}}
|
||||||
|
@RequestMapping(
|
||||||
|
method = [RequestMethod.{{httpMethod}}],
|
||||||
|
value = ["{{#lambda.escapeDoubleQuote}}{{path}}{{/lambda.escapeDoubleQuote}}"]{{#singleContentTypes}}{{#hasProduces}},
|
||||||
|
produces = "{{{vendorExtensions.x-accepts}}}"{{/hasProduces}}{{#hasConsumes}},
|
||||||
|
consumes = "{{{vendorExtensions.x-content-type}}}"{{/hasConsumes}}{{/singleContentTypes}}{{^singleContentTypes}}{{#hasProduces}},
|
||||||
|
produces = [{{#produces}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/produces}}]{{/hasProduces}}{{#hasConsumes}},
|
||||||
|
consumes = [{{#consumes}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/consumes}}]{{/hasConsumes}}{{/singleContentTypes}}
|
||||||
|
)
|
||||||
|
{{#reactive}}{{^isArray}}suspend {{/isArray}}{{/reactive}}fun {{operationId}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{^-last}},{{/-last}}{{/allParams}}): ResponseEntity<{{>returnTypes}}> {
|
||||||
|
return {{>returnValue}}
|
||||||
|
}
|
||||||
|
{{/operation}}
|
||||||
|
}
|
||||||
|
{{/operations}}
|
|
@ -0,0 +1,25 @@
|
||||||
|
package {{package}}
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Controller
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping
|
||||||
|
import java.util.Optional
|
||||||
|
import dev.usbharu.hideout.config.JsonOrFormBind
|
||||||
|
|
||||||
|
{{>generatedAnnotation}}
|
||||||
|
@Controller{{#beanQualifiers}}("{{package}}.{{classname}}Controller"){{/beanQualifiers}}
|
||||||
|
{{=<% %>=}}
|
||||||
|
@RequestMapping("\${openapi.<%title%>.base-path:<%>defaultBasePath%>}")
|
||||||
|
<%={{ }}=%>
|
||||||
|
{{#operations}}
|
||||||
|
class {{classname}}Controller(
|
||||||
|
@org.springframework.beans.factory.annotation.Autowired(required = false) delegate: {{classname}}Delegate?
|
||||||
|
) : {{classname}} {
|
||||||
|
private val delegate: {{classname}}Delegate
|
||||||
|
|
||||||
|
init {
|
||||||
|
this.delegate = Optional.ofNullable(delegate).orElse(object : {{classname}}Delegate {})
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getDelegate(): {{classname}}Delegate = delegate
|
||||||
|
}
|
||||||
|
{{/operations}}
|
|
@ -0,0 +1,46 @@
|
||||||
|
package {{package}}
|
||||||
|
|
||||||
|
{{#imports}}import {{import}}
|
||||||
|
{{/imports}}
|
||||||
|
import org.springframework.http.HttpStatus
|
||||||
|
import org.springframework.http.MediaType
|
||||||
|
import org.springframework.http.ResponseEntity
|
||||||
|
import org.springframework.web.context.request.NativeWebRequest
|
||||||
|
import org.springframework.core.io.Resource
|
||||||
|
{{#reactive}}
|
||||||
|
import kotlinx.coroutines.flow.Flow
|
||||||
|
{{/reactive}}
|
||||||
|
|
||||||
|
import java.util.Optional
|
||||||
|
{{#async}}
|
||||||
|
import java.util.concurrent.CompletableFuture
|
||||||
|
{{/async}}
|
||||||
|
|
||||||
|
{{#operations}}
|
||||||
|
/**
|
||||||
|
* A delegate to be called by the {@link {{classname}}Controller}}.
|
||||||
|
* Implement this interface with a {@link org.springframework.stereotype.Service} annotated class.
|
||||||
|
*/
|
||||||
|
{{>generatedAnnotation}}
|
||||||
|
interface {{classname}}Delegate {
|
||||||
|
|
||||||
|
fun getRequest(): Optional
|
||||||
|
<NativeWebRequest> = Optional.empty()
|
||||||
|
{{#operation}}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see {{classname}}#{{operationId}}
|
||||||
|
*/
|
||||||
|
{{#reactive}}{{^isArray}}suspend {{/isArray}}{{/reactive}}fun {{operationId}}({{#allParams}}{{paramName}}
|
||||||
|
: {{^isFile}}{{^reactive}}{{>optionalDataType}}{{/reactive}}{{#reactive}}{{^isArray}}{{>optionalDataType}}{{/isArray}}{{#isArray}}{{#isBodyParam}}
|
||||||
|
Flow<{{{baseType}}}
|
||||||
|
>{{/isBodyParam}}{{^isBodyParam}}{{>optionalDataType}}{{/isBodyParam}}{{/isArray}}{{/reactive}}{{/isFile}}{{#isFile}}
|
||||||
|
Resource?{{/isFile}}{{^-last}},
|
||||||
|
{{/-last}}{{/allParams}}): {{#responseWrapper}}{{.}}
|
||||||
|
<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {
|
||||||
|
{{>methodBody}}
|
||||||
|
}
|
||||||
|
|
||||||
|
{{/operation}}
|
||||||
|
}
|
||||||
|
{{/operations}}
|
|
@ -0,0 +1,112 @@
|
||||||
|
/**
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) ({{{generatorVersion}}}).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
package {{package}}
|
||||||
|
|
||||||
|
{{#imports}}import {{import}}
|
||||||
|
{{/imports}}
|
||||||
|
{{#swagger2AnnotationLibrary}}
|
||||||
|
import io.swagger.v3.oas.annotations.*
|
||||||
|
import io.swagger.v3.oas.annotations.enums.*
|
||||||
|
import io.swagger.v3.oas.annotations.media.*
|
||||||
|
import io.swagger.v3.oas.annotations.responses.*
|
||||||
|
import io.swagger.v3.oas.annotations.security.*
|
||||||
|
{{/swagger2AnnotationLibrary}}
|
||||||
|
{{#swagger1AnnotationLibrary}}
|
||||||
|
import io.swagger.annotations.Api
|
||||||
|
import io.swagger.annotations.ApiOperation
|
||||||
|
import io.swagger.annotations.ApiParam
|
||||||
|
import io.swagger.annotations.ApiResponse
|
||||||
|
import io.swagger.annotations.ApiResponses
|
||||||
|
import io.swagger.annotations.Authorization
|
||||||
|
import io.swagger.annotations.AuthorizationScope
|
||||||
|
{{/swagger1AnnotationLibrary}}
|
||||||
|
import org.springframework.http.HttpStatus
|
||||||
|
import org.springframework.http.MediaType
|
||||||
|
import org.springframework.http.ResponseEntity
|
||||||
|
|
||||||
|
import org.springframework.web.bind.annotation.*
|
||||||
|
{{#useBeanValidation}}
|
||||||
|
import org.springframework.validation.annotation.Validated
|
||||||
|
{{/useBeanValidation}}
|
||||||
|
import org.springframework.web.context.request.NativeWebRequest
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired
|
||||||
|
|
||||||
|
{{#useBeanValidation}}
|
||||||
|
import {{javaxPackage}}.validation.constraints.DecimalMax
|
||||||
|
import {{javaxPackage}}.validation.constraints.DecimalMin
|
||||||
|
import {{javaxPackage}}.validation.constraints.Email
|
||||||
|
import {{javaxPackage}}.validation.constraints.Max
|
||||||
|
import {{javaxPackage}}.validation.constraints.Min
|
||||||
|
import {{javaxPackage}}.validation.constraints.NotNull
|
||||||
|
import {{javaxPackage}}.validation.constraints.Pattern
|
||||||
|
import {{javaxPackage}}.validation.constraints.Size
|
||||||
|
import {{javaxPackage}}.validation.Valid
|
||||||
|
{{/useBeanValidation}}
|
||||||
|
|
||||||
|
{{#reactive}}
|
||||||
|
import kotlinx.coroutines.flow.Flow
|
||||||
|
{{/reactive}}
|
||||||
|
import kotlin.collections.List
|
||||||
|
import kotlin.collections.Map
|
||||||
|
import dev.usbharu.hideout.config.JsonOrFormBind
|
||||||
|
|
||||||
|
{{#useBeanValidation}}
|
||||||
|
@Validated
|
||||||
|
{{/useBeanValidation}}
|
||||||
|
{{#swagger1AnnotationLibrary}}
|
||||||
|
@Api(value = "{{{baseName}}}", description = "The {{{baseName}}} API")
|
||||||
|
{{/swagger1AnnotationLibrary}}
|
||||||
|
{{^useFeignClient}}
|
||||||
|
{{=<% %>=}}
|
||||||
|
@RequestMapping("\${api.base-path:<%contextPath%>}")
|
||||||
|
<%={{ }}=%>
|
||||||
|
{{/useFeignClient}}
|
||||||
|
{{#operations}}
|
||||||
|
interface {{classname}} {
|
||||||
|
{{#isDelegate}}
|
||||||
|
|
||||||
|
fun getDelegate(): {{classname}}Delegate = object: {{classname}}Delegate {}
|
||||||
|
{{/isDelegate}}
|
||||||
|
{{#operation}}
|
||||||
|
|
||||||
|
{{#swagger2AnnotationLibrary}}
|
||||||
|
@Operation(
|
||||||
|
summary = "{{{summary}}}",
|
||||||
|
operationId = "{{{operationId}}}",
|
||||||
|
description = """{{{unescapedNotes}}}""",
|
||||||
|
responses = [{{#responses}}
|
||||||
|
ApiResponse(responseCode = "{{{code}}}", description = "{{{message}}}"{{#baseType}}, content = [Content({{#isArray}}array = ArraySchema({{/isArray}}schema = Schema(implementation = {{{baseType}}}::class)){{#isArray}}){{/isArray}}]{{/baseType}}){{^-last}},{{/-last}}{{/responses}}
|
||||||
|
]{{#hasAuthMethods}},
|
||||||
|
security = [ {{#authMethods}}SecurityRequirement(name = "{{name}}"{{#isOAuth}}, scopes = [ {{#scopes}}"{{scope}}"{{^-last}}, {{/-last}}{{/scopes}} ]{{/isOAuth}}){{^-last}},{{/-last}}{{/authMethods}} ]{{/hasAuthMethods}}
|
||||||
|
){{/swagger2AnnotationLibrary}}{{#swagger1AnnotationLibrary}}
|
||||||
|
@ApiOperation(
|
||||||
|
value = "{{{summary}}}",
|
||||||
|
nickname = "{{{operationId}}}",
|
||||||
|
notes = "{{{notes}}}"{{#returnBaseType}},
|
||||||
|
response = {{{.}}}::class{{/returnBaseType}}{{#returnContainer}},
|
||||||
|
responseContainer = "{{{.}}}"{{/returnContainer}}{{#hasAuthMethods}},
|
||||||
|
authorizations = [{{#authMethods}}Authorization(value = "{{name}}"{{#isOAuth}}, scopes = [{{#scopes}}AuthorizationScope(scope = "{{scope}}", description = "{{description}}"){{^-last}}, {{/-last}}{{/scopes}}]{{/isOAuth}}){{^-last}}, {{/-last}}{{/authMethods}}]{{/hasAuthMethods}})
|
||||||
|
@ApiResponses(
|
||||||
|
value = [{{#responses}}ApiResponse(code = {{{code}}}, message = "{{{message}}}"{{#baseType}}, response = {{{.}}}::class{{/baseType}}{{#containerType}}, responseContainer = "{{{.}}}"{{/containerType}}){{^-last}}, {{/-last}}{{/responses}}]){{/swagger1AnnotationLibrary}}
|
||||||
|
@RequestMapping(
|
||||||
|
method = [RequestMethod.{{httpMethod}}],
|
||||||
|
value = ["{{#lambda.escapeDoubleQuote}}{{path}}{{/lambda.escapeDoubleQuote}}"]{{#singleContentTypes}}{{#hasProduces}},
|
||||||
|
produces = "{{{vendorExtensions.x-accepts}}}"{{/hasProduces}}{{#hasConsumes}},
|
||||||
|
consumes = "{{{vendorExtensions.x-content-type}}}"{{/hasConsumes}}{{/singleContentTypes}}{{^singleContentTypes}}{{#hasProduces}},
|
||||||
|
produces = [{{#produces}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/produces}}]{{/hasProduces}}{{#hasConsumes}},
|
||||||
|
consumes = [{{#consumes}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/consumes}}]{{/hasConsumes}}{{/singleContentTypes}}
|
||||||
|
)
|
||||||
|
{{#reactive}}{{^isArray}}suspend {{/isArray}}{{/reactive}}fun {{operationId}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{^-last}},{{/-last}}{{/allParams}}): ResponseEntity<{{>returnTypes}}>{{^skipDefaultInterface}} {
|
||||||
|
{{^isDelegate}}
|
||||||
|
return {{>returnValue}}
|
||||||
|
{{/isDelegate}}
|
||||||
|
{{#isDelegate}}
|
||||||
|
return getDelegate().{{operationId}}({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}})
|
||||||
|
{{/isDelegate}}
|
||||||
|
}{{/skipDefaultInterface}}
|
||||||
|
{{/operation}}
|
||||||
|
}
|
||||||
|
{{/operations}}
|
|
@ -0,0 +1,23 @@
|
||||||
|
package {{apiPackage}}
|
||||||
|
|
||||||
|
{{^reactive}}
|
||||||
|
import org.springframework.web.context.request.NativeWebRequest
|
||||||
|
|
||||||
|
import {{javaxPackage}}.servlet.http.HttpServletResponse
|
||||||
|
import java.io.IOException
|
||||||
|
{{/reactive}}
|
||||||
|
|
||||||
|
object ApiUtil {
|
||||||
|
{{^reactive}}
|
||||||
|
fun setExampleResponse(req: NativeWebRequest, contentType: String, example: String) {
|
||||||
|
try {
|
||||||
|
val res = req.getNativeResponse(HttpServletResponse::class.java)
|
||||||
|
res?.characterEncoding = "UTF-8"
|
||||||
|
res?.addHeader("Content-Type", contentType)
|
||||||
|
res?.writer?.print(example)
|
||||||
|
} catch (e: IOException) {
|
||||||
|
throw RuntimeException(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{{/reactive}}
|
||||||
|
}
|
|
@ -0,0 +1,38 @@
|
||||||
|
package {{package}}
|
||||||
|
|
||||||
|
{{#imports}}import {{import}}
|
||||||
|
{{/imports}}
|
||||||
|
import org.junit.jupiter.api.Test
|
||||||
|
{{#reactive}}
|
||||||
|
import kotlinx.coroutines.flow.Flow
|
||||||
|
import kotlinx.coroutines.test.runBlockingTest
|
||||||
|
{{/reactive}}
|
||||||
|
import org.springframework.http.ResponseEntity
|
||||||
|
|
||||||
|
class {{classname}}Test {
|
||||||
|
|
||||||
|
{{#serviceInterface}}
|
||||||
|
private val service: {{classname}}Service = {{classname}}ServiceImpl()
|
||||||
|
{{/serviceInterface}}
|
||||||
|
private val api: {{classname}}Controller = {{classname}}Controller({{#serviceInterface}}service{{/serviceInterface}})
|
||||||
|
{{#operations}}
|
||||||
|
{{#operation}}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To test {{classname}}Controller.{{operationId}}
|
||||||
|
*
|
||||||
|
* @throws ApiException
|
||||||
|
* if the Api call fails
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
fun {{operationId}}Test() {{#reactive}}= runBlockingTest {{/reactive}}{
|
||||||
|
{{#allParams}}
|
||||||
|
val {{{paramName}}}: {{>optionalDataType}} = TODO()
|
||||||
|
{{/allParams}}
|
||||||
|
val response: ResponseEntity<{{>returnTypes}}> = api.{{operationId}}({{#allParams}}{{{paramName}}}{{^-last}}, {{/-last}}{{/allParams}})
|
||||||
|
|
||||||
|
// TODO: test validations
|
||||||
|
}
|
||||||
|
{{/operation}}
|
||||||
|
{{/operations}}
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
{{#isContainer}}{{^isPrimitiveType}}{{^isEnum}}
|
||||||
|
@field:Valid{{/isEnum}}{{/isPrimitiveType}}{{/isContainer}}{{!
|
||||||
|
}}{{^isContainer}}{{^isPrimitiveType}}{{^isNumber}}{{^isUuid}}{{^isDateTime}}
|
||||||
|
@field:Valid{{/isDateTime}}{{/isUuid}}{{/isNumber}}{{/isPrimitiveType}}{{/isContainer}}
|
|
@ -0,0 +1,38 @@
|
||||||
|
{{!
|
||||||
|
format: email
|
||||||
|
}}{{#isEmail}}
|
||||||
|
@get:Email{{/isEmail}}{{!
|
||||||
|
pattern set
|
||||||
|
}}{{#pattern}}
|
||||||
|
@get:Pattern(regexp="{{{.}}}"){{/pattern}}{{!
|
||||||
|
minLength && maxLength set
|
||||||
|
}}{{#minLength}}{{#maxLength}}
|
||||||
|
@get:Size(min={{minLength}},max={{maxLength}}){{/maxLength}}{{/minLength}}{{!
|
||||||
|
minLength set, maxLength not
|
||||||
|
}}{{#minLength}}{{^maxLength}}
|
||||||
|
@get:Size(min={{minLength}}){{/maxLength}}{{/minLength}}{{!
|
||||||
|
minLength not set, maxLength set
|
||||||
|
}}{{^minLength}}{{#maxLength}}
|
||||||
|
@get:Size(max={{.}}){{/maxLength}}{{/minLength}}{{!
|
||||||
|
@Size: minItems && maxItems set
|
||||||
|
}}{{#minItems}}{{#maxItems}}
|
||||||
|
@get:Size(min={{minItems}},max={{maxItems}}) {{/maxItems}}{{/minItems}}{{!
|
||||||
|
@Size: minItems set, maxItems not
|
||||||
|
}}{{#minItems}}{{^maxItems}}
|
||||||
|
@get:Size(min={{minItems}}){{/maxItems}}{{/minItems}}{{!
|
||||||
|
@Size: minItems not set && maxItems set
|
||||||
|
}}{{^minItems}}{{#maxItems}}
|
||||||
|
@get:Size(max={{.}}){{/maxItems}}{{/minItems}}{{!
|
||||||
|
check for integer or long / all others=decimal type with @Decimal*
|
||||||
|
isInteger set
|
||||||
|
}}{{#isInteger}}{{#minimum}}
|
||||||
|
@get:Min({{.}}){{/minimum}}{{#maximum}}
|
||||||
|
@get:Max({{.}}){{/maximum}}{{/isInteger}}{{!
|
||||||
|
isLong set
|
||||||
|
}}{{#isLong}}{{#minimum}}
|
||||||
|
@get:Min({{.}}L){{/minimum}}{{#maximum}}
|
||||||
|
@get:Max({{.}}L){{/maximum}}{{/isLong}}{{!
|
||||||
|
Not Integer, not Long => we have a decimal value!
|
||||||
|
}}{{^isInteger}}{{^isLong}}{{#minimum}}
|
||||||
|
@get:DecimalMin("{{.}}"){{/minimum}}{{#maximum}}
|
||||||
|
@get:DecimalMax("{{.}}"){{/maximum}}{{/isLong}}{{/isInteger}}
|
|
@ -0,0 +1,22 @@
|
||||||
|
{{#isEmail}}@Email {{/isEmail}}{{!
|
||||||
|
pattern set
|
||||||
|
}}{{#pattern}}@Pattern(regexp="{{{.}}}") {{/pattern}}{{!
|
||||||
|
minLength && maxLength set
|
||||||
|
}}{{#minLength}}{{#maxLength}}@Size(min={{minLength}},max={{maxLength}}) {{/maxLength}}{{/minLength}}{{!
|
||||||
|
minLength set, maxLength not
|
||||||
|
}}{{#minLength}}{{^maxLength}}@Size(min={{minLength}}) {{/maxLength}}{{/minLength}}{{!
|
||||||
|
minLength not set, maxLength set
|
||||||
|
}}{{^minLength}}{{#maxLength}}@Size(max={{.}}) {{/maxLength}}{{/minLength}}{{!
|
||||||
|
@Size: minItems && maxItems set
|
||||||
|
}}{{#minItems}}{{#maxItems}}@Size(min={{minItems}},max={{maxItems}}) {{/maxItems}}{{/minItems}}{{!
|
||||||
|
@Size: minItems set, maxItems not
|
||||||
|
}}{{#minItems}}{{^maxItems}}@Size(min={{minItems}}) {{/maxItems}}{{/minItems}}{{!
|
||||||
|
@Size: minItems not set && maxItems set
|
||||||
|
}}{{^minItems}}{{#maxItems}}@Size(max={{.}}) {{/maxItems}}{{/minItems}}{{!
|
||||||
|
check for integer or long / all others=decimal type with @Decimal*
|
||||||
|
isInteger set
|
||||||
|
}}{{#isInteger}}{{#minimum}}@Min({{.}}){{/minimum}}{{#maximum}} @Max({{.}}) {{/maximum}}{{/isInteger}}{{!
|
||||||
|
isLong set
|
||||||
|
}}{{#isLong}}{{#minimum}}@Min({{.}}L){{/minimum}}{{#maximum}} @Max({{.}}L) {{/maximum}}{{/isLong}}{{!
|
||||||
|
Not Integer, not Long => we have a decimal value!
|
||||||
|
}}{{^isInteger}}{{^isLong}}{{#minimum}}@DecimalMin("{{.}}"){{/minimum}}{{#maximum}} @DecimalMax("{{.}}") {{/maximum}}{{/isLong}}{{/isInteger}}
|
|
@ -0,0 +1 @@
|
||||||
|
{{! PathParam is always required, no @NotNull necessary }}{{>beanValidationPath}}
|
|
@ -0,0 +1 @@
|
||||||
|
{{#required}}@NotNull {{/required}}{{>beanValidationPath}}
|
|
@ -0,0 +1 @@
|
||||||
|
{{#isBodyParam}}{{#swagger2AnnotationLibrary}}@Parameter(description = "{{{description}}}"{{#required}}, required = true{{/required}}{{^isContainer}}{{#allowableValues}}{{#defaultValue}}, schema = Schema(allowableValues = ["{{{allowableValues}}}"], defaultValue = {{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{{defaultValue}}}{{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}){{/defaultValue}}{{/allowableValues}}{{^allowableValues}}{{#defaultValue}}, schema = Schema(defaultValue = {{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{{defaultValue}}}{{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}){{/defaultValue}}{{/allowableValues}}{{#allowableValues}}{{^defaultValue}}, schema = Schema(allowableValues = ["{{{allowableValues}}}"]){{/defaultValue}}{{/allowableValues}}{{/isContainer}}){{/swagger2AnnotationLibrary}}{{#swagger1AnnotationLibrary}}@ApiParam(value = "{{{description}}}"{{#required}}, required = true{{/required}}{{^isContainer}}{{#allowableValues}}, allowableValues = "{{{.}}}"{{/allowableValues}}{{/isContainer}}{{#defaultValue}}, defaultValue = "{{{.}}}"{{/defaultValue}}){{/swagger1AnnotationLibrary}} {{#useBeanValidation}}@Valid{{/useBeanValidation}} @JsonOrForm {{{paramName}}}: {{^reactive}}{{>optionalDataType}}{{/reactive}}{{#reactive}}{{^isArray}}{{>optionalDataType}}{{/isArray}}{{#isArray}}Flow<{{{baseType}}}>{{/isArray}}{{/reactive}}{{/isBodyParam}}
|
|
@ -0,0 +1,33 @@
|
||||||
|
/**
|
||||||
|
* {{{description}}}
|
||||||
|
{{#vars}}
|
||||||
|
* @param {{name}} {{{description}}}
|
||||||
|
{{/vars}}
|
||||||
|
*/{{#discriminator}}
|
||||||
|
{{>typeInfoAnnotation}}{{/discriminator}}
|
||||||
|
{{#discriminator}}interface {{classname}}{{/discriminator}}{{^discriminator}}{{#hasVars}}data {{/hasVars}}class {{classname}}(
|
||||||
|
{{#requiredVars}}
|
||||||
|
{{>dataClassReqVar}}{{^-last}},
|
||||||
|
{{/-last}}{{/requiredVars}}{{#hasRequired}}{{#hasOptional}},
|
||||||
|
{{/hasOptional}}{{/hasRequired}}{{#optionalVars}}{{>dataClassOptVar}}{{^-last}},
|
||||||
|
{{/-last}}{{/optionalVars}}
|
||||||
|
) {{/discriminator}}{{#parent}}: {{{.}}}{{/parent}}{
|
||||||
|
{{#discriminator}}
|
||||||
|
{{#requiredVars}}
|
||||||
|
{{>interfaceReqVar}}
|
||||||
|
{{/requiredVars}}
|
||||||
|
{{#optionalVars}}
|
||||||
|
{{>interfaceOptVar}}
|
||||||
|
{{/optionalVars}}
|
||||||
|
{{/discriminator}}
|
||||||
|
{{#hasEnums}}{{#vars}}{{#isEnum}}
|
||||||
|
/**
|
||||||
|
* {{{description}}}
|
||||||
|
* Values: {{#allowableValues}}{{#enumVars}}{{&name}}{{^-last}},{{/-last}}{{/enumVars}}{{/allowableValues}}
|
||||||
|
*/
|
||||||
|
enum class {{{nameInCamelCase}}}(val value: {{#isContainer}}{{#items}}{{{dataType}}}{{/items}}{{/isContainer}}{{^isContainer}}{{{dataType}}}{{/isContainer}}) {
|
||||||
|
{{#allowableValues}}{{#enumVars}}
|
||||||
|
@JsonProperty({{{value}}}) {{{name}}}({{{value}}}){{^-last}},{{/-last}}{{/enumVars}}{{/allowableValues}}
|
||||||
|
}
|
||||||
|
{{/isEnum}}{{/vars}}{{/hasEnums}}
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
{{#useBeanValidation}}{{>beanValidation}}{{>beanValidationModel}}{{/useBeanValidation}}{{#swagger2AnnotationLibrary}}
|
||||||
|
@Schema({{#example}}example = "{{#lambdaRemoveLineBreak}}{{#lambdaEscapeDoubleQuote}}{{{.}}}{{/lambdaEscapeDoubleQuote}}{{/lambdaRemoveLineBreak}}", {{/example}}{{#isReadOnly}}readOnly = {{{isReadOnly}}}, {{/isReadOnly}}description = "{{{description}}}"){{/swagger2AnnotationLibrary}}{{#swagger1AnnotationLibrary}}
|
||||||
|
@ApiModelProperty({{#example}}example = "{{#lambdaRemoveLineBreak}}{{#lambdaEscapeDoubleQuote}}{{{.}}}{{/lambdaEscapeDoubleQuote}}{{/lambdaRemoveLineBreak}}", {{/example}}{{#isReadOnly}}readOnly = {{{isReadOnly}}}, {{/isReadOnly}}value = "{{{description}}}"){{/swagger1AnnotationLibrary}}{{#deprecated}}
|
||||||
|
@Deprecated(message = ""){{/deprecated}}
|
||||||
|
@get:JsonProperty("{{{baseName}}}"){{#isInherited}} override{{/isInherited}} {{>modelMutable}} {{{name}}}: {{#isEnum}}{{#isArray}}{{baseType}}<{{/isArray}}{{classname}}.{{{nameInCamelCase}}}{{#isArray}}>{{/isArray}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}? = {{{defaultValue}}}{{^defaultValue}}null{{/defaultValue}}
|
|
@ -0,0 +1,4 @@
|
||||||
|
{{#useBeanValidation}}{{>beanValidation}}{{>beanValidationModel}}{{/useBeanValidation}}{{#swagger2AnnotationLibrary}}
|
||||||
|
@Schema({{#example}}example = "{{#lambdaRemoveLineBreak}}{{#lambdaEscapeDoubleQuote}}{{{.}}}{{/lambdaEscapeDoubleQuote}}{{/lambdaRemoveLineBreak}}", {{/example}}required = true, {{#isReadOnly}}readOnly = {{{isReadOnly}}}, {{/isReadOnly}}description = "{{{description}}}"){{/swagger2AnnotationLibrary}}{{#swagger1AnnotationLibrary}}
|
||||||
|
@ApiModelProperty({{#example}}example = "{{#lambdaRemoveLineBreak}}{{#lambdaEscapeDoubleQuote}}{{{.}}}{{/lambdaEscapeDoubleQuote}}{{/lambdaRemoveLineBreak}}", {{/example}}required = true, {{#isReadOnly}}readOnly = {{{isReadOnly}}}, {{/isReadOnly}}value = "{{{description}}}"){{/swagger1AnnotationLibrary}}
|
||||||
|
@get:JsonProperty("{{{baseName}}}", required = true){{#isInherited}} override{{/isInherited}} {{>modelMutable}} {{{name}}}: {{#isEnum}}{{#isArray}}{{baseType}}<{{/isArray}}{{classname}}.{{{nameInCamelCase}}}{{#isArray}}>{{/isArray}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}{{#isNullable}}?{{/isNullable}}{{#defaultValue}} = {{{.}}}{{/defaultValue}}
|
|
@ -0,0 +1,8 @@
|
||||||
|
/**
|
||||||
|
* {{{description}}}
|
||||||
|
* Values: {{#allowableValues}}{{#enumVars}}{{&name}}{{^-last}},{{/-last}}{{/enumVars}}{{/allowableValues}}
|
||||||
|
*/
|
||||||
|
enum class {{classname}}(val value: {{dataType}}) {
|
||||||
|
{{#allowableValues}}{{#enumVars}}
|
||||||
|
@JsonProperty({{{value}}}) {{&name}}({{{value}}}){{^-last}},{{/-last}}{{/enumVars}}{{/allowableValues}}
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
package {{apiPackage}}
|
||||||
|
|
||||||
|
import org.springframework.http.HttpStatus
|
||||||
|
import org.springframework.web.bind.annotation.ControllerAdvice
|
||||||
|
import org.springframework.web.bind.annotation.ExceptionHandler
|
||||||
|
import {{javaxPackage}}.servlet.http.HttpServletResponse
|
||||||
|
import {{javaxPackage}}.validation.ConstraintViolationException
|
||||||
|
|
||||||
|
// TODO Extend ApiException for custom exception handling, e.g. the below NotFound exception
|
||||||
|
sealed class ApiException(msg: String, val code: Int) : Exception(msg)
|
||||||
|
|
||||||
|
class NotFoundException(msg: String, code: Int = HttpStatus.NOT_FOUND.value()) : ApiException(msg, code)
|
||||||
|
|
||||||
|
|
||||||
|
@ControllerAdvice
|
||||||
|
class DefaultExceptionHandler {
|
||||||
|
|
||||||
|
@ExceptionHandler(value = [ApiException::class])
|
||||||
|
fun onApiException(ex: ApiException, response: HttpServletResponse): Unit =
|
||||||
|
response.sendError(ex.code, ex.message)
|
||||||
|
|
||||||
|
@ExceptionHandler(value = [NotImplementedError::class])
|
||||||
|
fun onNotImplemented(ex: NotImplementedError, response: HttpServletResponse): Unit =
|
||||||
|
response.sendError(HttpStatus.NOT_IMPLEMENTED.value())
|
||||||
|
|
||||||
|
@ExceptionHandler(value = [ConstraintViolationException::class])
|
||||||
|
fun onConstraintViolation(ex: ConstraintViolationException, response: HttpServletResponse): Unit =
|
||||||
|
response.sendError(HttpStatus.BAD_REQUEST.value(), ex.constraintViolations.joinToString(", ") { it.message })
|
||||||
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
{{#isFormParam}}{{^isFile}}{{#swagger2AnnotationLibrary}}@Parameter(description = "{{{description}}}"{{#required}}, required = true{{/required}}{{#allowableValues}}{{#defaultValue}}, schema = Schema(allowableValues = [{{#values}}"{{{.}}}"{{^-last}}, {{/-last}}{{/values}}]{{^isContainer}}, defaultValue = {{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{{defaultValue}}}{{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{/isContainer}}){{/defaultValue}}{{/allowableValues}}{{#allowableValues}}{{^defaultValue}}, schema = Schema(allowableValues = [{{#values}}"{{{.}}}"{{^-last}}, {{/-last}}{{/values}}]){{/defaultValue}}{{/allowableValues}}{{^allowableValues}}{{#defaultValue}}{{^isContainer}}, schema = Schema(defaultValue = {{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{{defaultValue}}}{{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}){{/isContainer}}{{/defaultValue}}{{/allowableValues}}){{/swagger2AnnotationLibrary}}{{#swagger1AnnotationLibrary}}@ApiParam(value = "{{{description}}}"{{#required}}, required = true{{/required}}{{#allowableValues}}, allowableValues = "{{#values}}{{{.}}}{{^-last}}, {{/-last}}{{/values}}"{{/allowableValues}}{{#defaultValue}}, defaultValue = "{{{.}}}"{{/defaultValue}}){{/swagger1AnnotationLibrary}} @RequestParam(value = "{{baseName}}"{{#required}}, required = true{{/required}}{{^required}}, required = false{{/required}}) {{paramName}}: {{>optionalDataType}} {{/isFile}}{{#isFile}}{{#swagger2AnnotationLibrary}}@Parameter(description = "file detail"){{/swagger2AnnotationLibrary}}{{#swagger1AnnotationLibrary}}@ApiParam(value = "file detail"){{/swagger1AnnotationLibrary}} {{#useBeanValidation}}@Valid{{/useBeanValidation}} @RequestPart("file") {{baseName}}: {{>optionalDataType}}{{/isFile}}{{/isFormParam}}
|
|
@ -0,0 +1 @@
|
||||||
|
@{{javaxPackage}}.annotation.Generated(value = ["{{generatorClass}}"]{{^hideGenerationTimestamp}}, date = "{{generatedDate}}"{{/hideGenerationTimestamp}})
|
|
@ -0,0 +1 @@
|
||||||
|
{{#isHeaderParam}}{{#useBeanValidation}}{{>beanValidationPath}}{{/useBeanValidation}}{{#swagger2AnnotationLibrary}}@Parameter(description = "{{{description}}}", `in` = ParameterIn.HEADER{{#required}}, required = true{{/required}}{{#allowableValues}}{{#defaultValue}}, schema = Schema(allowableValues = [{{#values}}"{{{.}}}"{{^-last}}, {{/-last}}{{/values}}]{{^isContainer}}, defaultValue = {{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{{defaultValue}}}{{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{/isContainer}}){{/defaultValue}}{{/allowableValues}}{{#allowableValues}}{{^defaultValue}}, schema = Schema(allowableValues = [{{#values}}"{{{.}}}"{{^-last}}, {{/-last}}{{/values}}]){{/defaultValue}}{{/allowableValues}}{{^allowableValues}}{{#defaultValue}}{{^isContainer}}, schema = Schema(defaultValue = {{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{{defaultValue}}}{{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}){{/isContainer}}{{/defaultValue}}{{/allowableValues}}){{/swagger2AnnotationLibrary}}{{#swagger1AnnotationLibrary}}@ApiParam(value = "{{{description}}}"{{#required}}, required = true{{/required}}{{#allowableValues}}, allowableValues = "{{#values}}{{{.}}}{{^-last}}, {{/-last}}{{/values}}"{{/allowableValues}}{{#defaultValue}}, defaultValue = "{{{.}}}"{{/defaultValue}}){{/swagger1AnnotationLibrary}} @RequestHeader(value = "{{baseName}}", required = {{#required}}true{{/required}}{{^required}}false{{/required}}) {{paramName}}: {{>optionalDataType}}{{/isHeaderParam}}
|
|
@ -0,0 +1,91 @@
|
||||||
|
package {{basePackage}}
|
||||||
|
|
||||||
|
import org.springframework.context.annotation.Bean
|
||||||
|
import org.springframework.stereotype.Controller
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping
|
||||||
|
{{#sourceDocumentationProvider}}
|
||||||
|
import com.fasterxml.jackson.dataformat.yaml.YAMLMapper
|
||||||
|
import org.springframework.beans.factory.annotation.Value
|
||||||
|
import org.springframework.core.io.Resource
|
||||||
|
import org.springframework.util.StreamUtils
|
||||||
|
import org.springframework.web.bind.annotation.ResponseBody
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping
|
||||||
|
{{/sourceDocumentationProvider}}
|
||||||
|
{{^sourceDocumentationProvider}}
|
||||||
|
{{#useSwaggerUI}}
|
||||||
|
import org.springframework.web.bind.annotation.ResponseBody
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping
|
||||||
|
{{/useSwaggerUI}}
|
||||||
|
{{/sourceDocumentationProvider}}
|
||||||
|
{{#reactive}}
|
||||||
|
import org.springframework.web.reactive.function.server.HandlerFunction
|
||||||
|
import org.springframework.web.reactive.function.server.RequestPredicates.GET
|
||||||
|
import org.springframework.web.reactive.function.server.RouterFunction
|
||||||
|
import org.springframework.web.reactive.function.server.RouterFunctions.route
|
||||||
|
import org.springframework.web.reactive.function.server.ServerResponse
|
||||||
|
import java.net.URI
|
||||||
|
{{/reactive}}
|
||||||
|
{{#sourceDocumentationProvider}}
|
||||||
|
import java.nio.charset.Charset
|
||||||
|
{{/sourceDocumentationProvider}}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Home redirection to OpenAPI api documentation
|
||||||
|
*/
|
||||||
|
@Controller
|
||||||
|
class HomeController {
|
||||||
|
{{#useSwaggerUI}}
|
||||||
|
{{^springDocDocumentationProvider}}
|
||||||
|
{{#sourceDocumentationProvider}}
|
||||||
|
private val apiDocsPath = "/openapi.json"
|
||||||
|
{{/sourceDocumentationProvider}}
|
||||||
|
{{#springFoxDocumentationProvider}}
|
||||||
|
private val apiDocsPath = "/v2/api-docs"
|
||||||
|
{{/springFoxDocumentationProvider}}
|
||||||
|
{{/springDocDocumentationProvider}}
|
||||||
|
{{/useSwaggerUI}}
|
||||||
|
{{#sourceDocumentationProvider}}
|
||||||
|
private val yamlMapper = YAMLMapper()
|
||||||
|
|
||||||
|
@Value("classpath:/openapi.yaml")
|
||||||
|
private lateinit var openapi: Resource
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
fun openapiContent(): String {
|
||||||
|
return openapi.inputStream.use {
|
||||||
|
StreamUtils.copyToString(it, Charset.defaultCharset())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping(value = ["/openapi.yaml"], produces = ["application/vnd.oai.openapi"])
|
||||||
|
@ResponseBody
|
||||||
|
fun openapiYaml(): String = openapiContent()
|
||||||
|
|
||||||
|
@GetMapping(value = ["/openapi.json"], produces = ["application/json"])
|
||||||
|
@ResponseBody
|
||||||
|
fun openapiJson(): Any = yamlMapper.readValue(openapiContent(), Any::class.java)
|
||||||
|
{{/sourceDocumentationProvider}}
|
||||||
|
{{#useSwaggerUI}}
|
||||||
|
{{^springDocDocumentationProvider}}
|
||||||
|
|
||||||
|
@GetMapping(value = ["/swagger-config.yaml"], produces = ["text/plain"])
|
||||||
|
@ResponseBody
|
||||||
|
fun swaggerConfig(): String = "url: $apiDocsPath\n"
|
||||||
|
{{/springDocDocumentationProvider}}
|
||||||
|
{{#reactive}}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
fun index(): RouterFunction
|
||||||
|
<ServerResponse> = route(
|
||||||
|
GET("/"), HandlerFunction
|
||||||
|
<ServerResponse> {
|
||||||
|
ServerResponse.temporaryRedirect(URI.create("swagger-ui.html")).build()
|
||||||
|
})
|
||||||
|
{{/reactive}}
|
||||||
|
{{^reactive}}
|
||||||
|
|
||||||
|
@RequestMapping("/")
|
||||||
|
fun index(): String = "redirect:swagger-ui.html"
|
||||||
|
{{/reactive}}
|
||||||
|
{{/useSwaggerUI}}
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
{{#swagger2AnnotationLibrary}}
|
||||||
|
@get:Schema({{#example}}example = "{{{.}}}", {{/example}}{{#required}}requiredMode = Schema.RequiredMode.REQUIRED, {{/required}}{{#isReadOnly}}readOnly = {{{isReadOnly}}}, {{/isReadOnly}}description = "{{{description}}}"){{/swagger2AnnotationLibrary}}{{#swagger1AnnotationLibrary}}
|
||||||
|
@get:ApiModelProperty({{#example}}example = "{{{.}}}", {{/example}}{{#required}}required = {{required}}, {{/required}}{{#isReadOnly}}readOnly = {{{isReadOnly}}}, {{/isReadOnly}}value = "{{{description}}}"){{/swagger1AnnotationLibrary}}
|
||||||
|
{{>modelMutable}} {{{name}}}: {{#isEnum}}{{classname}}.{{nameInCamelCase}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}? {{^discriminator}}= {{{defaultValue}}}{{^defaultValue}}null{{/defaultValue}}{{/discriminator}}
|
|
@ -0,0 +1,4 @@
|
||||||
|
{{#swagger2AnnotationLibrary}}
|
||||||
|
@get:Schema({{#example}}example = "{{{.}}}", {{/example}}{{#required}}requiredMode = Schema.RequiredMode.REQUIRED, {{/required}}{{#isReadOnly}}readOnly = {{{isReadOnly}}}, {{/isReadOnly}}description = "{{{description}}}"){{/swagger2AnnotationLibrary}}{{#swagger1AnnotationLibrary}}
|
||||||
|
@get:ApiModelProperty({{#example}}example = "{{{.}}}", {{/example}}{{#required}}required = {{required}}, {{/required}}{{#isReadOnly}}readOnly = {{{isReadOnly}}}, {{/isReadOnly}}value = "{{{description}}}"){{/swagger1AnnotationLibrary}}
|
||||||
|
{{>modelMutable}} {{{name}}}: {{#isEnum}}{{classname}}.{{nameInCamelCase}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}
|
|
@ -0,0 +1,21 @@
|
||||||
|
# {{title}}{{^title}}Generated Kotlin Spring Boot App{{/title}}
|
||||||
|
|
||||||
|
This Kotlin based [Spring Boot](https://spring.io/projects/spring-boot) application has been generated using the [OpenAPI Generator](https://github.com/OpenAPITools/openapi-generator).
|
||||||
|
|
||||||
|
## Getting Started
|
||||||
|
|
||||||
|
This document assumes you have either maven or gradle available, either via the wrapper or otherwise. This does not come with a gradle / maven wrapper checked in.
|
||||||
|
|
||||||
|
By default a [`pom.xml`](pom.xml) file will be generated. If you specified `gradleBuildFile=true` when generating this project, a `build.gradle.kts` will also be generated. Note this uses [Gradle Kotlin DSL](https://github.com/gradle/kotlin-dsl).
|
||||||
|
|
||||||
|
To build the project using maven, run:
|
||||||
|
```bash
|
||||||
|
mvn package && java -jar target/{{artifactId}}-{{artifactVersion}}.jar
|
||||||
|
```
|
||||||
|
|
||||||
|
To build the project using gradle, run:
|
||||||
|
```bash
|
||||||
|
gradle build && java -jar build/libs/{{artifactId}}-{{artifactVersion}}.jar
|
||||||
|
```
|
||||||
|
|
||||||
|
If all builds successfully, the server should run on [http://localhost:8080/](http://localhost:{{serverPort}}/)
|
|
@ -0,0 +1,10 @@
|
||||||
|
spring:
|
||||||
|
application:
|
||||||
|
name: {{title}}
|
||||||
|
|
||||||
|
jackson:
|
||||||
|
serialization:
|
||||||
|
WRITE_DATES_AS_TIMESTAMPS: false
|
||||||
|
|
||||||
|
server:
|
||||||
|
port: {{serverPort}}
|
|
@ -0,0 +1,61 @@
|
||||||
|
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||||
|
|
||||||
|
group = "{{groupId}}"
|
||||||
|
version = "{{artifactVersion}}"
|
||||||
|
java.sourceCompatibility = JavaVersion.VERSION_17
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
maven { url = uri("https://repo.spring.io/milestone") }
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.withType
|
||||||
|
<KotlinCompile> {
|
||||||
|
kotlinOptions.jvmTarget = "17"
|
||||||
|
}
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
val kotlinVersion = "1.7.10"
|
||||||
|
id("org.jetbrains.kotlin.jvm") version kotlinVersion
|
||||||
|
id("org.jetbrains.kotlin.plugin.jpa") version kotlinVersion
|
||||||
|
id("org.jetbrains.kotlin.plugin.spring") version kotlinVersion
|
||||||
|
id("org.springframework.boot") version "3.0.2"
|
||||||
|
id("io.spring.dependency-management") version "1.0.14.RELEASE"
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
{{#reactive}} val kotlinxCoroutinesVersion = "1.6.1"
|
||||||
|
{{/reactive}} implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
|
||||||
|
implementation("org.jetbrains.kotlin:kotlin-reflect"){{^reactive}}
|
||||||
|
implementation("org.springframework.boot:spring-boot-starter-web"){{/reactive}}{{#reactive}}
|
||||||
|
implementation("org.springframework.boot:spring-boot-starter-webflux")
|
||||||
|
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlinxCoroutinesVersion")
|
||||||
|
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-reactor:$kotlinxCoroutinesVersion"){{/reactive}}{{#springDocDocumentationProvider}}{{#useSwaggerUI}}
|
||||||
|
implementation("org.springdoc:springdoc-openapi-starter-{{#reactive}}
|
||||||
|
webflux{{/reactive}}{{^reactive}}webmvc{{/reactive}}-ui:2.0.0-M5"){{/useSwaggerUI}}{{^useSwaggerUI}}
|
||||||
|
implementation("org.springdoc:springdoc-openapi-{{#reactive}}
|
||||||
|
webflux{{/reactive}}{{^reactive}}webmvc{{/reactive}}
|
||||||
|
-core:2.0.0-M5"){{/useSwaggerUI}}{{/springDocDocumentationProvider}}{{#springFoxDocumentationProvider}}
|
||||||
|
implementation("io.springfox:springfox-swagger2:2.9.2"){{/springFoxDocumentationProvider}}{{#useSwaggerUI}}{{^springDocDocumentationProvider}}
|
||||||
|
implementation("org.webjars:swagger-ui:4.10.3")
|
||||||
|
implementation("org.webjars:webjars-locator-core"){{/springDocDocumentationProvider}}{{/useSwaggerUI}}{{^springFoxDocumentationProvider}}{{^springDocDocumentationProvider}}{{#swagger1AnnotationLibrary}}
|
||||||
|
implementation("io.swagger:swagger-annotations:1.6.6"){{/swagger1AnnotationLibrary}}{{#swagger2AnnotationLibrary}}
|
||||||
|
implementation("io.swagger.core.v3:swagger-annotations:2.2.0"){{/swagger2AnnotationLibrary}}{{/springDocDocumentationProvider}}{{/springFoxDocumentationProvider}}
|
||||||
|
|
||||||
|
implementation("com.google.code.findbugs:jsr305:3.0.2")
|
||||||
|
implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml")
|
||||||
|
implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-xml")
|
||||||
|
implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310")
|
||||||
|
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
|
||||||
|
{{#useBeanValidation}}
|
||||||
|
implementation("jakarta.validation:jakarta.validation-api"){{/useBeanValidation}}
|
||||||
|
implementation("jakarta.annotation:jakarta.annotation-api:2.1.0")
|
||||||
|
|
||||||
|
testImplementation("org.jetbrains.kotlin:kotlin-test-junit5")
|
||||||
|
testImplementation("org.springframework.boot:spring-boot-starter-test") {
|
||||||
|
exclude(module = "junit")
|
||||||
|
}
|
||||||
|
{{#reactive}}
|
||||||
|
testImplementation`("org.jetbrains.kotlinx:kotlinx-coroutines-test:$kotlinxCoroutinesVersion")
|
||||||
|
{{/reactive}}
|
||||||
|
}
|
|
@ -0,0 +1,68 @@
|
||||||
|
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||||
|
|
||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
dependencies {
|
||||||
|
classpath("org.springframework.boot:spring-boot-gradle-plugin:2.6.7")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
group = "{{groupId}}"
|
||||||
|
version = "{{artifactVersion}}"
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.withType
|
||||||
|
<KotlinCompile> {
|
||||||
|
kotlinOptions.jvmTarget = "1.8"
|
||||||
|
}
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
val kotlinVersion = "1.6.21"
|
||||||
|
id("org.jetbrains.kotlin.jvm") version kotlinVersion
|
||||||
|
id("org.jetbrains.kotlin.plugin.jpa") version kotlinVersion
|
||||||
|
id("org.jetbrains.kotlin.plugin.spring") version kotlinVersion
|
||||||
|
id("org.springframework.boot") version "2.6.7"
|
||||||
|
id("io.spring.dependency-management") version "1.0.11.RELEASE"
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
{{#reactive}} val kotlinxCoroutinesVersion = "1.6.1"
|
||||||
|
{{/reactive}} compile("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
|
||||||
|
compile("org.jetbrains.kotlin:kotlin-reflect"){{^reactive}}
|
||||||
|
compile("org.springframework.boot:spring-boot-starter-web"){{/reactive}}{{#reactive}}
|
||||||
|
compile("org.springframework.boot:spring-boot-starter-webflux")
|
||||||
|
compile("org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlinxCoroutinesVersion")
|
||||||
|
compile("org.jetbrains.kotlinx:kotlinx-coroutines-reactor:$kotlinxCoroutinesVersion"){{/reactive}}{{#springDocDocumentationProvider}}{{#useSwaggerUI}}
|
||||||
|
compile("org.springdoc:springdoc-openapi-{{#reactive}}
|
||||||
|
webflux-{{/reactive}}ui:1.6.8"){{/useSwaggerUI}}{{^useSwaggerUI}}
|
||||||
|
compile("org.springdoc:springdoc-openapi-{{#reactive}}
|
||||||
|
webflux{{/reactive}}{{^reactive}}webmvc{{/reactive}}
|
||||||
|
-core:1.6.8"){{/useSwaggerUI}}{{/springDocDocumentationProvider}}{{#springFoxDocumentationProvider}}
|
||||||
|
compile("io.springfox:springfox-swagger2:2.9.2"){{/springFoxDocumentationProvider}}{{#useSwaggerUI}}{{^springDocDocumentationProvider}}
|
||||||
|
compile("org.webjars:swagger-ui:4.10.3")
|
||||||
|
compile("org.webjars:webjars-locator-core"){{/springDocDocumentationProvider}}{{/useSwaggerUI}}{{^springFoxDocumentationProvider}}{{^springDocDocumentationProvider}}{{#swagger1AnnotationLibrary}}
|
||||||
|
compile("io.swagger:swagger-annotations:1.6.6"){{/swagger1AnnotationLibrary}}{{#swagger2AnnotationLibrary}}
|
||||||
|
compile("io.swagger.core.v3:swagger-annotations:2.2.0"){{/swagger2AnnotationLibrary}}{{/springDocDocumentationProvider}}{{/springFoxDocumentationProvider}}
|
||||||
|
|
||||||
|
compile("com.google.code.findbugs:jsr305:3.0.2")
|
||||||
|
compile("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml")
|
||||||
|
compile("com.fasterxml.jackson.dataformat:jackson-dataformat-xml")
|
||||||
|
compile("com.fasterxml.jackson.datatype:jackson-datatype-jsr310")
|
||||||
|
compile("com.fasterxml.jackson.module:jackson-module-kotlin")
|
||||||
|
{{#useBeanValidation}}
|
||||||
|
compile("jakarta.validation:jakarta.validation-api"){{/useBeanValidation}}
|
||||||
|
compile("jakarta.annotation:jakarta.annotation-api:2.1.0")
|
||||||
|
|
||||||
|
testCompile("org.jetbrains.kotlin:kotlin-test-junit5")
|
||||||
|
testCompile("org.springframework.boot:spring-boot-starter-test") {
|
||||||
|
exclude(module = "junit")
|
||||||
|
}
|
||||||
|
{{#reactive}}
|
||||||
|
testCompile("org.jetbrains.kotlinx:kotlinx-coroutines-test:$kotlinxCoroutinesVersion")
|
||||||
|
{{/reactive}}
|
||||||
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
{{contextPath}}
|
|
@ -0,0 +1,210 @@
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<groupId>{{groupId}}</groupId>
|
||||||
|
<artifactId>{{artifactId}}</artifactId>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
<name>{{artifactId}}</name>
|
||||||
|
<version>{{artifactVersion}}</version>
|
||||||
|
<properties>{{#reactive}}
|
||||||
|
<kotlinx-coroutines.version>1.6.1
|
||||||
|
</kotlinx-coroutines.version>{{/reactive}}{{#springDocDocumentationProvider}}{{#useSwaggerUI}}
|
||||||
|
<springdoc-openapi.version>2.0.2
|
||||||
|
</springdoc-openapi.version>{{/useSwaggerUI}}{{/springDocDocumentationProvider}}{{#springFoxDocumentationProvider}}
|
||||||
|
<springfox-swagger2.version>2.9.2
|
||||||
|
</springfox-swagger2.version>{{/springFoxDocumentationProvider}}{{#useSwaggerUI}}{{^springDocDocumentationProvider}}
|
||||||
|
<swagger-ui.version>4.15.5
|
||||||
|
</swagger-ui.version>{{/springDocDocumentationProvider}}{{/useSwaggerUI}}{{^springFoxDocumentationProvider}}{{^springDocDocumentationProvider}}{{#swagger1AnnotationLibrary}}
|
||||||
|
<swagger-annotations.version>1.6.6
|
||||||
|
</swagger-annotations.version>{{/swagger1AnnotationLibrary}}{{#swagger2AnnotationLibrary}}
|
||||||
|
<swagger-annotations.version>2.2.7
|
||||||
|
</swagger-annotations.version>{{/swagger2AnnotationLibrary}}{{/springDocDocumentationProvider}}{{/springFoxDocumentationProvider}}
|
||||||
|
<findbugs-jsr305.version>3.0.2</findbugs-jsr305.version>
|
||||||
|
<jakarta-annotation.version>2.1.0</jakarta-annotation.version>
|
||||||
|
<kotlin-test-junit5.version>1.7.10</kotlin-test-junit5.version>
|
||||||
|
|
||||||
|
<kotlin.version>1.7.10</kotlin.version>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
<parent>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-parent</artifactId>
|
||||||
|
<version>3.0.2</version>
|
||||||
|
</parent>
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>repository.spring.milestone</id>
|
||||||
|
<name>Spring Milestone Repository</name>
|
||||||
|
<url>https://repo.spring.io/milestone</url>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
<pluginRepositories>
|
||||||
|
<pluginRepository>
|
||||||
|
<id>spring-milestones</id>
|
||||||
|
<url>https://repo.spring.io/milestone</url>
|
||||||
|
</pluginRepository>
|
||||||
|
</pluginRepositories>
|
||||||
|
<build>
|
||||||
|
<sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
|
||||||
|
<testSourceDirectory>${project.basedir}/src/test/kotlin</testSourceDirectory>
|
||||||
|
<plugins>{{^interfaceOnly}}
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>repackage</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>{{/interfaceOnly}}
|
||||||
|
<plugin>
|
||||||
|
<artifactId>kotlin-maven-plugin</artifactId>
|
||||||
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
|
<version>${kotlin.version}</version>
|
||||||
|
<configuration>
|
||||||
|
<compilerPlugins>
|
||||||
|
<plugin>spring</plugin>
|
||||||
|
</compilerPlugins>
|
||||||
|
<jvmTarget>17</jvmTarget>
|
||||||
|
</configuration>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>compile</id>
|
||||||
|
<phase>compile</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>compile</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>test-compile</id>
|
||||||
|
<phase>test-compile</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>test-compile</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
|
<artifactId>kotlin-maven-allopen</artifactId>
|
||||||
|
<version>${kotlin.version}</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
|
<artifactId>kotlin-stdlib-jdk8</artifactId>
|
||||||
|
<version>${kotlin.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
|
<artifactId>kotlin-reflect</artifactId>
|
||||||
|
<version>${kotlin.version}</version>
|
||||||
|
</dependency>{{^reactive}}
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
|
</dependency>{{/reactive}}{{#reactive}}
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-webflux</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jetbrains.kotlinx</groupId>
|
||||||
|
<artifactId>kotlinx-coroutines-core</artifactId>
|
||||||
|
<version>${kotlinx-coroutines.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jetbrains.kotlinx</groupId>
|
||||||
|
<artifactId>kotlinx-coroutines-reactor</artifactId>
|
||||||
|
<version>${kotlinx-coroutines.version}</version>
|
||||||
|
</dependency>{{/reactive}}
|
||||||
|
|
||||||
|
{{#springDocDocumentationProvider}}
|
||||||
|
<!--SpringDoc dependencies -->{{#useSwaggerUI}}
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springdoc</groupId>
|
||||||
|
<artifactId>springdoc-openapi-starter-{{#reactive}}
|
||||||
|
webflux{{/reactive}}{{^reactive}}webmvc{{/reactive}}-ui
|
||||||
|
</artifactId>
|
||||||
|
<version>${springdoc-openapi.version}</version>
|
||||||
|
</dependency>{{/useSwaggerUI}}{{^useSwaggerUI}}
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springdoc</groupId>
|
||||||
|
<artifactId>springdoc-openapi-{{#reactive}}webflux{{/reactive}}{{^reactive}}webmvc{{/reactive}}-core
|
||||||
|
</artifactId>
|
||||||
|
<version>${springdoc-openapi.version}</version>
|
||||||
|
</dependency>{{/useSwaggerUI}}{{/springDocDocumentationProvider}}{{#springFoxDocumentationProvider}}
|
||||||
|
<!--SpringFox dependencies -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.springfox</groupId>
|
||||||
|
<artifactId>springfox-swagger2</artifactId>
|
||||||
|
<version>${springfox-swagger2.version}</version>
|
||||||
|
</dependency>{{/springFoxDocumentationProvider}}{{#useSwaggerUI}}{{^springDocDocumentationProvider}}
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.webjars</groupId>
|
||||||
|
<artifactId>swagger-ui</artifactId>
|
||||||
|
<version>${swagger-ui.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.webjars</groupId>
|
||||||
|
<artifactId>webjars-locator-core</artifactId>
|
||||||
|
</dependency>{{/springDocDocumentationProvider}}{{/useSwaggerUI}}{{^springFoxDocumentationProvider}}{{^springDocDocumentationProvider}}{{#swagger1AnnotationLibrary}}
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.swagger</groupId>
|
||||||
|
<artifactId>swagger-annotations</artifactId>
|
||||||
|
<version>${swagger-annotations.version}</version>
|
||||||
|
</dependency>{{/swagger1AnnotationLibrary}}{{#swagger2AnnotationLibrary}}
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.swagger.core.v3</groupId>
|
||||||
|
<artifactId>swagger-annotations</artifactId>
|
||||||
|
<version>${swagger-annotations.version}</version>
|
||||||
|
</dependency>{{/swagger2AnnotationLibrary}}{{/springDocDocumentationProvider}}{{/springFoxDocumentationProvider}}
|
||||||
|
|
||||||
|
<!-- @Nullable annotation -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.code.findbugs</groupId>
|
||||||
|
<artifactId>jsr305</artifactId>
|
||||||
|
<version>${findbugs-jsr305.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.dataformat</groupId>
|
||||||
|
<artifactId>jackson-dataformat-yaml</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.dataformat</groupId>
|
||||||
|
<artifactId>jackson-dataformat-xml</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||||
|
<artifactId>jackson-datatype-jsr310</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.module</groupId>
|
||||||
|
<artifactId>jackson-module-kotlin</artifactId>
|
||||||
|
</dependency>
|
||||||
|
{{#useBeanValidation}}
|
||||||
|
<!-- Bean Validation API support -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>jakarta.validation</groupId>
|
||||||
|
<artifactId>jakarta.validation-api</artifactId>
|
||||||
|
</dependency>{{/useBeanValidation}}
|
||||||
|
<dependency>
|
||||||
|
<groupId>jakarta.annotation</groupId>
|
||||||
|
<artifactId>jakarta.annotation-api</artifactId>
|
||||||
|
<version>${jakarta-annotation.version}</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
|
<artifactId>kotlin-test-junit5</artifactId>
|
||||||
|
<version>${kotlin-test-junit5.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
|
@ -0,0 +1,195 @@
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<groupId>{{groupId}}</groupId>
|
||||||
|
<artifactId>{{artifactId}}</artifactId>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
<name>{{artifactId}}</name>
|
||||||
|
<version>{{artifactVersion}}</version>
|
||||||
|
<properties>{{#reactive}}
|
||||||
|
<kotlinx-coroutines.version>1.6.1
|
||||||
|
</kotlinx-coroutines.version>{{/reactive}}{{#springDocDocumentationProvider}}{{#useSwaggerUI}}
|
||||||
|
<springdoc-openapi.version>1.6.8
|
||||||
|
</springdoc-openapi.version>{{/useSwaggerUI}}{{/springDocDocumentationProvider}}{{#springFoxDocumentationProvider}}
|
||||||
|
<springfox-swagger2.version>2.9.2
|
||||||
|
</springfox-swagger2.version>{{/springFoxDocumentationProvider}}{{#useSwaggerUI}}{{^springDocDocumentationProvider}}
|
||||||
|
<swagger-ui.version>4.10.3
|
||||||
|
</swagger-ui.version>{{/springDocDocumentationProvider}}{{/useSwaggerUI}}{{^springFoxDocumentationProvider}}{{^springDocDocumentationProvider}}{{#swagger1AnnotationLibrary}}
|
||||||
|
<swagger-annotations.version>1.6.6
|
||||||
|
</swagger-annotations.version>{{/swagger1AnnotationLibrary}}{{#swagger2AnnotationLibrary}}
|
||||||
|
<swagger-annotations.version>2.2.0
|
||||||
|
</swagger-annotations.version>{{/swagger2AnnotationLibrary}}{{/springDocDocumentationProvider}}{{/springFoxDocumentationProvider}}
|
||||||
|
<findbugs-jsr305.version>3.0.2</findbugs-jsr305.version>
|
||||||
|
<jakarta-annotation.version>2.1.0</jakarta-annotation.version>
|
||||||
|
<kotlin-test-junit5.version>1.6.21</kotlin-test-junit5.version>
|
||||||
|
|
||||||
|
<kotlin.version>1.6.21</kotlin.version>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
<parent>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-parent</artifactId>
|
||||||
|
<version>2.6.7</version>
|
||||||
|
</parent>
|
||||||
|
<build>
|
||||||
|
<sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
|
||||||
|
<testSourceDirectory>${project.basedir}/src/test/kotlin</testSourceDirectory>
|
||||||
|
<plugins>{{^interfaceOnly}}
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>repackage</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>{{/interfaceOnly}}
|
||||||
|
<plugin>
|
||||||
|
<artifactId>kotlin-maven-plugin</artifactId>
|
||||||
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
|
<version>${kotlin.version}</version>
|
||||||
|
<configuration>
|
||||||
|
<compilerPlugins>
|
||||||
|
<plugin>spring</plugin>
|
||||||
|
</compilerPlugins>
|
||||||
|
<jvmTarget>1.8</jvmTarget>
|
||||||
|
</configuration>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>compile</id>
|
||||||
|
<phase>compile</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>compile</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>test-compile</id>
|
||||||
|
<phase>test-compile</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>test-compile</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
|
<artifactId>kotlin-maven-allopen</artifactId>
|
||||||
|
<version>${kotlin.version}</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
|
<artifactId>kotlin-stdlib-jdk8</artifactId>
|
||||||
|
<version>${kotlin.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
|
<artifactId>kotlin-reflect</artifactId>
|
||||||
|
<version>${kotlin.version}</version>
|
||||||
|
</dependency>{{^reactive}}
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
|
</dependency>{{/reactive}}{{#reactive}}
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-webflux</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jetbrains.kotlinx</groupId>
|
||||||
|
<artifactId>kotlinx-coroutines-core</artifactId>
|
||||||
|
<version>${kotlinx-coroutines.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jetbrains.kotlinx</groupId>
|
||||||
|
<artifactId>kotlinx-coroutines-reactor</artifactId>
|
||||||
|
<version>${kotlinx-coroutines.version}</version>
|
||||||
|
</dependency>{{/reactive}}
|
||||||
|
|
||||||
|
{{#springDocDocumentationProvider}}
|
||||||
|
<!--SpringDoc dependencies -->{{#useSwaggerUI}}
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springdoc</groupId>
|
||||||
|
<artifactId>springdoc-openapi-{{#reactive}}webflux-{{/reactive}}ui</artifactId>
|
||||||
|
<version>${springdoc-openapi.version}</version>
|
||||||
|
</dependency>{{/useSwaggerUI}}{{^useSwaggerUI}}
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springdoc</groupId>
|
||||||
|
<artifactId>springdoc-openapi-{{#reactive}}webflux{{/reactive}}{{^reactive}}webmvc{{/reactive}}-core
|
||||||
|
</artifactId>
|
||||||
|
<version>${springdoc-openapi.version}</version>
|
||||||
|
</dependency>{{/useSwaggerUI}}{{/springDocDocumentationProvider}}{{#springFoxDocumentationProvider}}
|
||||||
|
<!--SpringFox dependencies -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.springfox</groupId>
|
||||||
|
<artifactId>springfox-swagger2</artifactId>
|
||||||
|
<version>${springfox-swagger2.version}</version>
|
||||||
|
</dependency>{{/springFoxDocumentationProvider}}{{#useSwaggerUI}}{{^springDocDocumentationProvider}}
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.webjars</groupId>
|
||||||
|
<artifactId>swagger-ui</artifactId>
|
||||||
|
<version>${swagger-ui.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.webjars</groupId>
|
||||||
|
<artifactId>webjars-locator-core</artifactId>
|
||||||
|
</dependency>{{/springDocDocumentationProvider}}{{/useSwaggerUI}}{{^springFoxDocumentationProvider}}{{^springDocDocumentationProvider}}{{#swagger1AnnotationLibrary}}
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.swagger</groupId>
|
||||||
|
<artifactId>swagger-annotations</artifactId>
|
||||||
|
<version>${swagger-annotations.version}</version>
|
||||||
|
</dependency>{{/swagger1AnnotationLibrary}}{{#swagger2AnnotationLibrary}}
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.swagger.core.v3</groupId>
|
||||||
|
<artifactId>swagger-annotations</artifactId>
|
||||||
|
<version>${swagger-annotations.version}</version>
|
||||||
|
</dependency>{{/swagger2AnnotationLibrary}}{{/springDocDocumentationProvider}}{{/springFoxDocumentationProvider}}
|
||||||
|
|
||||||
|
<!-- @Nullable annotation -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.code.findbugs</groupId>
|
||||||
|
<artifactId>jsr305</artifactId>
|
||||||
|
<version>${findbugs-jsr305.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.dataformat</groupId>
|
||||||
|
<artifactId>jackson-dataformat-yaml</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.dataformat</groupId>
|
||||||
|
<artifactId>jackson-dataformat-xml</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||||
|
<artifactId>jackson-datatype-jsr310</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.module</groupId>
|
||||||
|
<artifactId>jackson-module-kotlin</artifactId>
|
||||||
|
</dependency>
|
||||||
|
{{#useBeanValidation}}
|
||||||
|
<!-- Bean Validation API support -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>jakarta.validation</groupId>
|
||||||
|
<artifactId>jakarta.validation-api</artifactId>
|
||||||
|
</dependency>{{/useBeanValidation}}
|
||||||
|
<dependency>
|
||||||
|
<groupId>jakarta.annotation</groupId>
|
||||||
|
<artifactId>jakarta.annotation-api</artifactId>
|
||||||
|
<version>${jakarta-annotation.version}</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
|
<artifactId>kotlin-test-junit5</artifactId>
|
||||||
|
<version>${kotlin-test-junit5.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
|
@ -0,0 +1,15 @@
|
||||||
|
pluginManagement {
|
||||||
|
repositories {
|
||||||
|
maven { url = uri("https://repo.spring.io/snapshot") }
|
||||||
|
maven { url = uri("https://repo.spring.io/milestone") }
|
||||||
|
gradlePluginPortal()
|
||||||
|
}
|
||||||
|
resolutionStrategy {
|
||||||
|
eachPlugin {
|
||||||
|
if (requested.id.id == "org.springframework.boot") {
|
||||||
|
useModule("org.springframework.boot:spring-boot-gradle-plugin:${requested.version}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rootProject.name = "{{artifactId}}"
|
|
@ -0,0 +1,15 @@
|
||||||
|
package {{basePackage}}
|
||||||
|
|
||||||
|
import org.springframework.boot.runApplication
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication
|
||||||
|
import org.springframework.context.annotation.ComponentScan
|
||||||
|
|
||||||
|
@SpringBootApplication
|
||||||
|
@ComponentScan(basePackages = ["{{basePackage}}", "{{apiPackage}}", "{{modelPackage}}"])
|
||||||
|
class Application
|
||||||
|
|
||||||
|
fun main(args: Array
|
||||||
|
<String>) {
|
||||||
|
runApplication
|
||||||
|
<Application>(*args)
|
||||||
|
}
|
|
@ -0,0 +1,57 @@
|
||||||
|
<!-- HTML for static distribution bundle build -->
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Swagger UI</title>
|
||||||
|
<link rel="stylesheet" type="text/css" href="webjars/swagger-ui/swagger-ui.css"/>
|
||||||
|
<link rel="icon" type="image/png" href="webjars/swagger-ui/favicon-32x32.png" sizes="32x32"/>
|
||||||
|
<link rel="icon" type="image/png" href="webjars/swagger-ui/favicon-16x16.png" sizes="16x16"/>
|
||||||
|
<style>
|
||||||
|
html {
|
||||||
|
box-sizing: border-box;
|
||||||
|
overflow: -moz-scrollbars-vertical;
|
||||||
|
overflow-y: scroll;
|
||||||
|
}
|
||||||
|
|
||||||
|
*,
|
||||||
|
*:before,
|
||||||
|
*:after {
|
||||||
|
box-sizing: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
background: #fafafa;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div id="swagger-ui"></div>
|
||||||
|
|
||||||
|
<script src="webjars/swagger-ui/swagger-ui-bundle.js" charset="UTF-8"></script>
|
||||||
|
<script src="webjars/swagger-ui/swagger-ui-standalone-preset.js" charset="UTF-8"></script>
|
||||||
|
<script>
|
||||||
|
window.onload = function () {
|
||||||
|
// Begin Swagger UI call region
|
||||||
|
const ui = SwaggerUIBundle({
|
||||||
|
configUrl: 'swagger-config.yaml',
|
||||||
|
dom_id: '#swagger-ui',
|
||||||
|
deepLinking: true,
|
||||||
|
presets: [
|
||||||
|
SwaggerUIBundle.presets.apis,
|
||||||
|
SwaggerUIStandalonePreset
|
||||||
|
],
|
||||||
|
plugins: [
|
||||||
|
SwaggerUIBundle.plugins.DownloadUrl
|
||||||
|
],
|
||||||
|
layout: "StandaloneLayout"
|
||||||
|
});
|
||||||
|
// End Swagger UI call region
|
||||||
|
|
||||||
|
window.ui = ui;
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -0,0 +1,83 @@
|
||||||
|
{{^interfaceOnly}}
|
||||||
|
# {{artifactId}}
|
||||||
|
|
||||||
|
## Requirements
|
||||||
|
|
||||||
|
Building the API client library requires [Maven](https://maven.apache.org/) to be installed.
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
To install the API client library to your local Maven repository, simply execute:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
mvn install
|
||||||
|
```
|
||||||
|
|
||||||
|
To deploy it to a remote Maven repository instead, configure the settings of the repository and execute:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
mvn deploy
|
||||||
|
```
|
||||||
|
|
||||||
|
Refer to the [official documentation](https://maven.apache.org/plugins/maven-deploy-plugin/usage.html) for more information.
|
||||||
|
|
||||||
|
### Maven users
|
||||||
|
|
||||||
|
Add this dependency to your project's POM:
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<dependency>
|
||||||
|
<groupId>{{{groupId}}}</groupId>
|
||||||
|
<artifactId>{{{artifactId}}}</artifactId>
|
||||||
|
<version>{{{artifactVersion}}}</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
```
|
||||||
|
|
||||||
|
### Gradle users
|
||||||
|
|
||||||
|
Add this dependency to your project's build file:
|
||||||
|
|
||||||
|
```groovy
|
||||||
|
compile "{{{groupId}}}:{{{artifactId}}}:{{{artifactVersion}}}"
|
||||||
|
```
|
||||||
|
|
||||||
|
### Others
|
||||||
|
|
||||||
|
At first generate the JAR by executing:
|
||||||
|
|
||||||
|
mvn package
|
||||||
|
|
||||||
|
Then manually install the following JARs:
|
||||||
|
|
||||||
|
* target/{{{artifactId}}}-{{{artifactVersion}}}.jar
|
||||||
|
* target/lib/*.jar
|
||||||
|
{{/interfaceOnly}}
|
||||||
|
{{#interfaceOnly}}
|
||||||
|
# OpenAPI generated API stub
|
||||||
|
|
||||||
|
Spring Framework stub
|
||||||
|
|
||||||
|
|
||||||
|
## Overview
|
||||||
|
This code was generated by the [OpenAPI Generator](https://openapi-generator.tech) project.
|
||||||
|
By using the [OpenAPI-Spec](https://openapis.org), you can easily generate an API stub.
|
||||||
|
This is an example of building API stub interfaces in Java using the Spring framework.
|
||||||
|
|
||||||
|
The stubs generated can be used in your existing Spring-MVC or Spring-Boot application to create controller endpoints
|
||||||
|
by adding ```@Controller``` classes that implement the interface. Eg:
|
||||||
|
```java
|
||||||
|
@Controller
|
||||||
|
public class PetController implements PetApi {
|
||||||
|
// implement all PetApi methods
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
You can also use the interface to create [Spring-Cloud Feign clients](http://projects.spring.io/spring-cloud/spring-cloud.html#spring-cloud-feign-inheritance).Eg:
|
||||||
|
```java
|
||||||
|
@FeignClient(name="pet", url="http://petstore.swagger.io/v2")
|
||||||
|
public interface PetClient extends PetApi {
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
{{/interfaceOnly}}
|
|
@ -0,0 +1,11 @@
|
||||||
|
package {{package}}
|
||||||
|
|
||||||
|
import org.springframework.cloud.openfeign.FeignClient
|
||||||
|
import {{configPackage}}.ClientConfiguration
|
||||||
|
|
||||||
|
@FeignClient(
|
||||||
|
name="\${{openbrace}}{{classVarName}}.name:{{classVarName}}{{closebrace}}",
|
||||||
|
{{#useFeignClientUrl}}url="\${{openbrace}}{{classVarName}}.url:{{basePath}}{{closebrace}}", {{/useFeignClientUrl}}
|
||||||
|
configuration = [ClientConfiguration::class]
|
||||||
|
)
|
||||||
|
interface {{classname}}Client : {{classname}}
|
|
@ -0,0 +1,19 @@
|
||||||
|
package {{configPackage}}
|
||||||
|
|
||||||
|
import feign.RequestInterceptor
|
||||||
|
import feign.RequestTemplate
|
||||||
|
|
||||||
|
class ApiKeyRequestInterceptor(
|
||||||
|
private val location: String,
|
||||||
|
private val name: String,
|
||||||
|
private val value: String,
|
||||||
|
) : RequestInterceptor {
|
||||||
|
|
||||||
|
override fun apply(requestTemplate: RequestTemplate) {
|
||||||
|
if (location == "header") {
|
||||||
|
requestTemplate.header(name, value)
|
||||||
|
} else if (location == "query") {
|
||||||
|
requestTemplate.query(name, value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,72 @@
|
||||||
|
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||||
|
|
||||||
|
group = "{{groupId}}"
|
||||||
|
version = "{{artifactVersion}}"
|
||||||
|
java.sourceCompatibility = JavaVersion.VERSION_17
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
maven { url = uri("https://repo.spring.io/milestone") }
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.withType
|
||||||
|
<KotlinCompile> {
|
||||||
|
kotlinOptions.jvmTarget = "17"
|
||||||
|
}
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
val kotlinVersion = "1.7.10"
|
||||||
|
id("org.jetbrains.kotlin.jvm") version kotlinVersion
|
||||||
|
id("org.jetbrains.kotlin.plugin.jpa") version kotlinVersion
|
||||||
|
id("org.jetbrains.kotlin.plugin.spring") version kotlinVersion
|
||||||
|
id("org.springframework.boot") version "3.0.2"
|
||||||
|
id("io.spring.dependency-management") version "1.0.14.RELEASE"
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.getByName("bootJar") {
|
||||||
|
enabled = false
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.getByName("jar") {
|
||||||
|
enabled = true
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencyManagement {
|
||||||
|
imports {
|
||||||
|
mavenBom("org.springframework.cloud:spring-cloud-dependencies:2021.0.5")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
{{#reactive}} val kotlinxCoroutinesVersion = "1.6.1"
|
||||||
|
{{/reactive}} implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
|
||||||
|
implementation("org.jetbrains.kotlin:kotlin-reflect"){{^reactive}}
|
||||||
|
implementation("org.springframework.boot:spring-boot-starter-web"){{/reactive}}{{#reactive}}
|
||||||
|
implementation("org.springframework.boot:spring-boot-starter-webflux")
|
||||||
|
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlinxCoroutinesVersion")
|
||||||
|
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-reactor:$kotlinxCoroutinesVersion"){{/reactive}}{{#springDocDocumentationProvider}}{{#useSwaggerUI}}
|
||||||
|
implementation("org.springdoc:springdoc-openapi-starter-{{#reactive}}
|
||||||
|
webflux{{/reactive}}{{^reactive}}webmvc{{/reactive}}-ui:2.0.0-M5"){{/useSwaggerUI}}{{^useSwaggerUI}}
|
||||||
|
implementation("org.springdoc:springdoc-openapi-{{#reactive}}
|
||||||
|
webflux{{/reactive}}{{^reactive}}webmvc{{/reactive}}
|
||||||
|
-core:2.0.0-M5"){{/useSwaggerUI}}{{/springDocDocumentationProvider}}{{#springFoxDocumentationProvider}}
|
||||||
|
implementation("io.springfox:springfox-swagger2:2.9.2"){{/springFoxDocumentationProvider}}{{#useSwaggerUI}}{{^springDocDocumentationProvider}}
|
||||||
|
implementation("org.webjars:swagger-ui:4.10.3")
|
||||||
|
implementation("org.webjars:webjars-locator-core"){{/springDocDocumentationProvider}}{{/useSwaggerUI}}{{^springFoxDocumentationProvider}}{{^springDocDocumentationProvider}}{{#swagger1AnnotationLibrary}}
|
||||||
|
implementation("io.swagger:swagger-annotations:1.6.6"){{/swagger1AnnotationLibrary}}{{#swagger2AnnotationLibrary}}
|
||||||
|
implementation("io.swagger.core.v3:swagger-annotations:2.2.0"){{/swagger2AnnotationLibrary}}{{/springDocDocumentationProvider}}{{/springFoxDocumentationProvider}}
|
||||||
|
|
||||||
|
implementation("com.google.code.findbugs:jsr305:3.0.2")
|
||||||
|
implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml")
|
||||||
|
implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-xml")
|
||||||
|
implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310")
|
||||||
|
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
|
||||||
|
|
||||||
|
implementation("org.springframework.cloud:spring-cloud-starter-openfeign"){{#hasAuthMethods}}
|
||||||
|
implementation("org.springframework.cloud:spring-cloud-starter-oauth2:2.2.5.RELEASE"){{/hasAuthMethods}}
|
||||||
|
|
||||||
|
{{#useBeanValidation}}
|
||||||
|
implementation("jakarta.validation:jakarta.validation-api"){{/useBeanValidation}}
|
||||||
|
implementation("jakarta.annotation:jakarta.annotation-api:2.1.0")
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,79 @@
|
||||||
|
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||||
|
|
||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
dependencies {
|
||||||
|
classpath("org.springframework.boot:spring-boot-gradle-plugin:2.6.7")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
group = "{{groupId}}"
|
||||||
|
version = "{{artifactVersion}}"
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.withType
|
||||||
|
<KotlinCompile> {
|
||||||
|
kotlinOptions.jvmTarget = "1.8"
|
||||||
|
}
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
val kotlinVersion = "1.6.21"
|
||||||
|
id("org.jetbrains.kotlin.jvm") version kotlinVersion
|
||||||
|
id("org.jetbrains.kotlin.plugin.jpa") version kotlinVersion
|
||||||
|
id("org.jetbrains.kotlin.plugin.spring") version kotlinVersion
|
||||||
|
id("org.springframework.boot") version "2.6.7"
|
||||||
|
id("io.spring.dependency-management") version "1.0.11.RELEASE"
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.getByName("bootJar") {
|
||||||
|
enabled = false
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.getByName("jar") {
|
||||||
|
enabled = true
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencyManagement {
|
||||||
|
imports {
|
||||||
|
mavenBom("org.springframework.cloud:spring-cloud-dependencies:2021.0.5")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
{{#reactive}} val kotlinxCoroutinesVersion = "1.6.1"
|
||||||
|
{{/reactive}} implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
|
||||||
|
implementation("org.jetbrains.kotlin:kotlin-reflect"){{^reactive}}
|
||||||
|
implementation("org.springframework.boot:spring-boot-starter-web"){{/reactive}}{{#reactive}}
|
||||||
|
implementation("org.springframework.boot:spring-boot-starter-webflux")
|
||||||
|
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlinxCoroutinesVersion")
|
||||||
|
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-reactor:$kotlinxCoroutinesVersion"){{/reactive}}{{#springDocDocumentationProvider}}{{#useSwaggerUI}}
|
||||||
|
implementation("org.springdoc:springdoc-openapi-{{#reactive}}
|
||||||
|
webflux-{{/reactive}}ui:1.6.8"){{/useSwaggerUI}}{{^useSwaggerUI}}
|
||||||
|
implementation("org.springdoc:springdoc-openapi-{{#reactive}}
|
||||||
|
webflux{{/reactive}}{{^reactive}}webmvc{{/reactive}}
|
||||||
|
-core:1.6.8"){{/useSwaggerUI}}{{/springDocDocumentationProvider}}{{#springFoxDocumentationProvider}}
|
||||||
|
implementation("io.springfox:springfox-swagger2:2.9.2"){{/springFoxDocumentationProvider}}{{#useSwaggerUI}}{{^springDocDocumentationProvider}}
|
||||||
|
implementation("org.webjars:swagger-ui:4.10.3")
|
||||||
|
implementation("org.webjars:webjars-locator-core"){{/springDocDocumentationProvider}}{{/useSwaggerUI}}{{^springFoxDocumentationProvider}}{{^springDocDocumentationProvider}}{{#swagger1AnnotationLibrary}}
|
||||||
|
implementation("io.swagger:swagger-annotations:1.6.6"){{/swagger1AnnotationLibrary}}{{#swagger2AnnotationLibrary}}
|
||||||
|
implementation("io.swagger.core.v3:swagger-annotations:2.2.0"){{/swagger2AnnotationLibrary}}{{/springDocDocumentationProvider}}{{/springFoxDocumentationProvider}}
|
||||||
|
|
||||||
|
implementation("com.google.code.findbugs:jsr305:3.0.2")
|
||||||
|
implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml")
|
||||||
|
implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-xml")
|
||||||
|
implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310")
|
||||||
|
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
|
||||||
|
|
||||||
|
implementation("org.springframework.cloud:spring-cloud-starter-openfeign"){{#hasAuthMethods}}
|
||||||
|
implementation("org.springframework.cloud:spring-cloud-starter-oauth2:2.2.5.RELEASE"){{/hasAuthMethods}}
|
||||||
|
|
||||||
|
{{#useBeanValidation}}
|
||||||
|
implementation("jakarta.validation:jakarta.validation-api"){{/useBeanValidation}}
|
||||||
|
implementation("jakarta.annotation:jakarta.annotation-api:2.1.0")
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,132 @@
|
||||||
|
package {{configPackage}}
|
||||||
|
|
||||||
|
{{#authMethods}}
|
||||||
|
{{#isBasicBasic}}
|
||||||
|
import feign.auth.BasicAuthRequestInterceptor
|
||||||
|
{{/isBasicBasic}}
|
||||||
|
{{#-first}}
|
||||||
|
import org.springframework.beans.factory.annotation.Value
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
|
||||||
|
{{/-first}}
|
||||||
|
{{#isOAuth}}
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties
|
||||||
|
{{/isOAuth}}
|
||||||
|
{{/authMethods}}
|
||||||
|
import org.springframework.boot.context.properties.EnableConfigurationProperties
|
||||||
|
{{#authMethods}}
|
||||||
|
{{#-first}}
|
||||||
|
import org.springframework.context.annotation.Bean
|
||||||
|
{{/-first}}
|
||||||
|
{{/authMethods}}
|
||||||
|
import org.springframework.context.annotation.Configuration
|
||||||
|
{{#authMethods}}
|
||||||
|
{{#isOAuth}}
|
||||||
|
import org.springframework.cloud.openfeign.security.OAuth2FeignRequestInterceptor
|
||||||
|
import org.springframework.security.oauth2.client.DefaultOAuth2ClientContext
|
||||||
|
import org.springframework.security.oauth2.client.OAuth2ClientContext
|
||||||
|
{{#isApplication}}
|
||||||
|
import org.springframework.security.oauth2.client.token.grant.client.ClientCredentialsResourceDetails
|
||||||
|
{{/isApplication}}
|
||||||
|
{{#isCode}}
|
||||||
|
import org.springframework.security.oauth2.client.token.grant.code.AuthorizationCodeResourceDetails
|
||||||
|
{{/isCode}}
|
||||||
|
{{#isImplicit}}
|
||||||
|
import org.springframework.security.oauth2.client.token.grant.implicit.ImplicitResourceDetails
|
||||||
|
{{/isImplicit}}
|
||||||
|
{{#isPassword}}
|
||||||
|
import org.springframework.security.oauth2.client.token.grant.password.ResourceOwnerPasswordResourceDetails
|
||||||
|
{{/isPassword}}
|
||||||
|
{{/isOAuth}}
|
||||||
|
{{/authMethods}}
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
@EnableConfigurationProperties
|
||||||
|
class ClientConfiguration {
|
||||||
|
|
||||||
|
{{#authMethods}}
|
||||||
|
{{#isBasicBasic}}
|
||||||
|
@Value("\${{openbrace}}{{#lambda.lowercase}}{{{title}}}{{/lambda.lowercase}}.security.{{{name}}}.username:{{closebrace}}")
|
||||||
|
private lateinit var {{#lambda.camelcase}}{{{name}}}{{/lambda.camelcase}}Username: String
|
||||||
|
|
||||||
|
@Value("\${{openbrace}}{{#lambda.lowercase}}{{{title}}}{{/lambda.lowercase}}.security.{{{name}}}.password:{{closebrace}}")
|
||||||
|
private lateinit var {{#lambda.camelcase}}{{{name}}}{{/lambda.camelcase}}Password: String
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
@ConditionalOnProperty("{{#lambda.lowercase}}{{{title}}}{{/lambda.lowercase}}.security.{{{name}}}.username")
|
||||||
|
fun {{{name}}}RequestInterceptor(): BasicAuthRequestInterceptor {
|
||||||
|
return BasicAuthRequestInterceptor(this.{{#lambda.camelcase}}{{{name}}}{{/lambda.camelcase}}Username, this.{{#lambda.camelcase}}{{{name}}}{{/lambda.camelcase}}Password)
|
||||||
|
}
|
||||||
|
|
||||||
|
{{/isBasicBasic}}
|
||||||
|
{{#isApiKey}}
|
||||||
|
@Value("\${{openbrace}}{{#lambda.lowercase}}{{{title}}}{{/lambda.lowercase}}.security.{{{name}}}.key:{{closebrace}}")
|
||||||
|
private lateinit var {{#lambda.camelcase}}{{{name}}}{{/lambda.camelcase}}Key: String
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
@ConditionalOnProperty("{{#lambda.lowercase}}{{{title}}}{{/lambda.lowercase}}.security.{{{name}}}.key")
|
||||||
|
fun {{#lambda.camelcase}}{{{name}}}{{/lambda.camelcase}}RequestInterceptor(): ApiKeyRequestInterceptor {
|
||||||
|
return ApiKeyRequestInterceptor({{#isKeyInHeader}}"header"{{/isKeyInHeader}}{{^isKeyInHeader}}"query"{{/isKeyInHeader}}, "{{{keyParamName}}}", this.{{#lambda.camelcase}}{{{name}}}{{/lambda.camelcase}}Key)
|
||||||
|
}
|
||||||
|
|
||||||
|
{{/isApiKey}}
|
||||||
|
{{#isOAuth}}
|
||||||
|
@Bean
|
||||||
|
@ConditionalOnProperty("{{#lambda.lowercase}}{{{title}}}{{/lambda.lowercase}}.security.{{{name}}}.client-id")
|
||||||
|
fun {{#lambda.camelcase}}{{{name}}}{{/lambda.camelcase}}RequestInterceptor(oAuth2ClientContext: OAuth2ClientContext): OAuth2FeignRequestInterceptor {
|
||||||
|
return OAuth2FeignRequestInterceptor(oAuth2ClientContext, {{#lambda.camelcase}}{{{name}}}{{/lambda.camelcase}}ResourceDetails())
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
@ConditionalOnProperty("{{#lambda.lowercase}}{{{title}}}{{/lambda.lowercase}}.security.{{{name}}}.client-id")
|
||||||
|
fun oAuth2ClientContext(): OAuth2ClientContext {
|
||||||
|
return DefaultOAuth2ClientContext()
|
||||||
|
}
|
||||||
|
|
||||||
|
{{#isCode}}
|
||||||
|
@Bean
|
||||||
|
@ConditionalOnProperty("{{#lambda.lowercase}}{{{title}}}{{/lambda.lowercase}}.security.{{{name}}}.client-id")
|
||||||
|
@ConfigurationProperties("{{#lambda.lowercase}}{{{title}}}{{/lambda.lowercase}}.security.{{{name}}}")
|
||||||
|
fun {{#lambda.camelcase}}{{{name}}}{{/lambda.camelcase}}ResourceDetails(): AuthorizationCodeResourceDetails {
|
||||||
|
val details = AuthorizationCodeResourceDetails()
|
||||||
|
details.accessTokenUri = "{{{tokenUrl}}}"
|
||||||
|
details.userAuthorizationUri = "{{{authorizationUrl}}}"
|
||||||
|
return details
|
||||||
|
}
|
||||||
|
|
||||||
|
{{/isCode}}
|
||||||
|
{{#isPassword}}
|
||||||
|
@Bean
|
||||||
|
@ConditionalOnProperty("{{#lambda.lowercase}}{{{title}}}{{/lambda.lowercase}}.security.{{{name}}}.client-id")
|
||||||
|
@ConfigurationProperties("{{#lambda.lowercase}}{{{title}}}{{/lambda.lowercase}}.security.{{{name}}}")
|
||||||
|
fun {{#lambda.camelcase}}{{{name}}}{{/lambda.camelcase}}ResourceDetails(): ResourceOwnerPasswordResourceDetails {
|
||||||
|
val details = ResourceOwnerPasswordResourceDetails()
|
||||||
|
details.accessTokenUri = "{{{tokenUrl}}}"
|
||||||
|
return details
|
||||||
|
}
|
||||||
|
|
||||||
|
{{/isPassword}}
|
||||||
|
{{#isApplication}}
|
||||||
|
@Bean
|
||||||
|
@ConditionalOnProperty("{{#lambda.lowercase}}{{{title}}}{{/lambda.lowercase}}.security.{{{name}}}.client-id")
|
||||||
|
@ConfigurationProperties("{{#lambda.lowercase}}{{{title}}}{{/lambda.lowercase}}.security.{{{name}}}")
|
||||||
|
fun {{#lambda.camelcase}}{{{name}}}{{/lambda.camelcase}}ResourceDetails(): ClientCredentialsResourceDetails {
|
||||||
|
val details = ClientCredentialsResourceDetails()
|
||||||
|
details.accessTokenUri = "{{{tokenUrl}}}"
|
||||||
|
return details
|
||||||
|
}
|
||||||
|
|
||||||
|
{{/isApplication}}
|
||||||
|
{{#isImplicit}}
|
||||||
|
@Bean
|
||||||
|
@ConditionalOnProperty("{{#lambda.lowercase}}{{{title}}}{{/lambda.lowercase}}.security.{{{name}}}.client-id")
|
||||||
|
@ConfigurationProperties("{{#lambda.lowercase}}{{{title}}}{{/lambda.lowercase}}.security.{{{name}}}")
|
||||||
|
fun {{#lambda.camelcase}}{{{name}}}{{/lambda.camelcase}}ResourceDetails(): ImplicitResourceDetails {
|
||||||
|
val details = ImplicitResourceDetails()
|
||||||
|
details.userAuthorizationUri= "{{{authorizationUrl}}}"
|
||||||
|
return details
|
||||||
|
}
|
||||||
|
|
||||||
|
{{/isImplicit}}
|
||||||
|
{{/isOAuth}}
|
||||||
|
{{/authMethods}}
|
||||||
|
}
|
|
@ -0,0 +1,233 @@
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<groupId>{{groupId}}</groupId>
|
||||||
|
<artifactId>{{artifactId}}</artifactId>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
<name>{{artifactId}}</name>
|
||||||
|
<version>{{artifactVersion}}</version>
|
||||||
|
<properties>{{#reactive}}
|
||||||
|
<kotlinx-coroutines.version>1.6.1
|
||||||
|
</kotlinx-coroutines.version>{{/reactive}}{{#springDocDocumentationProvider}}{{#useSwaggerUI}}
|
||||||
|
<springdoc-openapi.version>2.0.2
|
||||||
|
</springdoc-openapi.version>{{/useSwaggerUI}}{{/springDocDocumentationProvider}}{{#springFoxDocumentationProvider}}
|
||||||
|
<springfox-swagger2.version>2.9.2
|
||||||
|
</springfox-swagger2.version>{{/springFoxDocumentationProvider}}{{#useSwaggerUI}}{{^springDocDocumentationProvider}}
|
||||||
|
<swagger-ui.version>4.15.5
|
||||||
|
</swagger-ui.version>{{/springDocDocumentationProvider}}{{/useSwaggerUI}}{{^springFoxDocumentationProvider}}{{^springDocDocumentationProvider}}{{#swagger1AnnotationLibrary}}
|
||||||
|
<swagger-annotations.version>1.6.6
|
||||||
|
</swagger-annotations.version>{{/swagger1AnnotationLibrary}}{{#swagger2AnnotationLibrary}}
|
||||||
|
<swagger-annotations.version>2.2.7
|
||||||
|
</swagger-annotations.version>{{/swagger2AnnotationLibrary}}{{/springDocDocumentationProvider}}{{/springFoxDocumentationProvider}}
|
||||||
|
<findbugs-jsr305.version>3.0.2</findbugs-jsr305.version>
|
||||||
|
<jakarta-annotation.version>2.1.0</jakarta-annotation.version>
|
||||||
|
<kotlin-test-junit5.version>1.7.10</kotlin-test-junit5.version>
|
||||||
|
|
||||||
|
<kotlin.version>1.7.10</kotlin.version>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
<parent>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-parent</artifactId>
|
||||||
|
<version>3.0.2</version>
|
||||||
|
</parent>
|
||||||
|
<dependencyManagement>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-parent</artifactId>
|
||||||
|
<version>2021.0.5</version>
|
||||||
|
<type>pom</type>
|
||||||
|
<scope>import</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</dependencyManagement>
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>repository.spring.milestone</id>
|
||||||
|
<name>Spring Milestone Repository</name>
|
||||||
|
<url>https://repo.spring.io/milestone</url>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
<pluginRepositories>
|
||||||
|
<pluginRepository>
|
||||||
|
<id>spring-milestones</id>
|
||||||
|
<url>https://repo.spring.io/milestone</url>
|
||||||
|
</pluginRepository>
|
||||||
|
</pluginRepositories>
|
||||||
|
<build>
|
||||||
|
<sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
|
||||||
|
<plugins>{{^interfaceOnly}}
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>repackage</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>{{/interfaceOnly}}
|
||||||
|
<plugin>
|
||||||
|
<artifactId>kotlin-maven-plugin</artifactId>
|
||||||
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
|
<version>${kotlin.version}</version>
|
||||||
|
<configuration>
|
||||||
|
<compilerPlugins>
|
||||||
|
<plugin>spring</plugin>
|
||||||
|
</compilerPlugins>
|
||||||
|
<jvmTarget>17</jvmTarget>
|
||||||
|
</configuration>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>compile</id>
|
||||||
|
<phase>compile</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>compile</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>test-compile</id>
|
||||||
|
<phase>test-compile</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>test-compile</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
|
<artifactId>kotlin-maven-allopen</artifactId>
|
||||||
|
<version>${kotlin.version}</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
|
<artifactId>kotlin-stdlib-jdk8</artifactId>
|
||||||
|
<version>${kotlin.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
|
<artifactId>kotlin-reflect</artifactId>
|
||||||
|
<version>${kotlin.version}</version>
|
||||||
|
</dependency>{{^reactive}}
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
|
</dependency>{{/reactive}}{{#reactive}}
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-webflux</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jetbrains.kotlinx</groupId>
|
||||||
|
<artifactId>kotlinx-coroutines-core</artifactId>
|
||||||
|
<version>${kotlinx-coroutines.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jetbrains.kotlinx</groupId>
|
||||||
|
<artifactId>kotlinx-coroutines-reactor</artifactId>
|
||||||
|
<version>${kotlinx-coroutines.version}</version>
|
||||||
|
</dependency>{{/reactive}}
|
||||||
|
|
||||||
|
{{#springDocDocumentationProvider}}
|
||||||
|
<!--SpringDoc dependencies -->{{#useSwaggerUI}}
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springdoc</groupId>
|
||||||
|
<artifactId>springdoc-openapi-starter-{{#reactive}}
|
||||||
|
webflux{{/reactive}}{{^reactive}}webmvc{{/reactive}}-ui
|
||||||
|
</artifactId>
|
||||||
|
<version>${springdoc-openapi.version}</version>
|
||||||
|
</dependency>{{/useSwaggerUI}}{{^useSwaggerUI}}
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springdoc</groupId>
|
||||||
|
<artifactId>springdoc-openapi-{{#reactive}}webflux{{/reactive}}{{^reactive}}webmvc{{/reactive}}-core
|
||||||
|
</artifactId>
|
||||||
|
<version>${springdoc-openapi.version}</version>
|
||||||
|
</dependency>{{/useSwaggerUI}}{{/springDocDocumentationProvider}}{{#springFoxDocumentationProvider}}
|
||||||
|
<!--SpringFox dependencies -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.springfox</groupId>
|
||||||
|
<artifactId>springfox-swagger2</artifactId>
|
||||||
|
<version>${springfox-swagger2.version}</version>
|
||||||
|
</dependency>{{/springFoxDocumentationProvider}}{{#useSwaggerUI}}{{^springDocDocumentationProvider}}
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.webjars</groupId>
|
||||||
|
<artifactId>swagger-ui</artifactId>
|
||||||
|
<version>${swagger-ui.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.webjars</groupId>
|
||||||
|
<artifactId>webjars-locator-core</artifactId>
|
||||||
|
</dependency>{{/springDocDocumentationProvider}}{{/useSwaggerUI}}{{^springFoxDocumentationProvider}}{{^springDocDocumentationProvider}}{{#swagger1AnnotationLibrary}}
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.swagger</groupId>
|
||||||
|
<artifactId>swagger-annotations</artifactId>
|
||||||
|
<version>${swagger-annotations.version}</version>
|
||||||
|
</dependency>{{/swagger1AnnotationLibrary}}{{#swagger2AnnotationLibrary}}
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.swagger.core.v3</groupId>
|
||||||
|
<artifactId>swagger-annotations</artifactId>
|
||||||
|
<version>${swagger-annotations.version}</version>
|
||||||
|
</dependency>{{/swagger2AnnotationLibrary}}{{/springDocDocumentationProvider}}{{/springFoxDocumentationProvider}}
|
||||||
|
|
||||||
|
<!-- @Nullable annotation -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.code.findbugs</groupId>
|
||||||
|
<artifactId>jsr305</artifactId>
|
||||||
|
<version>${findbugs-jsr305.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
||||||
|
</dependency>
|
||||||
|
{{#hasAuthMethods}}
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-oauth2</artifactId>
|
||||||
|
{{^parentOverridden}}
|
||||||
|
<version>2.2.5.RELEASE</version>
|
||||||
|
{{/parentOverridden}}
|
||||||
|
</dependency>
|
||||||
|
{{/hasAuthMethods}}
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.dataformat</groupId>
|
||||||
|
<artifactId>jackson-dataformat-yaml</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.dataformat</groupId>
|
||||||
|
<artifactId>jackson-dataformat-xml</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||||
|
<artifactId>jackson-datatype-jsr310</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.module</groupId>
|
||||||
|
<artifactId>jackson-module-kotlin</artifactId>
|
||||||
|
</dependency>
|
||||||
|
{{#useBeanValidation}}
|
||||||
|
<!-- Bean Validation API support -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>jakarta.validation</groupId>
|
||||||
|
<artifactId>jakarta.validation-api</artifactId>
|
||||||
|
</dependency>{{/useBeanValidation}}
|
||||||
|
<dependency>
|
||||||
|
<groupId>jakarta.annotation</groupId>
|
||||||
|
<artifactId>jakarta.annotation-api</artifactId>
|
||||||
|
<version>${jakarta-annotation.version}</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
|
<artifactId>kotlin-test-junit5</artifactId>
|
||||||
|
<version>${kotlin-test-junit5.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
|
@ -0,0 +1,218 @@
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<groupId>{{groupId}}</groupId>
|
||||||
|
<artifactId>{{artifactId}}</artifactId>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
<name>{{artifactId}}</name>
|
||||||
|
<version>{{artifactVersion}}</version>
|
||||||
|
<properties>{{#reactive}}
|
||||||
|
<kotlinx-coroutines.version>1.6.1
|
||||||
|
</kotlinx-coroutines.version>{{/reactive}}{{#springDocDocumentationProvider}}{{#useSwaggerUI}}
|
||||||
|
<springdoc-openapi.version>1.6.8
|
||||||
|
</springdoc-openapi.version>{{/useSwaggerUI}}{{/springDocDocumentationProvider}}{{#springFoxDocumentationProvider}}
|
||||||
|
<springfox-swagger2.version>2.9.2
|
||||||
|
</springfox-swagger2.version>{{/springFoxDocumentationProvider}}{{#useSwaggerUI}}{{^springDocDocumentationProvider}}
|
||||||
|
<swagger-ui.version>4.10.3
|
||||||
|
</swagger-ui.version>{{/springDocDocumentationProvider}}{{/useSwaggerUI}}{{^springFoxDocumentationProvider}}{{^springDocDocumentationProvider}}{{#swagger1AnnotationLibrary}}
|
||||||
|
<swagger-annotations.version>1.6.6
|
||||||
|
</swagger-annotations.version>{{/swagger1AnnotationLibrary}}{{#swagger2AnnotationLibrary}}
|
||||||
|
<swagger-annotations.version>2.2.0
|
||||||
|
</swagger-annotations.version>{{/swagger2AnnotationLibrary}}{{/springDocDocumentationProvider}}{{/springFoxDocumentationProvider}}
|
||||||
|
<findbugs-jsr305.version>3.0.2</findbugs-jsr305.version>
|
||||||
|
<jakarta-annotation.version>2.1.0</jakarta-annotation.version>
|
||||||
|
<kotlin-test-junit5.version>1.6.21</kotlin-test-junit5.version>
|
||||||
|
|
||||||
|
<kotlin.version>1.6.21</kotlin.version>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
<parent>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-parent</artifactId>
|
||||||
|
<version>2.6.7</version>
|
||||||
|
</parent>
|
||||||
|
<dependencyManagement>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-parent</artifactId>
|
||||||
|
<version>2021.0.5</version>
|
||||||
|
<type>pom</type>
|
||||||
|
<scope>import</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</dependencyManagement>
|
||||||
|
<build>
|
||||||
|
<sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
|
||||||
|
<plugins>{{^interfaceOnly}}
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>repackage</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>{{/interfaceOnly}}
|
||||||
|
<plugin>
|
||||||
|
<artifactId>kotlin-maven-plugin</artifactId>
|
||||||
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
|
<version>${kotlin.version}</version>
|
||||||
|
<configuration>
|
||||||
|
<compilerPlugins>
|
||||||
|
<plugin>spring</plugin>
|
||||||
|
</compilerPlugins>
|
||||||
|
<jvmTarget>1.8</jvmTarget>
|
||||||
|
</configuration>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>compile</id>
|
||||||
|
<phase>compile</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>compile</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>test-compile</id>
|
||||||
|
<phase>test-compile</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>test-compile</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
|
<artifactId>kotlin-maven-allopen</artifactId>
|
||||||
|
<version>${kotlin.version}</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
|
<artifactId>kotlin-stdlib-jdk8</artifactId>
|
||||||
|
<version>${kotlin.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
|
<artifactId>kotlin-reflect</artifactId>
|
||||||
|
<version>${kotlin.version}</version>
|
||||||
|
</dependency>{{^reactive}}
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
|
</dependency>{{/reactive}}{{#reactive}}
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-webflux</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jetbrains.kotlinx</groupId>
|
||||||
|
<artifactId>kotlinx-coroutines-core</artifactId>
|
||||||
|
<version>${kotlinx-coroutines.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jetbrains.kotlinx</groupId>
|
||||||
|
<artifactId>kotlinx-coroutines-reactor</artifactId>
|
||||||
|
<version>${kotlinx-coroutines.version}</version>
|
||||||
|
</dependency>{{/reactive}}
|
||||||
|
|
||||||
|
{{#springDocDocumentationProvider}}
|
||||||
|
<!--SpringDoc dependencies -->{{#useSwaggerUI}}
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springdoc</groupId>
|
||||||
|
<artifactId>springdoc-openapi-{{#reactive}}webflux-{{/reactive}}ui</artifactId>
|
||||||
|
<version>${springdoc-openapi.version}</version>
|
||||||
|
</dependency>{{/useSwaggerUI}}{{^useSwaggerUI}}
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springdoc</groupId>
|
||||||
|
<artifactId>springdoc-openapi-{{#reactive}}webflux{{/reactive}}{{^reactive}}webmvc{{/reactive}}-core
|
||||||
|
</artifactId>
|
||||||
|
<version>${springdoc-openapi.version}</version>
|
||||||
|
</dependency>{{/useSwaggerUI}}{{/springDocDocumentationProvider}}{{#springFoxDocumentationProvider}}
|
||||||
|
<!--SpringFox dependencies -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.springfox</groupId>
|
||||||
|
<artifactId>springfox-swagger2</artifactId>
|
||||||
|
<version>${springfox-swagger2.version}</version>
|
||||||
|
</dependency>{{/springFoxDocumentationProvider}}{{#useSwaggerUI}}{{^springDocDocumentationProvider}}
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.webjars</groupId>
|
||||||
|
<artifactId>swagger-ui</artifactId>
|
||||||
|
<version>${swagger-ui.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.webjars</groupId>
|
||||||
|
<artifactId>webjars-locator-core</artifactId>
|
||||||
|
</dependency>{{/springDocDocumentationProvider}}{{/useSwaggerUI}}{{^springFoxDocumentationProvider}}{{^springDocDocumentationProvider}}{{#swagger1AnnotationLibrary}}
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.swagger</groupId>
|
||||||
|
<artifactId>swagger-annotations</artifactId>
|
||||||
|
<version>${swagger-annotations.version}</version>
|
||||||
|
</dependency>{{/swagger1AnnotationLibrary}}{{#swagger2AnnotationLibrary}}
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.swagger.core.v3</groupId>
|
||||||
|
<artifactId>swagger-annotations</artifactId>
|
||||||
|
<version>${swagger-annotations.version}</version>
|
||||||
|
</dependency>{{/swagger2AnnotationLibrary}}{{/springDocDocumentationProvider}}{{/springFoxDocumentationProvider}}
|
||||||
|
|
||||||
|
<!-- @Nullable annotation -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.code.findbugs</groupId>
|
||||||
|
<artifactId>jsr305</artifactId>
|
||||||
|
<version>${findbugs-jsr305.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
||||||
|
</dependency>
|
||||||
|
{{#hasAuthMethods}}
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-oauth2</artifactId>
|
||||||
|
{{^parentOverridden}}
|
||||||
|
<version>2.2.5.RELEASE</version>
|
||||||
|
{{/parentOverridden}}
|
||||||
|
</dependency>
|
||||||
|
{{/hasAuthMethods}}
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.dataformat</groupId>
|
||||||
|
<artifactId>jackson-dataformat-yaml</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.dataformat</groupId>
|
||||||
|
<artifactId>jackson-dataformat-xml</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||||
|
<artifactId>jackson-datatype-jsr310</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.module</groupId>
|
||||||
|
<artifactId>jackson-module-kotlin</artifactId>
|
||||||
|
</dependency>
|
||||||
|
{{#useBeanValidation}}
|
||||||
|
<!-- Bean Validation API support -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>jakarta.validation</groupId>
|
||||||
|
<artifactId>jakarta.validation-api</artifactId>
|
||||||
|
</dependency>{{/useBeanValidation}}
|
||||||
|
<dependency>
|
||||||
|
<groupId>jakarta.annotation</groupId>
|
||||||
|
<artifactId>jakarta.annotation-api</artifactId>
|
||||||
|
<version>${jakarta-annotation.version}</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
|
<artifactId>kotlin-test-junit5</artifactId>
|
||||||
|
<version>${kotlin-test-junit5.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
|
@ -0,0 +1,15 @@
|
||||||
|
pluginManagement {
|
||||||
|
repositories {
|
||||||
|
maven { url = uri("https://repo.spring.io/snapshot") }
|
||||||
|
maven { url = uri("https://repo.spring.io/milestone") }
|
||||||
|
gradlePluginPortal()
|
||||||
|
}
|
||||||
|
resolutionStrategy {
|
||||||
|
eachPlugin {
|
||||||
|
if (requested.id.id == "org.springframework.boot") {
|
||||||
|
useModule("org.springframework.boot:spring-boot-gradle-plugin:${requested.version}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rootProject.name = "{{artifactId}}"
|
|
@ -0,0 +1,28 @@
|
||||||
|
{{^reactive}}
|
||||||
|
{{#examples}}
|
||||||
|
{{#-first}}
|
||||||
|
{{#async}}
|
||||||
|
return CompletableFuture.supplyAsync(()-> {
|
||||||
|
{{/async}}getRequest().ifPresent { request ->
|
||||||
|
{{#async}} {{/async}} for (mediaType in MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||||
|
{{/-first}}
|
||||||
|
{{#async}} {{/async}}{{^async}} {{/async}} if (mediaType.isCompatibleWith(MediaType.valueOf("{{{contentType}}}"))) {
|
||||||
|
{{#async}} {{/async}}{{^async}} {{/async}} ApiUtil.setExampleResponse(request, "{{{contentType}}}", "{{#lambdaRemoveLineBreak}}{{#lambdaEscapeDoubleQuote}}{{{example}}}{{/lambdaEscapeDoubleQuote}}{{/lambdaRemoveLineBreak}}")
|
||||||
|
{{#async}} {{/async}}{{^async}} {{/async}} break
|
||||||
|
{{#async}} {{/async}}{{^async}} {{/async}} }
|
||||||
|
{{#-last}}
|
||||||
|
{{#async}} {{/async}}{{^async}} {{/async}} }
|
||||||
|
{{#async}} {{/async}} }
|
||||||
|
{{#async}} {{/async}} return ResponseEntity({{#returnSuccessCode}}HttpStatus.valueOf({{{statusCode}}}){{/returnSuccessCode}}{{^returnSuccessCode}}HttpStatus.NOT_IMPLEMENTED{{/returnSuccessCode}})
|
||||||
|
{{#async}}
|
||||||
|
}, Runnable::run)
|
||||||
|
{{/async}}
|
||||||
|
{{/-last}}
|
||||||
|
{{/examples}}
|
||||||
|
{{^examples}}
|
||||||
|
return {{#async}}CompletableFuture.completedFuture({{/async}}ResponseEntity({{#returnSuccessCode}}HttpStatus.OK{{/returnSuccessCode}}{{^returnSuccessCode}}HttpStatus.NOT_IMPLEMENTED{{/returnSuccessCode}})
|
||||||
|
{{/examples}}
|
||||||
|
{{/reactive}}
|
||||||
|
{{#reactive}}
|
||||||
|
return ResponseEntity({{#returnSuccessCode}}HttpStatus.OK{{/returnSuccessCode}}{{^returnSuccessCode}}HttpStatus.NOT_IMPLEMENTED{{/returnSuccessCode}})
|
||||||
|
{{/reactive}}
|
|
@ -0,0 +1,28 @@
|
||||||
|
package {{package}}
|
||||||
|
|
||||||
|
import java.util.Objects
|
||||||
|
{{#imports}}import {{import}}
|
||||||
|
{{/imports}}
|
||||||
|
{{#useBeanValidation}}
|
||||||
|
import {{javaxPackage}}.validation.constraints.DecimalMax
|
||||||
|
import {{javaxPackage}}.validation.constraints.DecimalMin
|
||||||
|
import {{javaxPackage}}.validation.constraints.Email
|
||||||
|
import {{javaxPackage}}.validation.constraints.Max
|
||||||
|
import {{javaxPackage}}.validation.constraints.Min
|
||||||
|
import {{javaxPackage}}.validation.constraints.NotNull
|
||||||
|
import {{javaxPackage}}.validation.constraints.Pattern
|
||||||
|
import {{javaxPackage}}.validation.constraints.Size
|
||||||
|
import {{javaxPackage}}.validation.Valid
|
||||||
|
{{/useBeanValidation}}
|
||||||
|
{{#swagger2AnnotationLibrary}}
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema
|
||||||
|
{{/swagger2AnnotationLibrary}}
|
||||||
|
{{#swagger1AnnotationLibrary}}
|
||||||
|
import io.swagger.annotations.ApiModelProperty
|
||||||
|
{{/swagger1AnnotationLibrary}}
|
||||||
|
|
||||||
|
{{#models}}
|
||||||
|
{{#model}}
|
||||||
|
{{#isEnum}}{{>enumClass}}{{/isEnum}}{{^isEnum}}{{>dataClass}}{{/isEnum}}
|
||||||
|
{{/model}}
|
||||||
|
{{/models}}
|
|
@ -0,0 +1 @@
|
||||||
|
{{#modelMutable}}var{{/modelMutable}}{{^modelMutable}}val{{/modelMutable}}
|
|
@ -0,0 +1 @@
|
||||||
|
{{{openapi-yaml}}}
|
|
@ -0,0 +1 @@
|
||||||
|
{{#required}}{{{dataType}}}{{/required}}{{^required}}{{#defaultValue}}{{{dataType}}}{{/defaultValue}}{{^defaultValue}}{{{dataType}}}?{{/defaultValue}}{{/required}}
|
|
@ -0,0 +1 @@
|
||||||
|
{{#isPathParam}}{{#useBeanValidation}}{{>beanValidationPathParams}}{{/useBeanValidation}}{{#swagger2AnnotationLibrary}}@Parameter(description = "{{{description}}}"{{#required}}, required = true{{/required}}{{#allowableValues}}{{#defaultValue}}, schema = Schema(allowableValues = [{{#enumVars}}"{{#lambdaEscapeDoubleQuote}}{{{value}}}{{/lambdaEscapeDoubleQuote}}"{{^-last}}, {{/-last}}{{/enumVars}}]{{^isContainer}}, defaultValue = {{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{{defaultValue}}}{{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{/isContainer}}{{/defaultValue}}{{/allowableValues}}{{#allowableValues}}{{^defaultValue}}, schema = Schema(allowableValues = [{{#enumVars}}"{{#lambdaEscapeDoubleQuote}}{{{value}}}{{/lambdaEscapeDoubleQuote}}"{{^-last}}, {{/-last}}{{/enumVars}}]){{/defaultValue}}{{/allowableValues}}{{^allowableValues}}{{#defaultValue}}{{^isContainer}}, schema = Schema(defaultValue = {{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{{defaultValue}}}{{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{/isContainer}}{{/defaultValue}}{{/allowableValues}}){{/swagger2AnnotationLibrary}}{{#swagger1AnnotationLibrary}}@ApiParam(value = "{{{description}}}"{{#required}}, required = true{{/required}}{{#allowableValues}}, allowableValues = "{{#enumVars}}{{#lambda.escapeDoubleQuote}}{{{value}}}{{/lambda.escapeDoubleQuote}}{{^-last}}, {{/-last}}{{/enumVars}}"{{/allowableValues}}{{#defaultValue}}, defaultValue = "{{{.}}}"{{/defaultValue}}){{/swagger1AnnotationLibrary}} @PathVariable("{{baseName}}") {{paramName}}: {{>optionalDataType}}{{/isPathParam}}
|
|
@ -0,0 +1 @@
|
||||||
|
{{#isQueryParam}}{{#useBeanValidation}}{{>beanValidationQueryParams}}{{/useBeanValidation}}{{#swagger2AnnotationLibrary}}@Parameter(description = "{{{description}}}"{{#required}}, required = true{{/required}}{{#allowableValues}}{{#defaultValue}}, schema = Schema(allowableValues = [{{#values}}"{{{.}}}"{{^-last}}, {{/-last}}{{/values}}]{{^isContainer}}, defaultValue = {{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{{defaultValue}}}{{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{/isContainer}}){{/defaultValue}}{{/allowableValues}}{{#allowableValues}}{{^defaultValue}}, schema = Schema(allowableValues = [{{#values}}"{{{.}}}"{{^-last}}, {{/-last}}{{/values}}]){{/defaultValue}}{{/allowableValues}}{{^allowableValues}}{{#defaultValue}}{{^isContainer}}, schema = Schema(defaultValue = {{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{{defaultValue}}}{{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}){{/isContainer}}{{/defaultValue}}{{/allowableValues}}){{/swagger2AnnotationLibrary}}{{#swagger1AnnotationLibrary}}@ApiParam(value = "{{{description}}}"{{#required}}, required = true{{/required}}{{#allowableValues}}, allowableValues = "{{#values}}{{{.}}}{{^-last}}, {{/-last}}{{/values}}"{{/allowableValues}}{{^isContainer}}{{#defaultValue}}, defaultValue = {{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{{defaultValue}}}{{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{/defaultValue}}{{/isContainer}}){{/swagger1AnnotationLibrary}}{{#useBeanValidation}} @Valid{{/useBeanValidation}}{{^isModel}} @RequestParam(value = "{{baseName}}"{{#required}}, required = true{{/required}}{{^required}}, required = false{{/required}}{{^isContainer}}{{#defaultValue}}, defaultValue = {{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{{defaultValue}}}{{^isString}}"{{/isString}}{{#isString}}{{#isEnum}}"{{/isEnum}}{{/isString}}{{/defaultValue}}{{/isContainer}}){{/isModel}}{{#isDate}} @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE){{/isDate}}{{#isDateTime}} @org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE_TIME){{/isDateTime}} {{paramName}}: {{>optionalDataType}}{{/isQueryParam}}
|
|
@ -0,0 +1,2 @@
|
||||||
|
{{#isMap}}Map
|
||||||
|
<String, {{{returnType}}}>{{/isMap}}{{#isArray}}{{#reactive}}Flow{{/reactive}}{{^reactive}}{{{returnContainer}}}{{/reactive}}<{{{returnType}}}>{{/isArray}}{{^returnContainer}}{{{returnType}}}{{/returnContainer}}
|
|
@ -0,0 +1 @@
|
||||||
|
{{#serviceInterface}}ResponseEntity(service.{{operationId}}({{#allParams}}{{{paramName}}}{{^-last}}, {{/-last}}{{/allParams}}), {{#responses}}{{#-first}}HttpStatus.valueOf({{code}}){{/-first}}{{/responses}}){{/serviceInterface}}{{^serviceInterface}}ResponseEntity(HttpStatus.NOT_IMPLEMENTED){{/serviceInterface}}
|
|
@ -0,0 +1,36 @@
|
||||||
|
package {{package}}
|
||||||
|
|
||||||
|
{{#imports}}import {{import}}
|
||||||
|
{{/imports}}
|
||||||
|
{{#reactive}}
|
||||||
|
import kotlinx.coroutines.flow.Flow
|
||||||
|
{{/reactive}}
|
||||||
|
|
||||||
|
{{#operations}}
|
||||||
|
interface {{classname}}Service {
|
||||||
|
{{#operation}}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {{httpMethod}} {{{path}}}{{#summary}} : {{.}}{{/summary}}
|
||||||
|
{{#notes}}
|
||||||
|
* {{.}}
|
||||||
|
{{/notes}}
|
||||||
|
*
|
||||||
|
{{#allParams}}
|
||||||
|
* @param {{{paramName}}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}}
|
||||||
|
{{/allParams}}
|
||||||
|
* @return {{#responses}}{{message}} (status code {{code}}){{^-last}}
|
||||||
|
* or {{/-last}}{{/responses}}
|
||||||
|
{{#isDeprecated}}
|
||||||
|
* @deprecated
|
||||||
|
{{/isDeprecated}}
|
||||||
|
{{#externalDocs}}
|
||||||
|
* {{description}}
|
||||||
|
* @see <a href="{{url}}">{{summary}} Documentation</a>
|
||||||
|
{{/externalDocs}}
|
||||||
|
* @see {{classname}}#{{operationId}}
|
||||||
|
*/
|
||||||
|
{{#reactive}}{{^isArray}}suspend {{/isArray}}{{/reactive}}fun {{operationId}}({{#allParams}}{{{paramName}}}: {{^isBodyParam}}{{>optionalDataType}}{{/isBodyParam}}{{#isBodyParam}}{{^reactive}}{{>optionalDataType}}{{/reactive}}{{#reactive}}{{^isArray}}{{>optionalDataType}}{{/isArray}}{{#isArray}}Flow<{{{baseType}}}>{{/isArray}}{{/reactive}}{{/isBodyParam}}{{^-last}}, {{/-last}}{{/allParams}}): {{>returnTypes}}
|
||||||
|
{{/operation}}
|
||||||
|
}
|
||||||
|
{{/operations}}
|
|
@ -0,0 +1,19 @@
|
||||||
|
package {{package}}
|
||||||
|
|
||||||
|
{{#imports}}import {{import}}
|
||||||
|
{{/imports}}
|
||||||
|
{{#reactive}}
|
||||||
|
import kotlinx.coroutines.flow.Flow
|
||||||
|
{{/reactive}}
|
||||||
|
import org.springframework.stereotype.Service
|
||||||
|
@Service
|
||||||
|
{{#operations}}
|
||||||
|
class {{classname}}ServiceImpl : {{classname}}Service {
|
||||||
|
{{#operation}}
|
||||||
|
|
||||||
|
override {{#reactive}}{{^isArray}}suspend {{/isArray}}{{/reactive}}fun {{operationId}}({{#allParams}}{{paramName}}: {{^isBodyParam}}{{>optionalDataType}}{{/isBodyParam}}{{#isBodyParam}}{{^reactive}}{{>optionalDataType}}{{/reactive}}{{#reactive}}{{^isArray}}{{>optionalDataType}}{{/isArray}}{{#isArray}}Flow<{{{baseType}}}>{{/isArray}}{{/reactive}}{{/isBodyParam}}{{^-last}}, {{/-last}}{{/allParams}}): {{>returnTypes}} {
|
||||||
|
TODO("Implement me")
|
||||||
|
}
|
||||||
|
{{/operation}}
|
||||||
|
}
|
||||||
|
{{/operations}}
|
|
@ -0,0 +1,53 @@
|
||||||
|
package {{basePackage}}
|
||||||
|
|
||||||
|
import org.springframework.context.annotation.Bean
|
||||||
|
import org.springframework.context.annotation.Configuration
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.models.OpenAPI
|
||||||
|
import io.swagger.v3.oas.models.info.Info
|
||||||
|
import io.swagger.v3.oas.models.info.Contact
|
||||||
|
import io.swagger.v3.oas.models.info.License
|
||||||
|
import io.swagger.v3.oas.models.Components
|
||||||
|
import io.swagger.v3.oas.models.security.SecurityScheme
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
class SpringDocConfiguration {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
fun apiInfo(): OpenAPI {
|
||||||
|
return OpenAPI()
|
||||||
|
.info(
|
||||||
|
Info(){{#appName}}
|
||||||
|
.title("{{appName}}"){{/appName}}
|
||||||
|
.description("{{{appDescription}}}"){{#termsOfService}}
|
||||||
|
.termsOfService("{{termsOfService}}"){{/termsOfService}}{{#openAPI}}{{#info}}{{#contact}}
|
||||||
|
.contact(
|
||||||
|
Contact(){{#infoName}}
|
||||||
|
.name("{{infoName}}"){{/infoName}}{{#infoUrl}}
|
||||||
|
.url("{{infoUrl}}"){{/infoUrl}}{{#infoEmail}}
|
||||||
|
.email("{{infoEmail}}"){{/infoEmail}}
|
||||||
|
){{/contact}}{{#license}}
|
||||||
|
.license(
|
||||||
|
License()
|
||||||
|
{{#licenseInfo}}.name("{{licenseInfo}}")
|
||||||
|
{{/licenseInfo}}{{#licenseUrl}}.url("{{licenseUrl}}")
|
||||||
|
{{/licenseUrl}}
|
||||||
|
){{/license}}{{/info}}{{/openAPI}}
|
||||||
|
.version("{{appVersion}}")
|
||||||
|
){{#hasAuthMethods}}
|
||||||
|
.components(
|
||||||
|
Components(){{#authMethods}}
|
||||||
|
.addSecuritySchemes("{{name}}", SecurityScheme(){{#isBasic}}
|
||||||
|
.type(SecurityScheme.Type.HTTP)
|
||||||
|
.scheme("{{scheme}}"){{#bearerFormat}}
|
||||||
|
.bearerFormat("{{bearerFormat}}"){{/bearerFormat}}{{/isBasic}}{{#isApiKey}}
|
||||||
|
.type(SecurityScheme.Type.APIKEY){{#isKeyInHeader}}
|
||||||
|
.`in`(SecurityScheme.In.HEADER){{/isKeyInHeader}}{{#isKeyInQuery}}
|
||||||
|
.`in`(SecurityScheme.In.QUERY){{/isKeyInQuery}}{{#isKeyInCookie}}
|
||||||
|
.`in`(SecurityScheme.In.COOKIE){{/isKeyInCookie}}
|
||||||
|
.name("{{keyParamName}}"){{/isApiKey}}{{#isOAuth}}
|
||||||
|
.type(SecurityScheme.Type.OAUTH2){{/isOAuth}}
|
||||||
|
){{/authMethods}}
|
||||||
|
){{/hasAuthMethods}}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,66 @@
|
||||||
|
package {{basePackage}}
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Value
|
||||||
|
import org.springframework.context.annotation.Bean
|
||||||
|
import org.springframework.context.annotation.Configuration
|
||||||
|
import org.springframework.web.util.UriComponentsBuilder
|
||||||
|
import springfox.documentation.builders.ApiInfoBuilder
|
||||||
|
import springfox.documentation.builders.RequestHandlerSelectors
|
||||||
|
import springfox.documentation.service.ApiInfo
|
||||||
|
import springfox.documentation.service.Contact
|
||||||
|
import springfox.documentation.spi.DocumentationType
|
||||||
|
import springfox.documentation.spring.web.paths.Paths
|
||||||
|
import springfox.documentation.spring.web.paths.RelativePathProvider
|
||||||
|
import springfox.documentation.spring.web.plugins.Docket
|
||||||
|
import springfox.documentation.swagger2.annotations.EnableSwagger2
|
||||||
|
import {{javaxPackage}}.servlet.ServletContext
|
||||||
|
|
||||||
|
|
||||||
|
{{>generatedAnnotation}}
|
||||||
|
@Configuration
|
||||||
|
@EnableSwagger2
|
||||||
|
class SpringFoxConfiguration {
|
||||||
|
|
||||||
|
fun apiInfo(): ApiInfo {
|
||||||
|
return ApiInfoBuilder()
|
||||||
|
.title("{{appName}}")
|
||||||
|
.description("{{{appDescription}}}")
|
||||||
|
.license("{{licenseInfo}}")
|
||||||
|
.licenseUrl("{{licenseUrl}}")
|
||||||
|
.termsOfServiceUrl("{{infoUrl}}")
|
||||||
|
.version("{{appVersion}}")
|
||||||
|
.contact(Contact("", "", "{{infoEmail}}"))
|
||||||
|
.build()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
{{=<% %>=}}
|
||||||
|
fun customImplementation(servletContext: ServletContext, @Value("\${openapi.<%title%>.base-path:<%>defaultBasePath%>}") basePath: String): Docket {
|
||||||
|
<%={{ }}=%>
|
||||||
|
return Docket(DocumentationType.SWAGGER_2)
|
||||||
|
.select()
|
||||||
|
.apis(RequestHandlerSelectors.basePackage("{{apiPackage}}"))
|
||||||
|
.build()
|
||||||
|
.pathProvider(BasePathAwareRelativePathProvider(servletContext, basePath))
|
||||||
|
.directModelSubstitute(java.time.LocalDate::class.java, java.sql.Date::class.java)
|
||||||
|
.directModelSubstitute(java.time.OffsetDateTime::class.java, java.util.Date::class.java)
|
||||||
|
.apiInfo(apiInfo())
|
||||||
|
}
|
||||||
|
|
||||||
|
class BasePathAwareRelativePathProvider(servletContext: ServletContext, private val basePath: String) :
|
||||||
|
RelativePathProvider(servletContext) {
|
||||||
|
|
||||||
|
override fun applicationPath(): String {
|
||||||
|
return Paths.removeAdjacentForwardSlashes(
|
||||||
|
UriComponentsBuilder.fromPath(super.applicationPath()).path(basePath).build().toString()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getOperationPath(operationPath: String): String {
|
||||||
|
val uriComponentsBuilder = UriComponentsBuilder.fromPath("/")
|
||||||
|
return Paths.removeAdjacentForwardSlashes(
|
||||||
|
uriComponentsBuilder.path(operationPath.replaceFirst("^$basePath", "")).build().toString()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
{{#jackson}}
|
||||||
|
|
||||||
|
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "{{{discriminator.propertyBaseName}}}", visible = true)
|
||||||
|
@JsonSubTypes(
|
||||||
|
{{#discriminator.mappedModels}}
|
||||||
|
JsonSubTypes.Type(value = {{modelName}}::class, name = "{{^vendorExtensions.x-discriminator-value}}{{mappingName}}{{/vendorExtensions.x-discriminator-value}}{{#vendorExtensions.x-discriminator-value}}{{{vendorExtensions.x-discriminator-value}}}{{/vendorExtensions.x-discriminator-value}}"){{^-last}},{{/-last}}
|
||||||
|
{{/discriminator.mappedModels}}
|
||||||
|
){{/jackson}}
|
Loading…
Reference in New Issue