Skip to content

Commit b807cc8

Browse files
committed
adding TweedBaseContext as required parameter in generated client
1 parent 31aaf72 commit b807cc8

File tree

7 files changed

+53
-21
lines changed

7 files changed

+53
-21
lines changed

.github/workflows/release.yml

-13
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { Model } from './Model';
22

33
export interface OperationParameter extends Model {
4-
in: 'path' | 'query' | 'header' | 'formData' | 'body' | 'cookie';
4+
in: 'path' | 'query' | 'header' | 'formData' | 'body' | 'cookie' | 'param';
55
prop: string;
66
mediaType: string | null;
77
}

src/openApi/v2/parser/getOperation.ts

+21
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,27 @@ export const getOperation = (
7070
});
7171
}
7272

73+
operation.parameters.push({
74+
name: 'context',
75+
type: 'TweedBaseContext',
76+
in: 'param',
77+
base: 'TweedBaseContext',
78+
description: 'Tweed context for context propagation',
79+
export: 'generic',
80+
isDefinition: false,
81+
isNullable: false,
82+
isReadOnly: false,
83+
isRequired: true,
84+
link: null,
85+
mediaType: null,
86+
prop: '',
87+
properties: [],
88+
enum: [],
89+
enums: [],
90+
imports: [],
91+
template: null,
92+
});
93+
7394
operation.parameters = operation.parameters.sort(sortByRequired);
7495

7596
return operation;

src/openApi/v3/parser/getOperation.ts

+20
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,26 @@ export const getOperation = (
8282
}
8383

8484
operation.parameters = operation.parameters.sort(sortByRequired);
85+
operation.parameters.push({
86+
name: 'context',
87+
type: 'TweedBaseContext',
88+
in: 'param',
89+
base: 'TweedBaseContext',
90+
description: 'Tweed context for context propagation',
91+
export: 'generic',
92+
isDefinition: false,
93+
isNullable: false,
94+
isReadOnly: false,
95+
isRequired: true,
96+
link: null,
97+
mediaType: null,
98+
prop: '',
99+
properties: [],
100+
enum: [],
101+
enums: [],
102+
imports: [],
103+
template: null,
104+
});
85105

86106
return operation;
87107
};

src/templates/core/ApiRequestOptions.hbs

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
{{>header}}
2-
import { TweedBaseContext } from "@paytweed/context";
2+
3+
4+
import { TweedBaseContext } from '@paytweed/context';
35

46
export type ApiRequestOptions = {
57
readonly method: 'GET' | 'PUT' | 'POST' | 'DELETE' | 'OPTIONS' | 'HEAD' | 'PATCH';
68
readonly url: string;
7-
readonly context: TweedContext
9+
readonly context: TweedBaseContext
810
readonly path?: Record<string, any>;
911
readonly cookies?: Record<string, any>;
1012
readonly headers?: Record<string, any>;

src/templates/core/BaseHttpRequest.hbs

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import type { ApiRequestOptions } from './ApiRequestOptions';
88
import type { OpenAPIConfig } from './OpenAPI';
99
{{else}}
1010
import type { ApiRequestOptions } from './ApiRequestOptions';
11-
import type { CancelablePromise } from './CancelablePromise';
11+
import { AxiosResponse } from '@paytweed/http-client';
1212
import type { OpenAPIConfig } from './OpenAPI';
1313
{{/equals}}
1414

@@ -26,6 +26,6 @@ export abstract class BaseHttpRequest {
2626
{{#equals @root.httpClient 'angular'}}
2727
public abstract request<T>(options: ApiRequestOptions): Observable<T>;
2828
{{else}}
29-
public abstract request<T>(options: ApiRequestOptions): CancelablePromise<T>;
29+
public abstract request<T>(options: ApiRequestOptions): Promise<AxiosResponse<T>>;
3030
{{/equals}}
3131
}

src/templates/exportService.hbs

+5-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ import type { {{{this}}} } from '../models/{{{this}}}';
1818

1919
{{/if}}
2020
{{#notEquals @root.httpClient 'angular'}}
21-
import type { CancelablePromise } from '../core/CancelablePromise';
21+
import { AxiosResponse } from '@paytweed/http-client';
22+
import { TweedBaseContext } from '@paytweed/context';
2223
{{/notEquals}}
2324
{{#if @root.exportClient}}
2425
{{#equals @root.httpClient 'angular'}}
@@ -75,20 +76,21 @@ export class {{{name}}}{{{@root.postfix}}} {
7576
public {{{name}}}({{>parameters}}): Observable<{{>result}}> {
7677
return this.httpRequest.request({
7778
{{else}}
78-
public {{{name}}}({{>parameters}}): CancelablePromise<{{>result}}> {
79+
public {{{name}}}({{>parameters}}): Promise<AxiosResponse<{{>result}}>> {
7980
return this.httpRequest.request({
8081
{{/equals}}
8182
{{else}}
8283
{{#equals @root.httpClient 'angular'}}
8384
public {{{name}}}({{>parameters}}): Observable<{{>result}}> {
8485
return __request(OpenAPI, this.http, {
8586
{{else}}
86-
public static {{{name}}}({{>parameters}}): CancelablePromise<{{>result}}> {
87+
public static {{{name}}}({{>parameters}}): Promise<AxiosResponse<{{>result}}>> {
8788
return __request(OpenAPI, {
8889
{{/equals}}
8990
{{/if}}
9091
method: '{{{method}}}',
9192
url: '{{{path}}}',
93+
context,
9294
{{#if parametersPath}}
9395
path: {
9496
{{#each parametersPath}}

0 commit comments

Comments
 (0)