Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #10679
Closed
Open
Issue created Oct 24, 2021 by Administrator@rootContributor4 of 6 checklist items completed4/6 checklist items

[BUG] [Kotlin] [Gradle Plugin] ApiKeyAuth is not generated under jvm-retrofit2 when no "oauth2" security scheme is present in the spec

Created by: NightEule5

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

When using the Gradle plugin to generation Kotlin code under the jvm-retrofit2 library type, ApiKeyAuth doesn't generate causing compilation to fail. The class is referenced in ApiClient here:

constructor(
    baseUrl: String = defaultBasePath,
    okHttpClientBuilder: OkHttpClient.Builder? = null,
    serializerBuilder: Moshi.Builder = Serializer.moshiBuilder,
    authNames: Array<String>
) : this(baseUrl, okHttpClientBuilder, serializerBuilder) {
    authNames.forEach { authName ->
        val auth = when (authName) {
            "TokenAuth" -> ApiKeyAuth("header", "Authorization")
            else -> throw RuntimeException("auth name $authName not found in available auth names")
        }
        addAuthorization(authName, auth);
    }
}
openapi-generator version

I've tested this on plugin versions 5.1.1, 5.2.1, and 5.3.0.

OpenAPI declaration file content or url

The spec I'm using can be found here.

Generation Details
generatorName: kotlin
outputDir: out
library: jvm-retrofit2
inputSpec: modrinth.yaml
Steps to reproduce

I've attached a minimal project that reproduces the bug:

OpenAPIBugReproduction.zip

Related issues/PRs

Might be related to this issue #8147.

Assignee
Assign to
Time tracking