Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions __fixtures__/output/swagger-client.merged.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { APIClient, APIClientRequestOpts } from "@interweb/fetch-api-client";
import { APIClient, APIClientRequestOpts, APIClientOptions } from "@interweb/fetch-api-client";
export interface MutatingWebhook {
admissionReviewVersions: string[];
clientConfig: WebhookClientConfig;
Expand Down Expand Up @@ -10199,7 +10199,7 @@ export interface LogFileHandlerRequest {
export interface GetServiceAccountIssuerOpenIDKeysetRequest {}
export interface GetCodeVersionRequest {}
export class KubernetesClient extends APIClient {
constructor(options) {
constructor(options: APIClientOptions) {
super(options);
}
async getSwaggerJSON() {
Expand Down
4 changes: 2 additions & 2 deletions __fixtures__/output/swagger-client.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { APIClient, APIClientRequestOpts } from "@interweb/fetch-api-client";
import { APIClient, APIClientRequestOpts, APIClientOptions } from "@interweb/fetch-api-client";
/* io.k8s.api.admissionregistration.v1.MutatingWebhook */
/* MutatingWebhook describes an admission webhook and the resources and operations it applies to. */
export interface MutatingWebhook {
Expand Down Expand Up @@ -11592,7 +11592,7 @@ export interface LogFileHandlerRequest {
export interface GetServiceAccountIssuerOpenIDKeysetRequest {}
export interface GetCodeVersionRequest {}
export class KubernetesClient extends APIClient {
constructor(options) {
constructor(options: APIClientOptions) {
super(options);
}
async getSwaggerJSON() {
Expand Down
4 changes: 2 additions & 2 deletions __fixtures__/output/swagger-extended-client.merged.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { APIClient, APIClientRequestOpts } from "@interweb/fetch-api-client";
import { APIClient, APIClientRequestOpts, APIClientOptions } from "@interweb/fetch-api-client";
export interface Alertmanager {
apiVersion?: string;
kind?: string;
Expand Down Expand Up @@ -33376,7 +33376,7 @@ export interface WatchStorageV1VolumeAttachmentRequest {
export interface GetServiceAccountIssuerOpenIDKeysetRequest {}
export interface GetCodeVersionRequest {}
export class KubernetesClient extends APIClient {
constructor(options) {
constructor(options: APIClientOptions) {
super(options);
}
async getSwaggerJSON() {
Expand Down
4 changes: 2 additions & 2 deletions __fixtures__/output/swagger-extended-client.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { APIClient, APIClientRequestOpts } from "@interweb/fetch-api-client";
import { APIClient, APIClientRequestOpts, APIClientOptions } from "@interweb/fetch-api-client";
/* com.coreos.monitoring.v1.Alertmanager */
/* 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.

Expand Down Expand Up @@ -38192,7 +38192,7 @@ export interface WatchStorageV1VolumeAttachmentRequest {
export interface GetServiceAccountIssuerOpenIDKeysetRequest {}
export interface GetCodeVersionRequest {}
export class KubernetesClient extends APIClient {
constructor(options) {
constructor(options: APIClientOptions) {
super(options);
}
async getSwaggerJSON() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`merged 1`] = `
"import { APIClient, APIClientRequestOpts } from "@interweb/fetch-api-client";
"import { APIClient, APIClientRequestOpts, APIClientOptions } from "@interweb/fetch-api-client";
export interface Alertmanager {
apiVersion?: string;
kind?: string;
Expand Down Expand Up @@ -33379,7 +33379,7 @@ export interface WatchStorageV1VolumeAttachmentRequest {
export interface GetServiceAccountIssuerOpenIDKeysetRequest {}
export interface GetCodeVersionRequest {}
export class KubernetesClient extends APIClient {
constructor(options) {
constructor(options: APIClientOptions) {
super(options);
}
async getSwaggerJSON() {
Expand Down Expand Up @@ -37854,7 +37854,7 @@ export class KubernetesClient extends APIClient {
`;

exports[`swagger 1`] = `
"import { APIClient, APIClientRequestOpts } from "@interweb/fetch-api-client";
"import { APIClient, APIClientRequestOpts, APIClientOptions } from "@interweb/fetch-api-client";
/* com.coreos.monitoring.v1.Alertmanager */
/* 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.

Expand Down Expand Up @@ -76048,7 +76048,7 @@ export interface WatchStorageV1VolumeAttachmentRequest {
export interface GetServiceAccountIssuerOpenIDKeysetRequest {}
export interface GetCodeVersionRequest {}
export class KubernetesClient extends APIClient {
constructor(options) {
constructor(options: APIClientOptions) {
super(options);
}
async getSwaggerJSON() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`merged 1`] = `
"import { APIClient, APIClientRequestOpts } from "@interweb/fetch-api-client";
"import { APIClient, APIClientRequestOpts, APIClientOptions } from "@interweb/fetch-api-client";
export interface MutatingWebhook {
admissionReviewVersions: string[];
clientConfig: WebhookClientConfig;
Expand Down Expand Up @@ -10202,7 +10202,7 @@ export interface LogFileHandlerRequest {
export interface GetServiceAccountIssuerOpenIDKeysetRequest {}
export interface GetCodeVersionRequest {}
export class KubernetesClient extends APIClient {
constructor(options) {
constructor(options: APIClientOptions) {
super(options);
}
async getSwaggerJSON() {
Expand Down Expand Up @@ -13345,7 +13345,7 @@ export class KubernetesClient extends APIClient {
`;

exports[`swagger 1`] = `
"import { APIClient, APIClientRequestOpts } from "@interweb/fetch-api-client";
"import { APIClient, APIClientRequestOpts, APIClientOptions } from "@interweb/fetch-api-client";
/* io.k8s.api.admissionregistration.v1.MutatingWebhook */
/* MutatingWebhook describes an admission webhook and the resources and operations it applies to. */
export interface MutatingWebhook {
Expand Down Expand Up @@ -24939,7 +24939,7 @@ export interface LogFileHandlerRequest {
export interface GetServiceAccountIssuerOpenIDKeysetRequest {}
export interface GetCodeVersionRequest {}
export class KubernetesClient extends APIClient {
constructor(options) {
constructor(options: APIClientOptions) {
super(options);
}
async getSwaggerJSON() {
Expand Down
11 changes: 10 additions & 1 deletion packages/schema-sdk/src/openapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -608,11 +608,16 @@ export function generateOpenApiClient(
}
methods.push(...generateMethods(options, patchedSchema));

const constructorOptionsParam = t.identifier('options');
constructorOptionsParam.typeAnnotation = t.tsTypeAnnotation(
t.tsTypeReference(t.identifier('APIClientOptions'))
);

const classBody = t.classBody([
t.classMethod(
'constructor',
t.identifier('constructor'),
[t.identifier('options')],
[constructorOptionsParam],
t.blockStatement([
t.expressionStatement(
t.callExpression(t.super(), [t.identifier('options')])
Expand Down Expand Up @@ -656,6 +661,10 @@ export function generateOpenApiClient(
t.identifier('APIClientRequestOpts'),
t.identifier('APIClientRequestOpts')
),
t.importSpecifier(
t.identifier('APIClientOptions'),
t.identifier('APIClientOptions')
),
],
t.stringLiteral(options.npmApiClient)
),
Expand Down