Skip to content

Commit

Permalink
chore: update generation customizations to use latest generator tag (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
anssari1 authored Oct 10, 2024
1 parent 3efe43f commit 66190aa
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/generate-and-publish-sdk-sources.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ on:

jobs:
generate-and-publish-sources:
uses: ExpediaGroup/expediagroup-java-sdk/.github/workflows/selfserve-full-workflow.yaml@main
uses: ExpediaGroup/expediagroup-java-sdk/.github/workflows/selfserve-full-workflow.yaml@v20241009
secrets: inherit
with:
name: rapid
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class OpenApiSdkGenerator {
addGlobalProperty(CodegenConstants.MODELS, "")
addGlobalProperty(CodegenConstants.MODEL_DOCS, "false")

supportingFiles.add("${namespace}Client.kt")
supportingFiles.add("${namespace.pascalCase()}Client.kt")
addGlobalProperty(CodegenConstants.SUPPORTING_FILES, supportingFiles.joinToString(","))
// addGlobalProperty("debugSupportingFiles", "")

Expand Down Expand Up @@ -135,7 +135,7 @@ class OpenApiSdkGenerator {
SupportingFile(
"client.mustache",
"$packagePath/client/",
"${namespace}Client.kt"
"${namespace.pascalCase()}Client.kt"
)
)
add(SupportingFile("pom.mustache", "pom.xml"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ class {{clientClassname}}Client private constructor(clientConfiguration: RapidCl
method = HttpMethod.parse(operation.method)
url(operation.url)
operation.params?.getHeaders()?.forEach { (key, value) ->
headers.append(key, value)
operation.params?.getHeaders()?.let {
headers.appendAll(it)
}

operation.params?.getQueryParams()?.forEach { (key, value) ->
url.parameters.appendAll(key, value)
operation.params?.getQueryParams()?.let {
url.parameters.appendAll(it)
}

val extraHeaders = buildMap {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import com.expediagroup.sdk.core.model.OperationParams
import com.fasterxml.jackson.annotation.JsonProperty
import com.fasterxml.jackson.databind.annotation.JsonDeserialize
import io.ktor.http.Headers
import io.ktor.http.Parameters

/**
{{#nonBodyParams}}
Expand Down Expand Up @@ -135,34 +137,39 @@
{{/hasRequiredParams}}
}

override fun getHeaders(): Map<String, String> {
return buildMap {
fun toBuilder() = Builder(
{{#nonBodyParams}}
{{#params}}
{{{paramName}}} = {{{paramName}}}{{^-last}},{{/-last}}
{{/params}}
{{/nonBodyParams}}
)

override fun getHeaders(): Headers {
return Headers.build {
{{#headerParams}}
{{paramName}}?.also {
put("{{baseName}}", {{paramName}}{{#isEnum}}.value{{/isEnum}})
{{paramName}}?.let {
append("{{baseName}}", it{{#isEnum}}.value{{/isEnum}})
}
{{/headerParams}}
{{#responses}}
{{#httpAcceptHeader}}
put("Accept", "{{mediaTypes}}")
append("Accept", "{{mediaTypes}}")
{{/httpAcceptHeader}}
{{/responses}}
}
}

override fun getQueryParams(): Map<String, Iterable<String>> {
return buildMap {
override fun getQueryParams(): Parameters {
return Parameters.build {
{{#queryParams}}
{{paramName}}?.also {
put(
"{{baseName}}",
{{#isContainer}}
{{paramName}}{{#isEnum}}.map { it.value }{{/isEnum}}
{{/isContainer}}
{{^isContainer}}
listOf({{paramName}}{{#isEnum}}.value{{/isEnum}}{{^isString}}.toString(){{/isString}})
{{/isContainer}}
)
{{paramName}}?.let {
{{#isContainer}}
appendAll("{{baseName}}", it{{#isEnum}}.map { it.value }{{/isEnum}})
{{/isContainer}}
{{^isContainer}}
append("{{baseName}}", it{{#isEnum}}.value{{/isEnum}}{{^isString}}.toString(){{/isString}})
{{/isContainer}}
}
{{/queryParams}}
}
Expand Down

0 comments on commit 66190aa

Please sign in to comment.