Skip to content

Commit 905a53b

Browse files
authored
BC-10146 - Generate auth client for access token endpoints (#41)
1 parent 35aa3d8 commit 905a53b

File tree

12 files changed

+560
-23
lines changed

12 files changed

+560
-23
lines changed

openapitools.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
"skipValidateSpec": true,
1212
"enablePostProcessFile": true,
1313
"openapiNormalizer": {
14-
"FILTER": "operationId:AuthorizationReferenceController_authorizeByReference"
14+
"FILTER": "operationId:AuthorizationReferenceController_authorizeByReference|AuthorizationReferenceController_createToken|AuthorizationReferenceController_resolveToken"
1515
},
1616
"globalProperty": {
17-
"models": "AuthorizationBodyParams:AuthorizationContextParams:AuthorizedReponse",
17+
"models": "AuthorizationBodyParams:AuthorizationContextParams:AuthorizedResponse:CreateAccessTokenParams:AccessTokenResponse:AccessTokenParams:AccessTokenPayloadResponse",
1818
"apis": "",
1919
"supportingFiles": ""
2020
},
@@ -30,4 +30,4 @@
3030
}
3131
}
3232
}
33-
}
33+
}

src/infra/authorization-client/authorization-api-client/.openapi-generator/FILES

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ common.ts
88
configuration.ts
99
git_push.sh
1010
index.ts
11+
models/access-token-payload-response.ts
12+
models/access-token-response.ts
1113
models/authorization-body-params.ts
1214
models/authorization-context-params.ts
13-
models/authorized-reponse.ts
15+
models/authorized-response.ts
16+
models/create-access-token-params.ts
1417
models/index.ts

src/infra/authorization-client/authorization-api-client/api/authorization-api.ts

Lines changed: 172 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,17 @@ import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObj
2222
// @ts-ignore
2323
import { BASE_PATH, COLLECTION_FORMATS, type RequestArgs, BaseAPI, RequiredError, operationServerMap } from '../base';
2424
// @ts-ignore
25+
import type { AccessTokenPayloadResponse } from '../models';
26+
// @ts-ignore
27+
import type { AccessTokenResponse } from '../models';
28+
// @ts-ignore
2529
import type { ApiValidationError } from '../models';
2630
// @ts-ignore
2731
import type { AuthorizationBodyParams } from '../models';
2832
// @ts-ignore
29-
import type { AuthorizedReponse } from '../models';
33+
import type { AuthorizedResponse } from '../models';
34+
// @ts-ignore
35+
import type { CreateAccessTokenParams } from '../models';
3036
/**
3137
* AuthorizationApi - axios parameter creator
3238
* @export
@@ -68,6 +74,82 @@ export const AuthorizationApiAxiosParamCreator = function (configuration?: Confi
6874
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
6975
localVarRequestOptions.data = serializeDataIfNeeded(authorizationBodyParams, localVarRequestOptions, configuration)
7076

77+
return {
78+
url: toPathString(localVarUrlObj),
79+
options: localVarRequestOptions,
80+
};
81+
},
82+
/**
83+
*
84+
* @param {CreateAccessTokenParams} createAccessTokenParams
85+
* @param {*} [options] Override http request option.
86+
* @throws {RequiredError}
87+
*/
88+
authorizationReferenceControllerCreateToken: async (createAccessTokenParams: CreateAccessTokenParams, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
89+
// verify required parameter 'createAccessTokenParams' is not null or undefined
90+
assertParamExists('authorizationReferenceControllerCreateToken', 'createAccessTokenParams', createAccessTokenParams)
91+
const localVarPath = `/authorization/create-token`;
92+
// use dummy base URL string because the URL constructor only accepts absolute URLs.
93+
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
94+
let baseOptions;
95+
if (configuration) {
96+
baseOptions = configuration.baseOptions;
97+
}
98+
99+
const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options};
100+
const localVarHeaderParameter = {} as any;
101+
const localVarQueryParameter = {} as any;
102+
103+
// authentication bearer required
104+
// http bearer authentication required
105+
await setBearerAuthToObject(localVarHeaderParameter, configuration)
106+
107+
108+
109+
localVarHeaderParameter['Content-Type'] = 'application/json';
110+
111+
setSearchParams(localVarUrlObj, localVarQueryParameter);
112+
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
113+
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
114+
localVarRequestOptions.data = serializeDataIfNeeded(createAccessTokenParams, localVarRequestOptions, configuration)
115+
116+
return {
117+
url: toPathString(localVarUrlObj),
118+
options: localVarRequestOptions,
119+
};
120+
},
121+
/**
122+
*
123+
* @param {string} token The access token to be resolved.
124+
* @param {number} tokenTtlInSeconds Lifetime of token
125+
* @param {*} [options] Override http request option.
126+
* @throws {RequiredError}
127+
*/
128+
authorizationReferenceControllerResolveToken: async (token: string, tokenTtlInSeconds: number, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
129+
// verify required parameter 'token' is not null or undefined
130+
assertParamExists('authorizationReferenceControllerResolveToken', 'token', token)
131+
// verify required parameter 'tokenTtlInSeconds' is not null or undefined
132+
assertParamExists('authorizationReferenceControllerResolveToken', 'tokenTtlInSeconds', tokenTtlInSeconds)
133+
const localVarPath = `/authorization/resolve-token/{token}/ttl/{tokenTtlInSeconds}`
134+
.replace(`{${"token"}}`, encodeURIComponent(String(token)))
135+
.replace(`{${"tokenTtlInSeconds"}}`, encodeURIComponent(String(tokenTtlInSeconds)));
136+
// use dummy base URL string because the URL constructor only accepts absolute URLs.
137+
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
138+
let baseOptions;
139+
if (configuration) {
140+
baseOptions = configuration.baseOptions;
141+
}
142+
143+
const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options};
144+
const localVarHeaderParameter = {} as any;
145+
const localVarQueryParameter = {} as any;
146+
147+
148+
149+
setSearchParams(localVarUrlObj, localVarQueryParameter);
150+
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
151+
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
152+
71153
return {
72154
url: toPathString(localVarUrlObj),
73155
options: localVarRequestOptions,
@@ -90,12 +172,37 @@ export const AuthorizationApiFp = function(configuration?: Configuration) {
90172
* @param {*} [options] Override http request option.
91173
* @throws {RequiredError}
92174
*/
93-
async authorizationReferenceControllerAuthorizeByReference(authorizationBodyParams: AuthorizationBodyParams, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<AuthorizedReponse>> {
175+
async authorizationReferenceControllerAuthorizeByReference(authorizationBodyParams: AuthorizationBodyParams, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<AuthorizedResponse>> {
94176
const localVarAxiosArgs = await localVarAxiosParamCreator.authorizationReferenceControllerAuthorizeByReference(authorizationBodyParams, options);
95177
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
96178
const localVarOperationServerBasePath = operationServerMap['AuthorizationApi.authorizationReferenceControllerAuthorizeByReference']?.[localVarOperationServerIndex]?.url;
97179
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
98180
},
181+
/**
182+
*
183+
* @param {CreateAccessTokenParams} createAccessTokenParams
184+
* @param {*} [options] Override http request option.
185+
* @throws {RequiredError}
186+
*/
187+
async authorizationReferenceControllerCreateToken(createAccessTokenParams: CreateAccessTokenParams, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<AccessTokenResponse>> {
188+
const localVarAxiosArgs = await localVarAxiosParamCreator.authorizationReferenceControllerCreateToken(createAccessTokenParams, options);
189+
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
190+
const localVarOperationServerBasePath = operationServerMap['AuthorizationApi.authorizationReferenceControllerCreateToken']?.[localVarOperationServerIndex]?.url;
191+
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
192+
},
193+
/**
194+
*
195+
* @param {string} token The access token to be resolved.
196+
* @param {number} tokenTtlInSeconds Lifetime of token
197+
* @param {*} [options] Override http request option.
198+
* @throws {RequiredError}
199+
*/
200+
async authorizationReferenceControllerResolveToken(token: string, tokenTtlInSeconds: number, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<AccessTokenPayloadResponse>> {
201+
const localVarAxiosArgs = await localVarAxiosParamCreator.authorizationReferenceControllerResolveToken(token, tokenTtlInSeconds, options);
202+
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
203+
const localVarOperationServerBasePath = operationServerMap['AuthorizationApi.authorizationReferenceControllerResolveToken']?.[localVarOperationServerIndex]?.url;
204+
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
205+
},
99206
}
100207
};
101208

@@ -113,9 +220,28 @@ export const AuthorizationApiFactory = function (configuration?: Configuration,
113220
* @param {*} [options] Override http request option.
114221
* @throws {RequiredError}
115222
*/
116-
authorizationReferenceControllerAuthorizeByReference(authorizationBodyParams: AuthorizationBodyParams, options?: any): AxiosPromise<AuthorizedReponse> {
223+
authorizationReferenceControllerAuthorizeByReference(authorizationBodyParams: AuthorizationBodyParams, options?: any): AxiosPromise<AuthorizedResponse> {
117224
return localVarFp.authorizationReferenceControllerAuthorizeByReference(authorizationBodyParams, options).then((request) => request(axios, basePath));
118225
},
226+
/**
227+
*
228+
* @param {CreateAccessTokenParams} createAccessTokenParams
229+
* @param {*} [options] Override http request option.
230+
* @throws {RequiredError}
231+
*/
232+
authorizationReferenceControllerCreateToken(createAccessTokenParams: CreateAccessTokenParams, options?: any): AxiosPromise<AccessTokenResponse> {
233+
return localVarFp.authorizationReferenceControllerCreateToken(createAccessTokenParams, options).then((request) => request(axios, basePath));
234+
},
235+
/**
236+
*
237+
* @param {string} token The access token to be resolved.
238+
* @param {number} tokenTtlInSeconds Lifetime of token
239+
* @param {*} [options] Override http request option.
240+
* @throws {RequiredError}
241+
*/
242+
authorizationReferenceControllerResolveToken(token: string, tokenTtlInSeconds: number, options?: any): AxiosPromise<AccessTokenPayloadResponse> {
243+
return localVarFp.authorizationReferenceControllerResolveToken(token, tokenTtlInSeconds, options).then((request) => request(axios, basePath));
244+
},
119245
};
120246
};
121247

@@ -133,7 +259,26 @@ export interface AuthorizationApiInterface {
133259
* @throws {RequiredError}
134260
* @memberof AuthorizationApiInterface
135261
*/
136-
authorizationReferenceControllerAuthorizeByReference(authorizationBodyParams: AuthorizationBodyParams, options?: RawAxiosRequestConfig): AxiosPromise<AuthorizedReponse>;
262+
authorizationReferenceControllerAuthorizeByReference(authorizationBodyParams: AuthorizationBodyParams, options?: RawAxiosRequestConfig): AxiosPromise<AuthorizedResponse>;
263+
264+
/**
265+
*
266+
* @param {CreateAccessTokenParams} createAccessTokenParams
267+
* @param {*} [options] Override http request option.
268+
* @throws {RequiredError}
269+
* @memberof AuthorizationApiInterface
270+
*/
271+
authorizationReferenceControllerCreateToken(createAccessTokenParams: CreateAccessTokenParams, options?: RawAxiosRequestConfig): AxiosPromise<AccessTokenResponse>;
272+
273+
/**
274+
*
275+
* @param {string} token The access token to be resolved.
276+
* @param {number} tokenTtlInSeconds Lifetime of token
277+
* @param {*} [options] Override http request option.
278+
* @throws {RequiredError}
279+
* @memberof AuthorizationApiInterface
280+
*/
281+
authorizationReferenceControllerResolveToken(token: string, tokenTtlInSeconds: number, options?: RawAxiosRequestConfig): AxiosPromise<AccessTokenPayloadResponse>;
137282

138283
}
139284

@@ -155,5 +300,28 @@ export class AuthorizationApi extends BaseAPI implements AuthorizationApiInterfa
155300
public authorizationReferenceControllerAuthorizeByReference(authorizationBodyParams: AuthorizationBodyParams, options?: RawAxiosRequestConfig) {
156301
return AuthorizationApiFp(this.configuration).authorizationReferenceControllerAuthorizeByReference(authorizationBodyParams, options).then((request) => request(this.axios, this.basePath));
157302
}
303+
304+
/**
305+
*
306+
* @param {CreateAccessTokenParams} createAccessTokenParams
307+
* @param {*} [options] Override http request option.
308+
* @throws {RequiredError}
309+
* @memberof AuthorizationApi
310+
*/
311+
public authorizationReferenceControllerCreateToken(createAccessTokenParams: CreateAccessTokenParams, options?: RawAxiosRequestConfig) {
312+
return AuthorizationApiFp(this.configuration).authorizationReferenceControllerCreateToken(createAccessTokenParams, options).then((request) => request(this.axios, this.basePath));
313+
}
314+
315+
/**
316+
*
317+
* @param {string} token The access token to be resolved.
318+
* @param {number} tokenTtlInSeconds Lifetime of token
319+
* @param {*} [options] Override http request option.
320+
* @throws {RequiredError}
321+
* @memberof AuthorizationApi
322+
*/
323+
public authorizationReferenceControllerResolveToken(token: string, tokenTtlInSeconds: number, options?: RawAxiosRequestConfig) {
324+
return AuthorizationApiFp(this.configuration).authorizationReferenceControllerResolveToken(token, tokenTtlInSeconds, options).then((request) => request(this.axios, this.basePath));
325+
}
158326
}
159327

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/* tslint:disable */
2+
/* eslint-disable */
3+
/**
4+
* Schulcloud-Verbund-Software Server API
5+
* This is v3 of Schulcloud-Verbund-Software Server. Checkout /docs for v1.
6+
*
7+
* The version of the OpenAPI document: 3.0
8+
*
9+
*
10+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
11+
* https://openapi-generator.tech
12+
* Do not edit the class manually.
13+
*/
14+
15+
16+
17+
/**
18+
*
19+
* @export
20+
* @interface AccessTokenPayloadResponse
21+
*/
22+
export interface AccessTokenPayloadResponse {
23+
/**
24+
*
25+
* @type {object}
26+
* @memberof AccessTokenPayloadResponse
27+
*/
28+
'payload': object;
29+
}
30+
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/* tslint:disable */
2+
/* eslint-disable */
3+
/**
4+
* Schulcloud-Verbund-Software Server API
5+
* This is v3 of Schulcloud-Verbund-Software Server. Checkout /docs for v1.
6+
*
7+
* The version of the OpenAPI document: 3.0
8+
*
9+
*
10+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
11+
* https://openapi-generator.tech
12+
* Do not edit the class manually.
13+
*/
14+
15+
16+
17+
/**
18+
*
19+
* @export
20+
* @interface AccessTokenResponse
21+
*/
22+
export interface AccessTokenResponse {
23+
/**
24+
*
25+
* @type {string}
26+
* @memberof AccessTokenResponse
27+
*/
28+
'token': string;
29+
}
30+

src/infra/authorization-client/authorization-api-client/models/authorized-reponse.ts renamed to src/infra/authorization-client/authorization-api-client/models/authorized-response.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,19 @@
1717
/**
1818
*
1919
* @export
20-
* @interface AuthorizedReponse
20+
* @interface AuthorizedResponse
2121
*/
22-
export interface AuthorizedReponse {
22+
export interface AuthorizedResponse {
2323
/**
2424
*
2525
* @type {string}
26-
* @memberof AuthorizedReponse
26+
* @memberof AuthorizedResponse
2727
*/
2828
'userId': string;
2929
/**
3030
*
3131
* @type {boolean}
32-
* @memberof AuthorizedReponse
32+
* @memberof AuthorizedResponse
3333
*/
3434
'isAuthorized': boolean;
3535
}

0 commit comments

Comments
 (0)