Skip to content

Commit 2436509

Browse files
authored
Merge pull request #8 from hyperweb-io/anmol/fix-constructor-param-options
fix: update constructor option params
2 parents ee27b46 + d2e9836 commit 2436509

File tree

7 files changed

+26
-17
lines changed

7 files changed

+26
-17
lines changed

__fixtures__/output/swagger-client.merged.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { APIClient, APIClientRequestOpts } from "@interweb/fetch-api-client";
1+
import { APIClient, APIClientRequestOpts, APIClientOptions } from "@interweb/fetch-api-client";
22
export interface MutatingWebhook {
33
admissionReviewVersions: string[];
44
clientConfig: WebhookClientConfig;
@@ -10199,7 +10199,7 @@ export interface LogFileHandlerRequest {
1019910199
export interface GetServiceAccountIssuerOpenIDKeysetRequest {}
1020010200
export interface GetCodeVersionRequest {}
1020110201
export class KubernetesClient extends APIClient {
10202-
constructor(options) {
10202+
constructor(options: APIClientOptions) {
1020310203
super(options);
1020410204
}
1020510205
async getSwaggerJSON() {

__fixtures__/output/swagger-client.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { APIClient, APIClientRequestOpts } from "@interweb/fetch-api-client";
1+
import { APIClient, APIClientRequestOpts, APIClientOptions } from "@interweb/fetch-api-client";
22
/* io.k8s.api.admissionregistration.v1.MutatingWebhook */
33
/* MutatingWebhook describes an admission webhook and the resources and operations it applies to. */
44
export interface MutatingWebhook {
@@ -11592,7 +11592,7 @@ export interface LogFileHandlerRequest {
1159211592
export interface GetServiceAccountIssuerOpenIDKeysetRequest {}
1159311593
export interface GetCodeVersionRequest {}
1159411594
export class KubernetesClient extends APIClient {
11595-
constructor(options) {
11595+
constructor(options: APIClientOptions) {
1159611596
super(options);
1159711597
}
1159811598
async getSwaggerJSON() {

__fixtures__/output/swagger-extended-client.merged.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { APIClient, APIClientRequestOpts } from "@interweb/fetch-api-client";
1+
import { APIClient, APIClientRequestOpts, APIClientOptions } from "@interweb/fetch-api-client";
22
export interface Alertmanager {
33
apiVersion?: string;
44
kind?: string;
@@ -33376,7 +33376,7 @@ export interface WatchStorageV1VolumeAttachmentRequest {
3337633376
export interface GetServiceAccountIssuerOpenIDKeysetRequest {}
3337733377
export interface GetCodeVersionRequest {}
3337833378
export class KubernetesClient extends APIClient {
33379-
constructor(options) {
33379+
constructor(options: APIClientOptions) {
3338033380
super(options);
3338133381
}
3338233382
async getSwaggerJSON() {

__fixtures__/output/swagger-extended-client.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { APIClient, APIClientRequestOpts } from "@interweb/fetch-api-client";
1+
import { APIClient, APIClientRequestOpts, APIClientOptions } from "@interweb/fetch-api-client";
22
/* com.coreos.monitoring.v1.Alertmanager */
33
/* The `Alertmanager` custom resource definition (CRD) defines a desired [Alertmanager](https://prometheus.io/docs/alerting) setup to run in a Kubernetes cluster. It allows to specify many options such as the number of replicas, persistent storage and many more.
44

@@ -38192,7 +38192,7 @@ export interface WatchStorageV1VolumeAttachmentRequest {
3819238192
export interface GetServiceAccountIssuerOpenIDKeysetRequest {}
3819338193
export interface GetCodeVersionRequest {}
3819438194
export class KubernetesClient extends APIClient {
38195-
constructor(options) {
38195+
constructor(options: APIClientOptions) {
3819638196
super(options);
3819738197
}
3819838198
async getSwaggerJSON() {

packages/schema-sdk/__tests__/__snapshots__/openapi.extended.generate.test.ts.snap

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

33
exports[`merged 1`] = `
4-
"import { APIClient, APIClientRequestOpts } from "@interweb/fetch-api-client";
4+
"import { APIClient, APIClientRequestOpts, APIClientOptions } from "@interweb/fetch-api-client";
55
export interface Alertmanager {
66
apiVersion?: string;
77
kind?: string;
@@ -33379,7 +33379,7 @@ export interface WatchStorageV1VolumeAttachmentRequest {
3337933379
export interface GetServiceAccountIssuerOpenIDKeysetRequest {}
3338033380
export interface GetCodeVersionRequest {}
3338133381
export class KubernetesClient extends APIClient {
33382-
constructor(options) {
33382+
constructor(options: APIClientOptions) {
3338333383
super(options);
3338433384
}
3338533385
async getSwaggerJSON() {
@@ -37854,7 +37854,7 @@ export class KubernetesClient extends APIClient {
3785437854
`;
3785537855

3785637856
exports[`swagger 1`] = `
37857-
"import { APIClient, APIClientRequestOpts } from "@interweb/fetch-api-client";
37857+
"import { APIClient, APIClientRequestOpts, APIClientOptions } from "@interweb/fetch-api-client";
3785837858
/* com.coreos.monitoring.v1.Alertmanager */
3785937859
/* The \`Alertmanager\` custom resource definition (CRD) defines a desired [Alertmanager](https://prometheus.io/docs/alerting) setup to run in a Kubernetes cluster. It allows to specify many options such as the number of replicas, persistent storage and many more.
3786037860

@@ -76048,7 +76048,7 @@ export interface WatchStorageV1VolumeAttachmentRequest {
7604876048
export interface GetServiceAccountIssuerOpenIDKeysetRequest {}
7604976049
export interface GetCodeVersionRequest {}
7605076050
export class KubernetesClient extends APIClient {
76051-
constructor(options) {
76051+
constructor(options: APIClientOptions) {
7605276052
super(options);
7605376053
}
7605476054
async getSwaggerJSON() {

packages/schema-sdk/__tests__/__snapshots__/openapi.generate.test.ts.snap

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

33
exports[`merged 1`] = `
4-
"import { APIClient, APIClientRequestOpts } from "@interweb/fetch-api-client";
4+
"import { APIClient, APIClientRequestOpts, APIClientOptions } from "@interweb/fetch-api-client";
55
export interface MutatingWebhook {
66
admissionReviewVersions: string[];
77
clientConfig: WebhookClientConfig;
@@ -10202,7 +10202,7 @@ export interface LogFileHandlerRequest {
1020210202
export interface GetServiceAccountIssuerOpenIDKeysetRequest {}
1020310203
export interface GetCodeVersionRequest {}
1020410204
export class KubernetesClient extends APIClient {
10205-
constructor(options) {
10205+
constructor(options: APIClientOptions) {
1020610206
super(options);
1020710207
}
1020810208
async getSwaggerJSON() {
@@ -13345,7 +13345,7 @@ export class KubernetesClient extends APIClient {
1334513345
`;
1334613346

1334713347
exports[`swagger 1`] = `
13348-
"import { APIClient, APIClientRequestOpts } from "@interweb/fetch-api-client";
13348+
"import { APIClient, APIClientRequestOpts, APIClientOptions } from "@interweb/fetch-api-client";
1334913349
/* io.k8s.api.admissionregistration.v1.MutatingWebhook */
1335013350
/* MutatingWebhook describes an admission webhook and the resources and operations it applies to. */
1335113351
export interface MutatingWebhook {
@@ -24939,7 +24939,7 @@ export interface LogFileHandlerRequest {
2493924939
export interface GetServiceAccountIssuerOpenIDKeysetRequest {}
2494024940
export interface GetCodeVersionRequest {}
2494124941
export class KubernetesClient extends APIClient {
24942-
constructor(options) {
24942+
constructor(options: APIClientOptions) {
2494324943
super(options);
2494424944
}
2494524945
async getSwaggerJSON() {

packages/schema-sdk/src/openapi.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -608,11 +608,16 @@ export function generateOpenApiClient(
608608
}
609609
methods.push(...generateMethods(options, patchedSchema));
610610

611+
const constructorOptionsParam = t.identifier('options');
612+
constructorOptionsParam.typeAnnotation = t.tsTypeAnnotation(
613+
t.tsTypeReference(t.identifier('APIClientOptions'))
614+
);
615+
611616
const classBody = t.classBody([
612617
t.classMethod(
613618
'constructor',
614619
t.identifier('constructor'),
615-
[t.identifier('options')],
620+
[constructorOptionsParam],
616621
t.blockStatement([
617622
t.expressionStatement(
618623
t.callExpression(t.super(), [t.identifier('options')])
@@ -656,6 +661,10 @@ export function generateOpenApiClient(
656661
t.identifier('APIClientRequestOpts'),
657662
t.identifier('APIClientRequestOpts')
658663
),
664+
t.importSpecifier(
665+
t.identifier('APIClientOptions'),
666+
t.identifier('APIClientOptions')
667+
),
659668
],
660669
t.stringLiteral(options.npmApiClient)
661670
),

0 commit comments

Comments
 (0)