Skip to content

[BUG] Support for cookie-based security schemas in Kotlin clients #10008

@puneetugru

Description

@puneetugru

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

While trying to generate Kotlin Client code for cookie-based security schema with OpenAPI Spec version 3.0.0, the below lines were seen in the ApiClient.kt file.

constructor(
        baseUrl: String = defaultBasePath,
        okHttpClientBuilder: OkHttpClient.Builder? = null,
        serializerBuilder: GsonBuilder = Serializer.gsonBuilder,
        authNames: Array<String>
    ) : this(baseUrl, okHttpClientBuilder, serializerBuilder) {
        authNames.forEach { authName ->
            val auth = when (authName) {
                "cookieAuth" -> ApiKeyAuth("cookie", "sess")
                else -> throw RuntimeException("auth name $authName not found in available auth names")
            }
            addAuthorization(authName, auth);
        }
    }
    

But, the file ApiKeyAuth.kt was not found in the generated code.

openapi-generator version

5.2.0

OpenAPI declaration file content or url

https://gist.github.com/puneetugru/ec65183b4ad2da3ee8a7b43def2eea4a

Generation Details

openapi-generator generate -i TestCookieAuthInAPI.yaml -g kotlin -c config_android.json

Steps to reproduce
  1. Create a config file like below to put the Kotlin client code in a required directory and use some required libraries, called as config_android.json.
{
    "packageName": "com.test",
    "serializationLibrary": "gson",
    "sourceFolder": "src/main/java",
    "library": "jvm-retrofit2"
}
  1. Run the command, openapi-generator generate -i TestCookieAuthInAPI.yaml -g kotlin -c config_android.json
Related issues/PRs

None

Suggest a fix

None

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions