-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: fix cleanup of securitySchemes (#10)
Fix lookup of references to securitySchemes before cleaning it. /components/securitySchemes are not referenced by $ref like other components. We now implement the correct algorithm to lookup for references before cleaning: - look for references in Security Requirements in /security - look for references in Security Requirements in /paths/<path>/<method>/security
- Loading branch information
Showing
4 changed files
with
106 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
--- | ||
openapi: "3.1.1" | ||
info: | ||
version: "0.0.1" | ||
security: | ||
- {} | ||
- { | ||
"api-key": [] | ||
} | ||
paths: | ||
/: | ||
get: | ||
responses: | ||
404: | ||
description: Not found. | ||
security: | ||
- { "api-key-cookie": [] } | ||
- {} | ||
components: | ||
securitySchemes: | ||
unused: | ||
type: apiKey | ||
in: header | ||
name: unused | ||
api-key: | ||
type: apiKey | ||
in: header | ||
name: Api-Key | ||
api-key-cookie: | ||
type: apiKey | ||
in: cookie | ||
name: apiKey |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
{ | ||
"openapi": "3.1.1", | ||
"info": { | ||
"version": "0.0.1" | ||
}, | ||
"security": [ | ||
{}, | ||
{ | ||
"api-key": [] | ||
} | ||
], | ||
"paths": { | ||
"/": { | ||
"get": { | ||
"responses": { | ||
"404": { | ||
"description": "Not found." | ||
} | ||
}, | ||
"security": [ | ||
{ | ||
"api-key-cookie": [] | ||
}, | ||
{} | ||
] | ||
} | ||
} | ||
}, | ||
"components": { | ||
"securitySchemes": { | ||
"api-key": { | ||
"in": "header", | ||
"name": "Api-Key", | ||
"type": "apiKey" | ||
}, | ||
"api-key-cookie": { | ||
"in": "cookie", | ||
"name": "apiKey", | ||
"type": "apiKey" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package main | ||
|
||
import "testing" | ||
|
||
func TestUnusedSecuritySchemes01(t *testing.T) { | ||
runExpandRefs(t, "testdata/80-unused-securityschemes-01") | ||
} |