OpenAPI security definition "key" is not transformed
lottamus opened this issue · comments
Chris Lott commented
Describe the bug
The "key" is a very valuable piece of information since most schemes don't have a "name" property. We need to use this property to display information in docs and to address this issue: https://github.com/stoplightio/studio/issues/257
To Reproduce
- Create an OpenAPI file in Studio and add some security schemes
- Grab the active node's data in the console:
__SL.activeProjectStore.studioStore.uiStore.activeNode.children[3].data
- Notice the HttpService doesn't include security scheme's key property
Example OpenAPI V2
{
"swagger": "2.0",
"info": {
"title": "OAS2",
"version": "1.0"
},
"host": "localhost:3000",
"schemes": [
"http"
],
"produces": [
"application/json",
"application/xml"
],
"consumes": [
"application/json"
],
"paths": {
"/path": {
"$ref": "../test-api/openapi.yaml#/paths/~1path"
}
},
"definitions": {
"Embedded-Model": {
"type": "object",
"title": "User",
"enum": [
"foo",
"bar"
],
"properties": {
"foo": {
"type": "object"
}
}
}
},
"securityDefinitions": {
"API Key - 1": {
"type": "oauth2",
"flows": {
"implicit": {
"refreshUrl": "foo",
"scopes": []
},
"clientCredentials": {
"tokenUrl": "",
"refreshUrl": "",
"scopes": []
}
},
"scopes": {
"scope_1": "bar"
},
"flow": "password"
}
}
}
Actual HttpService
{
"id": "?http-service-id?",
"name": "OAS2",
"title": "OAS2",
"version": "1.0",
"servers": [
{
"name": "OAS2",
"url": "http://localhost:3000"
}
],
"tags": [],
"security": [],
"securitySchemes": [
{
"type": "oauth2",
"flows": {
"password": {
"scopes": {
"scope_1": "bar"
}
}
}
}
]
}
Expected HttpService
{
"id": "?http-service-id?",
"name": "OAS2",
"title": "OAS2",
"version": "1.0",
"servers": [
{
"name": "OAS2",
"url": "http://localhost:3000"
}
],
"tags": [],
"security": [],
"securitySchemes": [
{
"key": "API Key - 1",
"type": "oauth2",
"flows": {
"password": {
"scopes": {
"scope_1": "bar"
}
}
}
}
]
}
Additional Context
- Needed by this PR: stoplightio/elements#150
- We should update
ISecurityScheme
to include a key property: https://github.com/stoplightio/types/blob/d2401b0c69c23e5164fe8ce4e811be10958f74ad/src/http-spec.ts#L166
interface ISecurityScheme {
key: string;
description?: string;
}
- We should add a test to make sure the "key" property is being added to both oas2 and oas3 for each scheme type:
- oas3:
- oas2:
Chris Lott commented
Closed with #48