Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix typescript-node generation when only models are generated #7127

Merged
merged 13 commits into from
Aug 28, 2020
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { {{ classname }} } from './{{ classFilename }}';
export * from './{{ classFilename }}Interface'
{{/withInterfaces}}
{{/apis}}
import * as fs from 'fs';
import * as http from 'http';

export class HttpError extends Error {
Expand All @@ -18,15 +17,7 @@ export class HttpError extends Error {
}
}

export interface RequestDetailedFile {
value: Buffer;
options?: {
filename?: string;
contentType?: string;
}
}

export type RequestFile = string | Buffer | fs.ReadStream | RequestDetailedFile;
export { RequestFile } from '../model/models';

export const APIS = [{{#apis}}{{#operations}}{{ classname }}{{/operations}}{{^-last}}, {{/-last}}{{/apis}}];
{{/apiInfo}}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{>licenseInfo}}
{{#models}}
{{#model}}
import { RequestFile } from '../api';
import { RequestFile } from './models';
{{#tsImports}}
import { {{classname}} } from '{{filename}}';
{{/tsImports}}
Expand Down Expand Up @@ -78,4 +78,4 @@ export enum {{classname}} {
}
{{/isEnum}}
{{/model}}
{{/models}}
{{/models}}
Original file line number Diff line number Diff line change
@@ -1,10 +1,27 @@
{{#generateApis}}
import localVarRequest from 'request';
{{/generateApis}}

{{#models}}
{{#model}}
export * from '{{{ classFilename }}}';
{{/model}}
{{/models}}

import localVarRequest from 'request';
import * as fs from 'fs';

export interface RequestDetailedFile {
value: Buffer;
options?: {
filename?: string;
contentType?: string;
}
}

export type RequestFile = string | Buffer | fs.ReadStream | RequestDetailedFile;

// Object serialization only relevant if generating APIs, too
sarumont marked this conversation as resolved.
Show resolved Hide resolved
{{#generateApis}}

{{#models}}
{{#model}}
Expand Down Expand Up @@ -235,3 +252,4 @@ export class VoidAuth implements Authentication {
}

export type Interceptor = (requestOptions: localVarRequest.Options) => (Promise<void> | void);
{{/generateApis}}
11 changes: 1 addition & 10 deletions samples/client/petstore/typescript-node/default/api/apis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ export * from './storeApi';
import { StoreApi } from './storeApi';
export * from './userApi';
import { UserApi } from './userApi';
import * as fs from 'fs';
import * as http from 'http';

export class HttpError extends Error {
Expand All @@ -14,14 +13,6 @@ export class HttpError extends Error {
}
}

export interface RequestDetailedFile {
value: Buffer;
options?: {
filename?: string;
contentType?: string;
}
}

export type RequestFile = string | Buffer | fs.ReadStream | RequestDetailedFile;
export { RequestFile } from '../model/models';

export const APIS = [PetApi, StoreApi, UserApi];
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* Do not edit the class manually.
*/

import { RequestFile } from '../api';
import { RequestFile } from './models';

/**
* Describes the result of uploading an image resource
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* Do not edit the class manually.
*/

import { RequestFile } from '../api';
import { RequestFile } from './models';

/**
* A category for a pet
Expand Down
19 changes: 19 additions & 0 deletions samples/client/petstore/typescript-node/default/model/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
export * from './apiResponse';
sarumont marked this conversation as resolved.
Show resolved Hide resolved
export * from './category';
export * from './order';
export * from './pet';
export * from './tag';
export * from './user';

import * as fs from 'fs';

export interface RequestDetailedFile {
value: Buffer;
options?: {
filename?: string;
contentType?: string;
}
}

export type RequestFile = string | Buffer | fs.ReadStream | RequestDetailedFile;

16 changes: 15 additions & 1 deletion samples/client/petstore/typescript-node/default/model/models.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
import localVarRequest from 'request';

export * from './apiResponse';
export * from './category';
export * from './order';
export * from './pet';
export * from './tag';
export * from './user';

import localVarRequest from 'request';
import * as fs from 'fs';

export interface RequestDetailedFile {
value: Buffer;
options?: {
filename?: string;
contentType?: string;
}
}

export type RequestFile = string | Buffer | fs.ReadStream | RequestDetailedFile;

// Object serialization only relevant if generating APIs, too

import { ApiResponse } from './apiResponse';
import { Category } from './category';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* Do not edit the class manually.
*/

import { RequestFile } from '../api';
import { RequestFile } from './models';

/**
* An order for a pets from the pet store
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* Do not edit the class manually.
*/

import { RequestFile } from '../api';
import { RequestFile } from './models';
import { Category } from './category';
import { Tag } from './tag';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* Do not edit the class manually.
*/

import { RequestFile } from '../api';
import { RequestFile } from './models';

/**
* A tag for a pet
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* Do not edit the class manually.
*/

import { RequestFile } from '../api';
import { RequestFile } from './models';

/**
* A User who is purchasing from the pet store
Expand Down
11 changes: 1 addition & 10 deletions samples/client/petstore/typescript-node/npm/api/apis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ export * from './storeApi';
import { StoreApi } from './storeApi';
export * from './userApi';
import { UserApi } from './userApi';
import * as fs from 'fs';
import * as http from 'http';

export class HttpError extends Error {
Expand All @@ -14,14 +13,6 @@ export class HttpError extends Error {
}
}

export interface RequestDetailedFile {
value: Buffer;
options?: {
filename?: string;
contentType?: string;
}
}

export type RequestFile = string | Buffer | fs.ReadStream | RequestDetailedFile;
export { RequestFile } from '../model/models';

export const APIS = [PetApi, StoreApi, UserApi];
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* Do not edit the class manually.
*/

import { RequestFile } from '../api';
import { RequestFile } from './models';

/**
* Describes the result of uploading an image resource
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* Do not edit the class manually.
*/

import { RequestFile } from '../api';
import { RequestFile } from './models';

/**
* A category for a pet
Expand Down
19 changes: 19 additions & 0 deletions samples/client/petstore/typescript-node/npm/model/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
export * from './apiResponse';
export * from './category';
export * from './order';
export * from './pet';
export * from './tag';
export * from './user';

import * as fs from 'fs';

export interface RequestDetailedFile {
value: Buffer;
options?: {
filename?: string;
contentType?: string;
}
}

export type RequestFile = string | Buffer | fs.ReadStream | RequestDetailedFile;

16 changes: 15 additions & 1 deletion samples/client/petstore/typescript-node/npm/model/models.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
import localVarRequest from 'request';

export * from './apiResponse';
export * from './category';
export * from './order';
export * from './pet';
export * from './tag';
export * from './user';

import localVarRequest from 'request';
import * as fs from 'fs';

export interface RequestDetailedFile {
value: Buffer;
options?: {
filename?: string;
contentType?: string;
}
}

export type RequestFile = string | Buffer | fs.ReadStream | RequestDetailedFile;

// Object serialization only relevant if generating APIs, too

import { ApiResponse } from './apiResponse';
import { Category } from './category';
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/typescript-node/npm/model/order.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* Do not edit the class manually.
*/

import { RequestFile } from '../api';
import { RequestFile } from './models';

/**
* An order for a pets from the pet store
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/typescript-node/npm/model/pet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* Do not edit the class manually.
*/

import { RequestFile } from '../api';
import { RequestFile } from './models';
import { Category } from './category';
import { Tag } from './tag';

Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/typescript-node/npm/model/tag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* Do not edit the class manually.
*/

import { RequestFile } from '../api';
import { RequestFile } from './models';

/**
* A tag for a pet
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/typescript-node/npm/model/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* Do not edit the class manually.
*/

import { RequestFile } from '../api';
import { RequestFile } from './models';

/**
* A User who is purchasing from the pet store
Expand Down