forked from loafle/openapi-generator-original
parent
26ab9e7741
commit
287e8fc69c
@ -440,7 +440,6 @@
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>${lombok.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<repositories>
|
||||
|
@ -22,6 +22,9 @@ import com.samskivert.mustache.Mustache.Lambda;
|
||||
import com.samskivert.mustache.Template;
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.oas.models.Operation;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.openapitools.codegen.CliOption;
|
||||
import org.openapitools.codegen.CodegenConstants;
|
||||
import org.openapitools.codegen.CodegenModel;
|
||||
@ -380,7 +383,7 @@ public class KotlinSpringServerCodegen extends AbstractKotlinCodegen
|
||||
}
|
||||
|
||||
public boolean isAppendRequestToHandler() {
|
||||
return Boolean.parseBoolean(additionalProperties.get(APPEND_REQUEST_TO_HANDLER).toString());
|
||||
return Boolean.parseBoolean(additionalProperties.getOrDefault(APPEND_REQUEST_TO_HANDLER, false).toString());
|
||||
}
|
||||
|
||||
public void setUseSpringBoot3(boolean isSpringBoot3) {
|
||||
@ -906,6 +909,9 @@ public class KotlinSpringServerCodegen extends AbstractKotlinCodegen
|
||||
|
||||
final List<CodegenParameter> allParams = operation.allParams;
|
||||
if (allParams != null) {
|
||||
if (this.isAppendRequestToHandler()) {
|
||||
allParams.add(new RequestCodegenParameter(true));
|
||||
}
|
||||
allParams.forEach(param ->
|
||||
// This is necessary in case 'modelMutable' is enabled,
|
||||
// to prevent Spring Request handlers from being generated with
|
||||
@ -996,4 +1002,11 @@ public class KotlinSpringServerCodegen extends AbstractKotlinCodegen
|
||||
// provides extra protection against improperly trying to import language primitives and java types
|
||||
return !type.startsWith("org.springframework.") && super.needToImport(type);
|
||||
}
|
||||
|
||||
@AllArgsConstructor
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
static class RequestCodegenParameter extends CodegenParameter {
|
||||
boolean isRequestObject;
|
||||
}
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ class {{classname}}Controller({{#serviceInterface}}@Autowired(required = true) v
|
||||
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}}{{#appendRequestToHandler}}, serverHttpRequest: ServerHttpRequest{{/appendRequestToHandler}}): ResponseEntity<{{>returnTypes}}> {
|
||||
{{#reactive}}{{^isArray}}suspend {{/isArray}}{{/reactive}}fun {{operationId}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{>requesObject}}{{^-last}},{{/-last}}{{/allParams}}): ResponseEntity<{{>returnTypes}}> {
|
||||
return {{>returnValue}}
|
||||
}
|
||||
{{/operation}}
|
||||
|
@ -102,7 +102,7 @@ interface {{classname}} {
|
||||
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}}{{#appendRequestToHandler}}, serverHttpRequest: ServerHttpRequest{{/appendRequestToHandler}}): ResponseEntity<{{>returnTypes}}>{{^skipDefaultInterface}} {
|
||||
{{#reactive}}{{^isArray}}suspend {{/isArray}}{{/reactive}}fun {{operationId}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{>requesObject}}{{^-last}},{{/-last}}{{/allParams}}): ResponseEntity<{{>returnTypes}}>{{^skipDefaultInterface}} {
|
||||
{{^isDelegate}}
|
||||
return {{>returnValue}}
|
||||
{{/isDelegate}}
|
||||
|
1
modules/openapi-generator/src/main/resources/kotlin-spring/requesObject.mustache
vendored
Normal file
1
modules/openapi-generator/src/main/resources/kotlin-spring/requesObject.mustache
vendored
Normal file
@ -0,0 +1 @@
|
||||
{{#isRequestObject}}serverHttpRequest: ServerHttpRequest{{/isRequestObject}}
|
@ -54,7 +54,7 @@ interface PetApi {
|
||||
value = ["/pet"],
|
||||
consumes = ["application/json", "application/xml"]
|
||||
)
|
||||
fun addPet(@Parameter(description = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody body: Pet, serverHttpRequest: ServerHttpRequest): ResponseEntity<Unit> {
|
||||
fun addPet(@Parameter(description = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody body: Pet,serverHttpRequest: ServerHttpRequest): ResponseEntity<Unit> {
|
||||
return ResponseEntity(HttpStatus.NOT_IMPLEMENTED)
|
||||
}
|
||||
|
||||
@ -72,7 +72,7 @@ interface PetApi {
|
||||
method = [RequestMethod.DELETE],
|
||||
value = ["/pet/{petId}"]
|
||||
)
|
||||
fun deletePet(@Parameter(description = "Pet id to delete", required = true) @PathVariable("petId") petId: kotlin.Long,@Parameter(description = "", `in` = ParameterIn.HEADER) @RequestHeader(value = "api_key", required = false) apiKey: kotlin.String?, serverHttpRequest: ServerHttpRequest): ResponseEntity<Unit> {
|
||||
fun deletePet(@Parameter(description = "Pet id to delete", required = true) @PathVariable("petId") petId: kotlin.Long,@Parameter(description = "", `in` = ParameterIn.HEADER) @RequestHeader(value = "api_key", required = false) apiKey: kotlin.String?,serverHttpRequest: ServerHttpRequest): ResponseEntity<Unit> {
|
||||
return ResponseEntity(HttpStatus.NOT_IMPLEMENTED)
|
||||
}
|
||||
|
||||
@ -92,7 +92,7 @@ interface PetApi {
|
||||
value = ["/pet/findByStatus"],
|
||||
produces = ["application/xml", "application/json"]
|
||||
)
|
||||
fun findPetsByStatus(@NotNull @Parameter(description = "Status values that need to be considered for filter", required = true, schema = Schema(allowableValues = ["available", "pending", "sold"])) @Valid @RequestParam(value = "status", required = true) status: kotlin.collections.List<kotlin.String>, serverHttpRequest: ServerHttpRequest): ResponseEntity<List<Pet>> {
|
||||
fun findPetsByStatus(@NotNull @Parameter(description = "Status values that need to be considered for filter", required = true, schema = Schema(allowableValues = ["available", "pending", "sold"])) @Valid @RequestParam(value = "status", required = true) status: kotlin.collections.List<kotlin.String>,serverHttpRequest: ServerHttpRequest): ResponseEntity<List<Pet>> {
|
||||
return ResponseEntity(HttpStatus.NOT_IMPLEMENTED)
|
||||
}
|
||||
|
||||
@ -112,7 +112,7 @@ interface PetApi {
|
||||
value = ["/pet/findByTags"],
|
||||
produces = ["application/xml", "application/json"]
|
||||
)
|
||||
fun findPetsByTags(@NotNull @Parameter(description = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) tags: kotlin.collections.List<kotlin.String>, serverHttpRequest: ServerHttpRequest): ResponseEntity<List<Pet>> {
|
||||
fun findPetsByTags(@NotNull @Parameter(description = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) tags: kotlin.collections.List<kotlin.String>,serverHttpRequest: ServerHttpRequest): ResponseEntity<List<Pet>> {
|
||||
return ResponseEntity(HttpStatus.NOT_IMPLEMENTED)
|
||||
}
|
||||
|
||||
@ -133,7 +133,7 @@ interface PetApi {
|
||||
value = ["/pet/{petId}"],
|
||||
produces = ["application/xml", "application/json"]
|
||||
)
|
||||
fun getPetById(@Parameter(description = "ID of pet to return", required = true) @PathVariable("petId") petId: kotlin.Long, serverHttpRequest: ServerHttpRequest): ResponseEntity<Pet> {
|
||||
fun getPetById(@Parameter(description = "ID of pet to return", required = true) @PathVariable("petId") petId: kotlin.Long,serverHttpRequest: ServerHttpRequest): ResponseEntity<Pet> {
|
||||
return ResponseEntity(HttpStatus.NOT_IMPLEMENTED)
|
||||
}
|
||||
|
||||
@ -154,7 +154,7 @@ interface PetApi {
|
||||
value = ["/pet"],
|
||||
consumes = ["application/json", "application/xml"]
|
||||
)
|
||||
fun updatePet(@Parameter(description = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody body: Pet, serverHttpRequest: ServerHttpRequest): ResponseEntity<Unit> {
|
||||
fun updatePet(@Parameter(description = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody body: Pet,serverHttpRequest: ServerHttpRequest): ResponseEntity<Unit> {
|
||||
return ResponseEntity(HttpStatus.NOT_IMPLEMENTED)
|
||||
}
|
||||
|
||||
@ -173,7 +173,7 @@ interface PetApi {
|
||||
value = ["/pet/{petId}"],
|
||||
consumes = ["application/x-www-form-urlencoded"]
|
||||
)
|
||||
fun updatePetWithForm(@Parameter(description = "ID of pet that needs to be updated", required = true) @PathVariable("petId") petId: kotlin.Long,@Parameter(description = "Updated name of the pet") @RequestParam(value = "name", required = false) name: kotlin.String? ,@Parameter(description = "Updated status of the pet") @RequestParam(value = "status", required = false) status: kotlin.String? , serverHttpRequest: ServerHttpRequest): ResponseEntity<Unit> {
|
||||
fun updatePetWithForm(@Parameter(description = "ID of pet that needs to be updated", required = true) @PathVariable("petId") petId: kotlin.Long,@Parameter(description = "Updated name of the pet") @RequestParam(value = "name", required = false) name: kotlin.String? ,@Parameter(description = "Updated status of the pet") @RequestParam(value = "status", required = false) status: kotlin.String? ,serverHttpRequest: ServerHttpRequest): ResponseEntity<Unit> {
|
||||
return ResponseEntity(HttpStatus.NOT_IMPLEMENTED)
|
||||
}
|
||||
|
||||
@ -193,7 +193,7 @@ interface PetApi {
|
||||
produces = ["application/json"],
|
||||
consumes = ["multipart/form-data"]
|
||||
)
|
||||
fun uploadFile(@Parameter(description = "ID of pet to update", required = true) @PathVariable("petId") petId: kotlin.Long,@Parameter(description = "Additional data to pass to server") @RequestParam(value = "additionalMetadata", required = false) additionalMetadata: kotlin.String? ,@Parameter(description = "file detail") @Valid @RequestPart("file") file: org.springframework.core.io.Resource?, serverHttpRequest: ServerHttpRequest): ResponseEntity<ModelApiResponse> {
|
||||
fun uploadFile(@Parameter(description = "ID of pet to update", required = true) @PathVariable("petId") petId: kotlin.Long,@Parameter(description = "Additional data to pass to server") @RequestParam(value = "additionalMetadata", required = false) additionalMetadata: kotlin.String? ,@Parameter(description = "file detail") @Valid @RequestPart("file") file: org.springframework.core.io.Resource?,serverHttpRequest: ServerHttpRequest): ResponseEntity<ModelApiResponse> {
|
||||
return ResponseEntity(HttpStatus.NOT_IMPLEMENTED)
|
||||
}
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ interface StoreApi {
|
||||
method = [RequestMethod.DELETE],
|
||||
value = ["/store/order/{orderId}"]
|
||||
)
|
||||
fun deleteOrder(@Parameter(description = "ID of the order that needs to be deleted", required = true) @PathVariable("orderId") orderId: kotlin.String, serverHttpRequest: ServerHttpRequest): ResponseEntity<Unit> {
|
||||
fun deleteOrder(@Parameter(description = "ID of the order that needs to be deleted", required = true) @PathVariable("orderId") orderId: kotlin.String,serverHttpRequest: ServerHttpRequest): ResponseEntity<Unit> {
|
||||
return ResponseEntity(HttpStatus.NOT_IMPLEMENTED)
|
||||
}
|
||||
|
||||
@ -71,7 +71,7 @@ interface StoreApi {
|
||||
value = ["/store/inventory"],
|
||||
produces = ["application/json"]
|
||||
)
|
||||
fun getInventory(, serverHttpRequest: ServerHttpRequest): ResponseEntity<Map<String, kotlin.Int>> {
|
||||
fun getInventory(serverHttpRequest: ServerHttpRequest): ResponseEntity<Map<String, kotlin.Int>> {
|
||||
return ResponseEntity(HttpStatus.NOT_IMPLEMENTED)
|
||||
}
|
||||
|
||||
@ -91,7 +91,7 @@ interface StoreApi {
|
||||
value = ["/store/order/{orderId}"],
|
||||
produces = ["application/xml", "application/json"]
|
||||
)
|
||||
fun getOrderById(@Min(1L) @Max(5L) @Parameter(description = "ID of pet that needs to be fetched", required = true) @PathVariable("orderId") orderId: kotlin.Long, serverHttpRequest: ServerHttpRequest): ResponseEntity<Order> {
|
||||
fun getOrderById(@Min(1L) @Max(5L) @Parameter(description = "ID of pet that needs to be fetched", required = true) @PathVariable("orderId") orderId: kotlin.Long,serverHttpRequest: ServerHttpRequest): ResponseEntity<Order> {
|
||||
return ResponseEntity(HttpStatus.NOT_IMPLEMENTED)
|
||||
}
|
||||
|
||||
@ -110,7 +110,7 @@ interface StoreApi {
|
||||
value = ["/store/order"],
|
||||
produces = ["application/xml", "application/json"]
|
||||
)
|
||||
fun placeOrder(@Parameter(description = "order placed for purchasing the pet", required = true) @Valid @RequestBody body: Order, serverHttpRequest: ServerHttpRequest): ResponseEntity<Order> {
|
||||
fun placeOrder(@Parameter(description = "order placed for purchasing the pet", required = true) @Valid @RequestBody body: Order,serverHttpRequest: ServerHttpRequest): ResponseEntity<Order> {
|
||||
return ResponseEntity(HttpStatus.NOT_IMPLEMENTED)
|
||||
}
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ interface UserApi {
|
||||
method = [RequestMethod.POST],
|
||||
value = ["/user"]
|
||||
)
|
||||
fun createUser(@Parameter(description = "Created user object", required = true) @Valid @RequestBody body: User, serverHttpRequest: ServerHttpRequest): ResponseEntity<Unit> {
|
||||
fun createUser(@Parameter(description = "Created user object", required = true) @Valid @RequestBody body: User,serverHttpRequest: ServerHttpRequest): ResponseEntity<Unit> {
|
||||
return ResponseEntity(HttpStatus.NOT_IMPLEMENTED)
|
||||
}
|
||||
|
||||
@ -68,7 +68,7 @@ interface UserApi {
|
||||
method = [RequestMethod.POST],
|
||||
value = ["/user/createWithArray"]
|
||||
)
|
||||
fun createUsersWithArrayInput(@Parameter(description = "List of user object", required = true) @Valid @RequestBody body: kotlin.collections.List<User>, serverHttpRequest: ServerHttpRequest): ResponseEntity<Unit> {
|
||||
fun createUsersWithArrayInput(@Parameter(description = "List of user object", required = true) @Valid @RequestBody body: kotlin.collections.List<User>,serverHttpRequest: ServerHttpRequest): ResponseEntity<Unit> {
|
||||
return ResponseEntity(HttpStatus.NOT_IMPLEMENTED)
|
||||
}
|
||||
|
||||
@ -85,7 +85,7 @@ interface UserApi {
|
||||
method = [RequestMethod.POST],
|
||||
value = ["/user/createWithList"]
|
||||
)
|
||||
fun createUsersWithListInput(@Parameter(description = "List of user object", required = true) @Valid @RequestBody body: kotlin.collections.List<User>, serverHttpRequest: ServerHttpRequest): ResponseEntity<Unit> {
|
||||
fun createUsersWithListInput(@Parameter(description = "List of user object", required = true) @Valid @RequestBody body: kotlin.collections.List<User>,serverHttpRequest: ServerHttpRequest): ResponseEntity<Unit> {
|
||||
return ResponseEntity(HttpStatus.NOT_IMPLEMENTED)
|
||||
}
|
||||
|
||||
@ -103,7 +103,7 @@ interface UserApi {
|
||||
method = [RequestMethod.DELETE],
|
||||
value = ["/user/{username}"]
|
||||
)
|
||||
fun deleteUser(@Parameter(description = "The name that needs to be deleted", required = true) @PathVariable("username") username: kotlin.String, serverHttpRequest: ServerHttpRequest): ResponseEntity<Unit> {
|
||||
fun deleteUser(@Parameter(description = "The name that needs to be deleted", required = true) @PathVariable("username") username: kotlin.String,serverHttpRequest: ServerHttpRequest): ResponseEntity<Unit> {
|
||||
return ResponseEntity(HttpStatus.NOT_IMPLEMENTED)
|
||||
}
|
||||
|
||||
@ -123,7 +123,7 @@ interface UserApi {
|
||||
value = ["/user/{username}"],
|
||||
produces = ["application/xml", "application/json"]
|
||||
)
|
||||
fun getUserByName(@Parameter(description = "The name that needs to be fetched. Use user1 for testing.", required = true) @PathVariable("username") username: kotlin.String, serverHttpRequest: ServerHttpRequest): ResponseEntity<User> {
|
||||
fun getUserByName(@Parameter(description = "The name that needs to be fetched. Use user1 for testing.", required = true) @PathVariable("username") username: kotlin.String,serverHttpRequest: ServerHttpRequest): ResponseEntity<User> {
|
||||
return ResponseEntity(HttpStatus.NOT_IMPLEMENTED)
|
||||
}
|
||||
|
||||
@ -142,7 +142,7 @@ interface UserApi {
|
||||
value = ["/user/login"],
|
||||
produces = ["application/xml", "application/json"]
|
||||
)
|
||||
fun loginUser(@NotNull @Parameter(description = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) username: kotlin.String,@NotNull @Parameter(description = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) password: kotlin.String, serverHttpRequest: ServerHttpRequest): ResponseEntity<kotlin.String> {
|
||||
fun loginUser(@NotNull @Parameter(description = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) username: kotlin.String,@NotNull @Parameter(description = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) password: kotlin.String,serverHttpRequest: ServerHttpRequest): ResponseEntity<kotlin.String> {
|
||||
return ResponseEntity(HttpStatus.NOT_IMPLEMENTED)
|
||||
}
|
||||
|
||||
@ -159,7 +159,7 @@ interface UserApi {
|
||||
method = [RequestMethod.GET],
|
||||
value = ["/user/logout"]
|
||||
)
|
||||
fun logoutUser(, serverHttpRequest: ServerHttpRequest): ResponseEntity<Unit> {
|
||||
fun logoutUser(serverHttpRequest: ServerHttpRequest): ResponseEntity<Unit> {
|
||||
return ResponseEntity(HttpStatus.NOT_IMPLEMENTED)
|
||||
}
|
||||
|
||||
@ -177,7 +177,7 @@ interface UserApi {
|
||||
method = [RequestMethod.PUT],
|
||||
value = ["/user/{username}"]
|
||||
)
|
||||
fun updateUser(@Parameter(description = "name that need to be deleted", required = true) @PathVariable("username") username: kotlin.String,@Parameter(description = "Updated user object", required = true) @Valid @RequestBody body: User, serverHttpRequest: ServerHttpRequest): ResponseEntity<Unit> {
|
||||
fun updateUser(@Parameter(description = "name that need to be deleted", required = true) @PathVariable("username") username: kotlin.String,@Parameter(description = "Updated user object", required = true) @Valid @RequestBody body: User,serverHttpRequest: ServerHttpRequest): ResponseEntity<Unit> {
|
||||
return ResponseEntity(HttpStatus.NOT_IMPLEMENTED)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user