Skip to content

Commit

Permalink
[Kotlin Server] Use query parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
Stexxe committed Dec 11, 2024
1 parent c345e6a commit 7198f71
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,13 @@ public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<Mo
if (operations != null && !Objects.equals(library, Constants.JAXRS_SPEC)) {
List<CodegenOperation> ops = operations.getOperation();
ops.forEach(operation -> {
if (isKtor()) {
ArrayList<CodegenParameter> params = new ArrayList<>();
params.addAll(operation.pathParams);
params.addAll(operation.queryParams);
operation.vendorExtensions.put("ktor-params", params);
}

List<CodegenResponse> responses = operation.responses;
if (responses != null) {
responses.forEach(resp -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ object Paths {
{{#allParams}}* @param {{paramName}} {{description}} {{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}}
{{/allParams}}*/
{{#hasParams}}
@Resource("{{{path}}}") class {{operationId}}({{#pathParams}}val {{paramName}}: {{{dataType}}}{{^required}}? = null{{/required}}{{#required}}{{#isNullable}}?{{/isNullable}}{{/required}}{{^-last}}, {{/-last}}{{/pathParams}})
@Resource("{{{path}}}") class {{operationId}}({{#vendorExtensions.ktor-params}}val {{paramName}}: {{{dataType}}}{{^required}}? = null{{/required}}{{#required}}{{#isNullable}}?{{/isNullable}}{{/required}}{{^-last}}, {{/-last}}{{/vendorExtensions.ktor-params}})
{{/hasParams}}
{{^hasParams}}
@Resource("{{{path}}}") class {{operationId}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ object Paths {
* Multiple status values can be provided with comma separated strings
* @param status Status values that need to be considered for filter
*/
@Resource("/pet/findByStatus") class findPetsByStatus()
@Resource("/pet/findByStatus") class findPetsByStatus(val status: kotlin.collections.MutableList<kotlin.String>)

/**
* Finds Pets by tags
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
* @param tags Tags to filter by
*/
@Resource("/pet/findByTags") class findPetsByTags()
@Resource("/pet/findByTags") class findPetsByTags(val tags: kotlin.collections.MutableList<kotlin.String>)

/**
* Find pet by ID
Expand Down Expand Up @@ -145,7 +145,7 @@ object Paths {
* @param username The user name for login
* @param password The password for login in clear text
*/
@Resource("/user/login") class loginUser()
@Resource("/user/login") class loginUser(val username: kotlin.String, val password: kotlin.String)

/**
* Logs out current logged in user session
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ object Paths {
* Multiple status values can be provided with comma separated strings
* @param status Status values that need to be considered for filter
*/
@Resource("/pet/findByStatus") class findPetsByStatus()
@Resource("/pet/findByStatus") class findPetsByStatus(val status: kotlin.collections.List<kotlin.String>)

/**
* Finds Pets by tags
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
* @param tags Tags to filter by
*/
@Resource("/pet/findByTags") class findPetsByTags()
@Resource("/pet/findByTags") class findPetsByTags(val tags: kotlin.collections.List<kotlin.String>)

/**
* Find pet by ID
Expand Down Expand Up @@ -145,7 +145,7 @@ object Paths {
* @param username The user name for login
* @param password The password for login in clear text
*/
@Resource("/user/login") class loginUser()
@Resource("/user/login") class loginUser(val username: kotlin.String, val password: kotlin.String)

/**
* Logs out current logged in user session
Expand Down

0 comments on commit 7198f71

Please sign in to comment.