File tree Expand file tree Collapse file tree 3 files changed +43
-1
lines changed
Expand file tree Collapse file tree 3 files changed +43
-1
lines changed Original file line number Diff line number Diff line change 1+ openapi : 3.0.1
2+ info :
3+ title : " Overriding global security"
4+ version : 1.0.0
5+ components :
6+ schemas :
7+ Data :
8+ description : " Data"
9+ type : string
10+ securitySchemes :
11+ Token :
12+ type : apiKey
13+ in : header
14+ name : X-API-Key
15+ security :
16+ - Token : []
17+ paths :
18+ " /api/protected " :
19+ summary : Endpoint requiring token
20+ description : Description of protected endpoint
21+ get :
22+ operationId : GetProtectedData
23+ responses :
24+ 200 :
25+ $ref : " #/components/schemas/Data"
26+
27+ " /api/unprotected " :
28+ summary : Unprotected (public) endpoint
29+ description : " Description of unprotected endpoint"
30+ get :
31+ security : []
32+ operationId : GetUnprotectedData
33+ responses :
34+ 200 :
35+ $ref : " #/components/schemas/Data"
Original file line number Diff line number Diff line change @@ -1494,7 +1494,9 @@ operationToAuthorizationInfo : OpenApi.Operation.Operation -> CliMonad Authoriza
14941494operationToAuthorizationInfo operation =
14951495 CliMonad . andThen2
14961496 ( \ globalSecurity components ->
1497- ( OpenApi . Operation . security operation ++ globalSecurity)
1497+ -- If present, the operation's security overrides globalSecurity.
1498+ OpenApi . Operation . security operation
1499+ |> Maybe . withDefault globalSecurity
14981500 |> List . concatMap
14991501 ( Dict . toList << OpenApi . SecurityRequirement . requirements)
15001502 |> CliMonad . foldl
Original file line number Diff line number Diff line change 2020 recursiveAllofRefs =
2121 OpenApi . Config . inputFrom ( OpenApi . Config . File " ./example/recursive-allof-refs.yaml" )
2222
23+ overridingGlobalSecurity : OpenApi . Config . Input
24+ overridingGlobalSecurity =
25+ OpenApi . Config . inputFrom ( OpenApi . Config . File " ./example/overriding-global-security.yaml" )
26+
2327 singleEnum : OpenApi . Config . Input
2428 singleEnum =
2529 OpenApi . Config . inputFrom ( OpenApi . Config . File " ./example/single-enum.yaml" )
7074 OpenApi . Config . init " ./generated"
7175 |> OpenApi . Config . withAutoConvertSwagger True
7276 |> OpenApi . Config . withInput recursiveAllofRefs
77+ |> OpenApi . Config . withInput overridingGlobalSecurity
7378 |> OpenApi . Config . withInput singleEnum
7479 |> OpenApi . Config . withInput patreon
7580 |> OpenApi . Config . withInput realworldConduit
You can’t perform that action at this time.
0 commit comments