-
-
Notifications
You must be signed in to change notification settings - Fork 21
Description
Actual behavior (the bug)
Generation of security schema, where in parameter is equal to name:
"securitySchemes" : {
"ApiKeyAuth" : {
"in" : "X-API-Key",
"name" : "X-API-Key",
"type" : "apiKey"
}
}Expected behavior
Generation of security schema, where in parameter is equal to header and name remains without any changes:
"securitySchemes" : {
"ApiKeyAuth" : {
"in" : "header",
"name" : "X-API-Key",
"type" : "apiKey"
}
}To Reproduce
Create an openapi schema definition with api key authentication by using withApiKeyAuth method in Java project. It can be workarounded by manually setting in field by consumer provided as third parameter for withApiKeyAuth method.
Additional context
It seems like in Java project the value defined as apiKeyHeader is assigned to in field, which leads to generation of invalid openapi definition.
Lines 109 to 111 in 5e341fe
| @JvmOverloads | |
| fun withApiKeyAuth(schemeName: String = "ApiKeyAuth", apiKeyHeader: String = "X-Api-Key", securityScheme: Consumer<ApiKeyAuth> = Consumer {}): SecurityComponentConfiguration = | |
| withSecurityScheme(schemeName, ApiKeyAuth(apiKeyHeader).also { securityScheme.accept(it) }) |
javalin-openapi/openapi-specification/src/main/kotlin/io/javalin/openapi/Security.kt
Lines 29 to 34 in 5e341fe
| open class ApiKeyAuth( | |
| open var `in`: String = "header", | |
| open var name: String = "X-API-Key" | |
| ) : SecurityScheme { | |
| override val type: String = "apiKey" | |
| } |
Metadata
Metadata
Assignees
Labels
Type
Projects
Status