[BUG] [Kotlin] [Gradle Plugin] ApiKeyAuth is not generated under jvm-retrofit2 when no "oauth2" security scheme is present in the spec
See original GitHub issueBug 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:
Related issues/PRs
Might be related to this issue #8147.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:9 (5 by maintainers)
Top Results From Across the Web
OAuth2 Autoconfig - Spring
This project is a port of the Spring Security OAuth support that came with Spring Boot 1.x. Support was removed in favor of...
Read more >Gen 8.6 Consuming REST APIs: Security
The goal of this document is to show you how to implement REST API security schemes using existing functionality. We will illustrate how...
Read more >Using OAuth2 RBAC - Quarkus
This extension provides a light-weight support for using the opaque Bearer Tokens and validating them by calling an introspection endpoint. If the OAuth2...
Read more >Authentication - Swagger
In the following example, the API calls can be authenticated using either an API key or OAuth 2. The ApiKeyAuth and OAuth2 names...
Read more >Using Spring Boot for OAuth2 and JWT REST Protection - Toptal
Let's take a quick look at Spring Security architecture (a more detailed guide can be found here). Security is mostly about authentication, i.e....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I did find the problem and submitted a fix
I don’t have idea why the one class is not being generated, the samples here on github do include a package “auth” with that class inside.