File tree 4 files changed +19
-2
lines changed
modules/openapi-generator/src/main
java/org/openapitools/codegen/languages
samples/client/petstore/elixir/lib/openapi_petstore
4 files changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -188,7 +188,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
188
188
|BasicAuth|✓|OAS2,OAS3
189
189
|ApiKey|✗|OAS2,OAS3
190
190
|OpenIDConnect|✗|OAS3
191
- |BearerToken|✗ |OAS3
191
+ |BearerToken|✓ |OAS3
192
192
|OAuth2_Implicit|✓|OAS2,OAS3
193
193
|OAuth2_Password|✗|OAS2,OAS3
194
194
|OAuth2_ClientCredentials|✗|OAS2,OAS3
Original file line number Diff line number Diff line change @@ -71,7 +71,8 @@ public ElixirClientCodegen() {
71
71
.includeDocumentationFeatures (DocumentationFeature .Readme )
72
72
.securityFeatures (EnumSet .of (
73
73
SecurityFeature .OAuth2_Implicit ,
74
- SecurityFeature .BasicAuth ))
74
+ SecurityFeature .BasicAuth ,
75
+ SecurityFeature .BearerToken ))
75
76
.excludeGlobalFeatures (
76
77
GlobalFeature .XMLStructureDefinitions ,
77
78
GlobalFeature .Callbacks ,
Original file line number Diff line number Diff line change @@ -52,6 +52,9 @@ defmodule {{moduleName}}.Connection do
52
52
- `username`: A username for basic authentication.
53
53
- `password`: A password for basic authentication.
54
54
{ {/hasHttpBasicMethods} }
55
+ { {#hasHttpBearerMethods} }
56
+ - `bearer_token`: A bearer token for bearer authentication.
57
+ { {/hasHttpBearerMethods} }
55
58
"""
56
59
@type options :: [
57
60
{ :base_url, String.t()} ,
@@ -64,6 +67,9 @@ defmodule {{moduleName}}.Connection do
64
67
{ :username, String.t() | nil} ,
65
68
{ :password, String.t() | nil} ,
66
69
{ {/hasHttpBasicMethods} }
70
+ { {#hasHttpBearerMethods} }
71
+ { :bearer_token, String.t() | nil} ,
72
+ { {/hasHttpBearerMethods} }
67
73
]
68
74
69
75
@doc "Forward requests to Tesla."
@@ -240,6 +246,11 @@ defmodule {{moduleName}}.Connection do
240
246
end
241
247
{ {/hasHttpBasicMethods} }
242
248
249
+ { {#hasHttpBearerMethods} }
250
+ bearer_token = Keyword.get(options, :bearer_token)
251
+ middleware = [{ Tesla.Middleware.BearerAuth, token: bearer_token} | middleware]
252
+ { {/hasHttpBearerMethods} }
253
+
243
254
{ {#hasOAuthMethods} }
244
255
middleware =
245
256
if token = Keyword.get(options, :token) do
Original file line number Diff line number Diff line change @@ -46,6 +46,7 @@ defmodule OpenapiPetstore.Connection do
46
46
fetcher function.
47
47
- `username`: A username for basic authentication.
48
48
- `password`: A password for basic authentication.
49
+ - `bearer_token`: A bearer token for bearer authentication.
49
50
"""
50
51
@ type options :: [
51
52
{ :base_url , String . t ( ) } ,
@@ -54,6 +55,7 @@ defmodule OpenapiPetstore.Connection do
54
55
{ :token_scopes , list ( String . t ( ) ) } ,
55
56
{ :username , String . t ( ) | nil } ,
56
57
{ :password , String . t ( ) | nil } ,
58
+ { :bearer_token , String . t ( ) | nil } ,
57
59
]
58
60
59
61
@ doc "Forward requests to Tesla."
@@ -175,6 +177,9 @@ defmodule OpenapiPetstore.Connection do
175
177
middleware
176
178
end
177
179
180
+ bearer_token = Keyword . get ( options , :bearer_token )
181
+ middleware = [ { Tesla.Middleware.BearerAuth , token: bearer_token } | middleware ]
182
+
178
183
middleware =
179
184
if token = Keyword . get ( options , :token ) do
180
185
scopes = Keyword . get ( options , :token_scopes , @ default_scopes )
You can’t perform that action at this time.
0 commit comments