-
Notifications
You must be signed in to change notification settings - Fork 43
Closed
Description
Problem
Let's say I want to obtain cookie security scheme like in OpenSpec example
openapi: 3.0.0
...
# 1) Define the cookie name
components:
securitySchemes:
cookieAuth: # arbitrary name for the security scheme; will be used in the "security" key later
type: apiKey
in: cookie
name: JSESSIONID # cookie name
# 2) Apply cookie auth globally to all operations
security:
- cookieAuth: []
If I'll create such description with the code:
AuthProvider.Security(
SecuritySchemeModel(
SecuritySchemeType.apiKey,
`in` = APIKeyLocation.cookie,
name = "JSESSIONID",
),
emptyList<Scopes>()
)
It will create such definition in swagger:
"JSESSIONID": {
"in": "cookie",
"type": "apiKey"
},
As you see there is no name
field inside security scheme, which make spec invalid.
Expected
At least name should appear INSIDE security scheme as well for spec to be valid.
"JSESSIONID": {
"in": "cookie",
"type": "apiKey",
"name": "JSESSIONID",
},
Research
The problem is in these lines of code
Lines 21 to 23 in f7e7048
return this::class.memberProperties.associateBy { it.name }.mapValues<String, KProperty1<out SecuritySchemeModel<TScope>, Any?>, Any?> { (_, prop) -> | |
convertToValue((prop as KProperty1<DataModel, *>).get(this)) | |
}.filter { it.key != "name" }.cleanEmptyValues() |
First of all, it uses name
field as security scheme reference name
Second, it strips name
field from serializing to resulted spec.
Therefore there is no way to set up name
field, and current name
field is used as security scheme arbitrary reference name.
Proposal
Add another field to separate reference name from name
field
Metadata
Metadata
Assignees
Labels
No labels