mirror of
https://github.com/LukeHagar/redocly-cli.git
synced 2025-12-06 12:47:48 +00:00
fix: join command security schemas fix (#1439)
This commit is contained in:
5
.changeset/little-camels-fold.md
Normal file
5
.changeset/little-camels-fold.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@redocly/cli": patch
|
||||
---
|
||||
|
||||
Adds support for using logical AND for the security schema so that the `join` command generates the correct schema.
|
||||
@@ -19,7 +19,11 @@ paths:
|
||||
responses:
|
||||
'201':
|
||||
description: example description
|
||||
|
||||
security:
|
||||
- scheme1: []
|
||||
scheme2: []
|
||||
- scheme3: []
|
||||
scheme4: []
|
||||
components:
|
||||
schemas:
|
||||
some-property:
|
||||
|
||||
@@ -27,7 +27,11 @@ paths:
|
||||
responses:
|
||||
'200':
|
||||
description: example description
|
||||
|
||||
security:
|
||||
- scheme1: []
|
||||
scheme2: []
|
||||
scheme3: []
|
||||
scheme4: []
|
||||
components:
|
||||
schemas:
|
||||
some-property:
|
||||
|
||||
@@ -39,6 +39,11 @@ paths:
|
||||
responses:
|
||||
'200':
|
||||
description: example description
|
||||
security:
|
||||
- Foo Example OpenAPI 3 definition foo._scheme1: []
|
||||
Foo Example OpenAPI 3 definition foo._scheme2: []
|
||||
Foo Example OpenAPI 3 definition foo._scheme3: []
|
||||
Foo Example OpenAPI 3 definition foo._scheme4: []
|
||||
tags:
|
||||
- foo_other
|
||||
/pets/{petId}:
|
||||
@@ -48,6 +53,11 @@ paths:
|
||||
responses:
|
||||
'201':
|
||||
description: example description
|
||||
security:
|
||||
- Bar Example OpenAPI 3 definition._scheme1: []
|
||||
Bar Example OpenAPI 3 definition._scheme2: []
|
||||
- Bar Example OpenAPI 3 definition._scheme3: []
|
||||
Bar Example OpenAPI 3 definition._scheme4: []
|
||||
tags:
|
||||
- bar_other
|
||||
components:
|
||||
|
||||
@@ -756,8 +756,11 @@ function addComponentsPrefix(description: string, componentsPrefix: string) {
|
||||
function addSecurityPrefix(security: any, componentsPrefix: string) {
|
||||
return componentsPrefix
|
||||
? security?.map((s: any) => {
|
||||
const key = Object.keys(s)[0];
|
||||
return { [componentsPrefix + '_' + key]: s[key] };
|
||||
const joinedSecuritySchema = {};
|
||||
for (const [key, value] of Object.entries(s)) {
|
||||
Object.assign(joinedSecuritySchema, { [componentsPrefix + '_' + key]: value });
|
||||
}
|
||||
return joinedSecuritySchema;
|
||||
})
|
||||
: security;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user