forked from OpenAPITools/openapi-generator
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[KOTLIN Spring] add interfaceOnly option (OpenAPITools#3050)
* move template definition to processOpts() * add interfaceOnly option for kotlin-spring * add template for interface only option
- Loading branch information
1 parent
325ed4b
commit 73966a0
Showing
12 changed files
with
430 additions
and
371 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
modules/openapi-generator/src/main/resources/kotlin-spring/apiInterface.mustache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
package {{package}} | ||
|
||
{{#imports}}import {{import}} | ||
{{/imports}} | ||
{{#swaggerAnnotations}} | ||
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 | ||
{{/swaggerAnnotations}} | ||
import org.springframework.http.HttpStatus | ||
import org.springframework.http.MediaType | ||
import org.springframework.http.ResponseEntity | ||
import org.springframework.stereotype.Controller | ||
import org.springframework.web.bind.annotation.RequestBody | ||
import org.springframework.web.bind.annotation.RequestPart | ||
import org.springframework.web.bind.annotation.RequestParam | ||
import org.springframework.web.bind.annotation.PathVariable | ||
import org.springframework.web.bind.annotation.RequestHeader | ||
import org.springframework.web.bind.annotation.RequestMethod | ||
import org.springframework.web.bind.annotation.RequestMapping | ||
{{#useBeanValidation}} | ||
import org.springframework.validation.annotation.Validated | ||
{{/useBeanValidation}} | ||
import org.springframework.web.context.request.NativeWebRequest | ||
import org.springframework.beans.factory.annotation.Autowired | ||
|
||
{{#useBeanValidation}} | ||
import javax.validation.Valid | ||
import javax.validation.constraints.DecimalMax | ||
import javax.validation.constraints.DecimalMin | ||
import javax.validation.constraints.Max | ||
import javax.validation.constraints.Min | ||
import javax.validation.constraints.NotNull | ||
import javax.validation.constraints.Pattern | ||
import javax.validation.constraints.Size | ||
{{/useBeanValidation}} | ||
|
||
{{#reactive}} | ||
import kotlinx.coroutines.flow.Flow; | ||
{{/reactive}} | ||
import kotlin.collections.List | ||
import kotlin.collections.Map | ||
|
||
{{#useBeanValidation}} | ||
@Validated | ||
{{/useBeanValidation}} | ||
{{#swaggerAnnotations}} | ||
@Api(value = "{{{baseName}}}", description = "The {{{baseName}}} API") | ||
{{/swaggerAnnotations}} | ||
{{=<% %>=}} | ||
@RequestMapping("\${api.base-path:<%contextPath%>}") | ||
<%={{ }}=%> | ||
{{#operations}} | ||
interface {{classname}} { | ||
{{#operation}} | ||
|
||
{{#swaggerAnnotations}} | ||
@ApiOperation( | ||
value = "{{{summary}}}", | ||
nickname = "{{{operationId}}}", | ||
notes = "{{{notes}}}"{{#returnBaseType}}, | ||
response = {{{returnBaseType}}}::class{{/returnBaseType}}{{#returnContainer}}, | ||
responseContainer = "{{{returnContainer}}}"{{/returnContainer}}{{#hasAuthMethods}}, | ||
authorizations = [{{#authMethods}}Authorization(value = "{{name}}"{{#isOAuth}}, scopes = [{{#scopes}}AuthorizationScope(scope = "{{scope}}", description = "{{description}}"){{#hasMore}}, {{/hasMore}}{{/scopes}}]{{/isOAuth}}){{#hasMore}}, {{/hasMore}}{{/authMethods}}]{{/hasAuthMethods}}) | ||
@ApiResponses( | ||
value = [{{#responses}}ApiResponse(code = {{{code}}}, message = "{{{message}}}"{{#baseType}}, response = {{{baseType}}}::class{{/baseType}}{{#containerType}}, responseContainer = "{{{containerType}}}"{{/containerType}}){{#hasMore}},{{/hasMore}}{{/responses}}]){{/swaggerAnnotations}} | ||
@RequestMapping( | ||
value = ["{{#lambda.escapeDoubleQuote}}{{path}}{{/lambda.escapeDoubleQuote}}"],{{#singleContentTypes}}{{#hasProduces}} | ||
produces = "{{{vendorExtensions.x-accepts}}}",{{/hasProduces}}{{#hasConsumes}} | ||
consumes = "{{{vendorExtensions.x-contentType}}}",{{/hasConsumes}}{{/singleContentTypes}}{{^singleContentTypes}}{{#hasProduces}} | ||
produces = [{{#produces}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/produces}}], {{/hasProduces}}{{#hasConsumes}} | ||
consumes = [{{#consumes}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/consumes}}],{{/hasConsumes}}{{/singleContentTypes}} | ||
method = [RequestMethod.{{httpMethod}}]) | ||
{{#reactive}}{{^isListContainer}}suspend {{/isListContainer}}{{/reactive}}fun {{operationId}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}},{{/hasMore}}{{/allParams}}): ResponseEntity<{{>returnTypes}}> { | ||
return {{>returnValue}} | ||
} | ||
{{/operation}} | ||
} | ||
{{/operations}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.