Skip to content
This repository was archived by the owner on Dec 25, 2024. It is now read-only.

Commit b5b8fa8

Browse files
committed
Improves apikey constructor
1 parent 0b978b0 commit b5b8fa8

File tree

5 files changed

+6
-72
lines changed

5 files changed

+6
-72
lines changed

samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/components/securityschemes/apikey.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ public class ApiKey extends ApiKeySecurityScheme {
77
/*
88
apiKey in header
99
*/
10-
public ApiKey(String apiKey, String name) {
10+
public ApiKey(String apiKey) {
1111
super(apiKey, "api_key", ApiKeyInLocation.HEADER);
1212
}
1313
}

samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/components/securityschemes/apikeyquery.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ public class ApiKeyQuery extends ApiKeySecurityScheme {
77
/*
88
apiKey in query
99
*/
10-
public ApiKeyQuery(String apiKey, String name) {
10+
public ApiKeyQuery(String apiKey) {
1111
super(apiKey, "api_key_query", ApiKeyInLocation.QUERY);
1212
}
1313
}

samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/components/securityschemes/openidconnecttest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,4 @@ class OpenIdConnectTest(security_schemes.OpenIdConnectSecurityScheme):
77
/*
88
openIdConnect
99
*/
10-
openid_connect_url = "https://somesite.com/.well-known/openid-configuration"
1110
}

samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/components/securityschemes/petstoreauth.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,5 @@ public class PetstoreAuth extends OAuth2SecurityScheme {
66
/*
77
oauth2 implicit flow with two scopes
88
*/
9-
flows = security_schemes.OAuthFlows(
10-
implicit=security_schemes.ImplicitOAuthFlow(
11-
authorization_url="http://petstore.swagger.io/api/oauth/dialog",
12-
scopes={
13-
"write:pets": "modify pets in your account",
14-
"read:pets": "read your pets",
15-
},
16-
)
17-
)
9+
// todo add flows info
1810
}

src/main/resources/java/src/main/java/packagename/components/securityschemes/SecurityScheme.hbs

Lines changed: 3 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ public class {{jsonPathPiece.pascalCase}} extends ApiKeySecurityScheme {
4545
*/
4646
{{/if}}
4747
{{#eq in "query"}}
48-
public {{jsonPathPiece.pascalCase}}(String apiKey, String name) {
48+
public {{jsonPathPiece.pascalCase}}(String apiKey) {
4949
super(apiKey, "{{{name}}}", ApiKeyInLocation.QUERY);
5050
}
5151
{{else}}
5252
{{#eq in "header"}}
53-
public {{jsonPathPiece.pascalCase}}(String apiKey, String name) {
53+
public {{jsonPathPiece.pascalCase}}(String apiKey) {
5454
super(apiKey, "{{{name}}}", ApiKeyInLocation.HEADER);
5555
}
5656
{{else}}
@@ -99,63 +99,7 @@ public class {{jsonPathPiece.pascalCase}} extends OAuth2SecurityScheme {
9999
{{description.original}}
100100
*/
101101
{{/if}}
102-
flows = security_schemes.OAuthFlows(
103-
{{#with flows}}
104-
{{#with implicit}}
105-
implicit=security_schemes.ImplicitOAuthFlow(
106-
authorization_url="{{authorizationUrl}}",
107-
scopes={
108-
{{#each scopes}}
109-
"{{@key}}": "{{this}}",
110-
{{/each}}
111-
},
112-
{{#if refreshUrl}}
113-
refresh_url="{{refreshUrl}}"
114-
{{/if}}
115-
)
116-
{{/with}}
117-
{{#with password}}
118-
password=security_schemes.TokenUrlOauthFlow(
119-
token_url="{{tokenUrl}}",
120-
scopes={
121-
{{#each scopes}}
122-
"{{@key}}": "{{this}}",
123-
{{/each}}
124-
},
125-
{{#if refreshUrl}}
126-
refresh_url="{{refreshUrl}}"
127-
{{/if}}
128-
)
129-
{{/with}}
130-
{{#with clientCredentials}}
131-
client_credentials=security_schemes.TokenUrlOauthFlow(
132-
token_url="{{tokenUrl}}",
133-
scopes={
134-
{{#each scopes}}
135-
"{{@key}}": "{{this}}",
136-
{{/each}}
137-
},
138-
{{#if refreshUrl}}
139-
refresh_url="{{refreshUrl}}",
140-
{{/if}}
141-
)
142-
{{/with}}
143-
{{#with authorizationCode}}
144-
authorization_code=security_schemes.AuthorizationCodeOauthFlow(
145-
authorization_url="{{authorizationUrl}}",
146-
token_url="{{tokenUrl}}",
147-
scopes={
148-
{{#each scopes}}
149-
"{{@key}}": "{{this}}",
150-
{{/each}}
151-
},
152-
{{#if refreshUrl}}
153-
refresh_url="{{refreshUrl}}"
154-
{{/if}}
155-
)
156-
{{/with}}
157-
{{/with}}
158-
)
102+
// todo add flows info
159103
}
160104
{{else}}
161105
{{#eq type "openIdConnect"}}
@@ -166,7 +110,6 @@ class {{jsonPathPiece.pascalCase}}(security_schemes.OpenIdConnectSecurityScheme)
166110
{{description.original}}
167111
*/
168112
{{/if}}
169-
openid_connect_url = "{{openIdConnectUrl}}"
170113
}
171114
{{/eq}}
172115
{{/eq}}

0 commit comments

Comments
 (0)