From c66f811c418f673fbd6029e2c1f51e62b25e397a Mon Sep 17 00:00:00 2001 From: Richard Kolkovich Date: Tue, 4 Aug 2020 13:38:12 -0600 Subject: [PATCH 1/8] add model/index.ts - move export of all models to model/index.ts - move RequestFile definition to model/index.ts This fixes #7126 --- .../languages/TypeScriptNodeClientCodegen.java | 1 + .../resources/typescript-node/api-all.mustache | 11 ----------- .../typescript-node/api-single.mustache | 3 ++- .../typescript-node/model-index.mustache | 18 ++++++++++++++++++ .../resources/typescript-node/model.mustache | 4 ++-- .../resources/typescript-node/models.mustache | 6 ------ 6 files changed, 23 insertions(+), 20 deletions(-) create mode 100644 modules/openapi-generator/src/main/resources/typescript-node/model-index.mustache diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptNodeClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptNodeClientCodegen.java index 09d5ae4df4e8..d7f231b9665b 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptNodeClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptNodeClientCodegen.java @@ -241,6 +241,7 @@ public void setNpmRepository(String npmRepository) { public void processOpts() { super.processOpts(); supportingFiles.add(new SupportingFile("models.mustache", modelPackage().replace('.', File.separatorChar), "models.ts")); + supportingFiles.add(new SupportingFile("model-index.mustache", modelPackage().replace('.', File.separatorChar), "index.ts")); supportingFiles.add(new SupportingFile("api-all.mustache", apiPackage().replace('.', File.separatorChar), "apis.ts")); supportingFiles.add(new SupportingFile("api.mustache", getIndexDirectory(), "api.ts")); supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh")); diff --git a/modules/openapi-generator/src/main/resources/typescript-node/api-all.mustache b/modules/openapi-generator/src/main/resources/typescript-node/api-all.mustache index 3092696f5744..1a8d2f1dbd6e 100644 --- a/modules/openapi-generator/src/main/resources/typescript-node/api-all.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-node/api-all.mustache @@ -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 { @@ -18,15 +17,5 @@ export class HttpError extends Error { } } -export interface RequestDetailedFile { - value: Buffer; - options?: { - filename?: string; - contentType?: string; - } -} - -export type RequestFile = string | Buffer | fs.ReadStream | RequestDetailedFile; - export const APIS = [{{#apis}}{{#operations}}{{ classname }}{{/operations}}{{^-last}}, {{/-last}}{{/apis}}]; {{/apiInfo}} diff --git a/modules/openapi-generator/src/main/resources/typescript-node/api-single.mustache b/modules/openapi-generator/src/main/resources/typescript-node/api-single.mustache index e8a6cc5bf360..7e733dffb013 100644 --- a/modules/openapi-generator/src/main/resources/typescript-node/api-single.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-node/api-single.mustache @@ -13,7 +13,8 @@ import { ObjectSerializer, Authentication, VoidAuth, Interceptor } from '../mode import { HttpBasicAuth, HttpBearerAuth, ApiKeyAuth, OAuth } from '../model/models'; {{/hasAuthMethods}} -import { HttpError, RequestFile } from './apis'; +import { HttpError } from './apis'; +import { RequestFile } from '../model'; let defaultBasePath = '{{{basePath}}}'; diff --git a/modules/openapi-generator/src/main/resources/typescript-node/model-index.mustache b/modules/openapi-generator/src/main/resources/typescript-node/model-index.mustache new file mode 100644 index 000000000000..16f93cbe5e8e --- /dev/null +++ b/modules/openapi-generator/src/main/resources/typescript-node/model-index.mustache @@ -0,0 +1,18 @@ +{{#models}} +{{#model}} +export * from '{{{ classFilename }}}'; +{{/model}} +{{/models}} + +import * as fs from 'fs'; + +export interface RequestDetailedFile { + value: Buffer; + options?: { + filename?: string; + contentType?: string; + } +} + +export type RequestFile = string | Buffer | fs.ReadStream | RequestDetailedFile; + diff --git a/modules/openapi-generator/src/main/resources/typescript-node/model.mustache b/modules/openapi-generator/src/main/resources/typescript-node/model.mustache index 521bce34d767..1472d83a0863 100644 --- a/modules/openapi-generator/src/main/resources/typescript-node/model.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-node/model.mustache @@ -1,7 +1,7 @@ {{>licenseInfo}} {{#models}} {{#model}} -import { RequestFile } from '../api'; +import { RequestFile } from './'; {{#tsImports}} import { {{classname}} } from '{{filename}}'; {{/tsImports}} @@ -78,4 +78,4 @@ export enum {{classname}} { } {{/isEnum}} {{/model}} -{{/models}} \ No newline at end of file +{{/models}} diff --git a/modules/openapi-generator/src/main/resources/typescript-node/models.mustache b/modules/openapi-generator/src/main/resources/typescript-node/models.mustache index 41bf1422eab8..250a5c22fc2c 100644 --- a/modules/openapi-generator/src/main/resources/typescript-node/models.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-node/models.mustache @@ -1,9 +1,3 @@ -{{#models}} -{{#model}} -export * from '{{{ classFilename }}}'; -{{/model}} -{{/models}} - import localVarRequest from 'request'; {{#models}} From 936b76424f267ec6303a752a90c489988be609b6 Mon Sep 17 00:00:00 2001 From: Richard Kolkovich Date: Tue, 4 Aug 2020 13:54:34 -0600 Subject: [PATCH 2/8] update samples --- .../builds/default/.openapi-generator/FILES | 12 ++++++------ .../builds/with-npm/.openapi-generator/FILES | 12 ++++++------ .../builds/default/.openapi-generator/FILES | 12 ++++++------ .../builds/with-npm/.openapi-generator/FILES | 12 ++++++------ .../builds/default/.openapi-generator/FILES | 12 ++++++------ .../builds/with-npm/.openapi-generator/FILES | 12 ++++++------ .../builds/default/.openapi-generator/FILES | 12 ++++++------ .../builds/with-npm/.openapi-generator/FILES | 12 ++++++------ .../builds/default/.openapi-generator/FILES | 12 ++++++------ .../builds/with-npm/.openapi-generator/FILES | 12 ++++++------ .../.openapi-generator/FILES | 12 ++++++------ .../builds/with-npm/.openapi-generator/FILES | 12 ++++++------ .../.openapi-generator/FILES | 12 ++++++------ .../builds/default/.openapi-generator/FILES | 12 ++++++------ .../builds/with-npm/.openapi-generator/FILES | 12 ++++++------ .../default/.openapi-generator/FILES | 13 +++++++------ .../typescript-node/default/api/apis.ts | 11 ----------- .../typescript-node/default/api/petApi.ts | 3 ++- .../typescript-node/default/api/storeApi.ts | 3 ++- .../typescript-node/default/api/userApi.ts | 3 ++- .../default/model/apiResponse.ts | 2 +- .../typescript-node/default/model/category.ts | 2 +- .../typescript-node/default/model/index.ts | 19 +++++++++++++++++++ .../typescript-node/default/model/models.ts | 7 ------- .../typescript-node/default/model/order.ts | 2 +- .../typescript-node/default/model/pet.ts | 2 +- .../typescript-node/default/model/tag.ts | 2 +- .../typescript-node/default/model/user.ts | 2 +- .../npm/.openapi-generator/FILES | 13 +++++++------ .../petstore/typescript-node/npm/api/apis.ts | 11 ----------- .../typescript-node/npm/api/petApi.ts | 3 ++- .../typescript-node/npm/api/storeApi.ts | 3 ++- .../typescript-node/npm/api/userApi.ts | 3 ++- .../typescript-node/npm/model/apiResponse.ts | 2 +- .../typescript-node/npm/model/category.ts | 2 +- .../typescript-node/npm/model/index.ts | 19 +++++++++++++++++++ .../typescript-node/npm/model/models.ts | 7 ------- .../typescript-node/npm/model/order.ts | 2 +- .../petstore/typescript-node/npm/model/pet.ts | 2 +- .../petstore/typescript-node/npm/model/tag.ts | 2 +- .../typescript-node/npm/model/user.ts | 2 +- 41 files changed, 166 insertions(+), 156 deletions(-) create mode 100644 samples/client/petstore/typescript-node/default/model/index.ts create mode 100644 samples/client/petstore/typescript-node/npm/model/index.ts diff --git a/samples/client/petstore/typescript-angular-v10-provided-in-root/builds/default/.openapi-generator/FILES b/samples/client/petstore/typescript-angular-v10-provided-in-root/builds/default/.openapi-generator/FILES index bc66e2a3865f..7f11560dda7f 100644 --- a/samples/client/petstore/typescript-angular-v10-provided-in-root/builds/default/.openapi-generator/FILES +++ b/samples/client/petstore/typescript-angular-v10-provided-in-root/builds/default/.openapi-generator/FILES @@ -9,11 +9,11 @@ configuration.ts encoder.ts git_push.sh index.ts -model/./apiResponse.ts -model/./category.ts -model/./order.ts -model/./pet.ts -model/./tag.ts -model/./user.ts +model/apiResponse.ts +model/category.ts +model/order.ts +model/pet.ts +model/tag.ts +model/user.ts model/models.ts variables.ts diff --git a/samples/client/petstore/typescript-angular-v10-provided-in-root/builds/with-npm/.openapi-generator/FILES b/samples/client/petstore/typescript-angular-v10-provided-in-root/builds/with-npm/.openapi-generator/FILES index a2650d9db088..d85eeefc6f26 100644 --- a/samples/client/petstore/typescript-angular-v10-provided-in-root/builds/with-npm/.openapi-generator/FILES +++ b/samples/client/petstore/typescript-angular-v10-provided-in-root/builds/with-npm/.openapi-generator/FILES @@ -9,12 +9,12 @@ configuration.ts encoder.ts git_push.sh index.ts -model/./apiResponse.ts -model/./category.ts -model/./order.ts -model/./pet.ts -model/./tag.ts -model/./user.ts +model/apiResponse.ts +model/category.ts +model/order.ts +model/pet.ts +model/tag.ts +model/user.ts model/models.ts ng-package.json package.json diff --git a/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/default/.openapi-generator/FILES b/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/default/.openapi-generator/FILES index bc66e2a3865f..7f11560dda7f 100644 --- a/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/default/.openapi-generator/FILES +++ b/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/default/.openapi-generator/FILES @@ -9,11 +9,11 @@ configuration.ts encoder.ts git_push.sh index.ts -model/./apiResponse.ts -model/./category.ts -model/./order.ts -model/./pet.ts -model/./tag.ts -model/./user.ts +model/apiResponse.ts +model/category.ts +model/order.ts +model/pet.ts +model/tag.ts +model/user.ts model/models.ts variables.ts diff --git a/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/with-npm/.openapi-generator/FILES b/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/with-npm/.openapi-generator/FILES index a2650d9db088..d85eeefc6f26 100644 --- a/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/with-npm/.openapi-generator/FILES +++ b/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/with-npm/.openapi-generator/FILES @@ -9,12 +9,12 @@ configuration.ts encoder.ts git_push.sh index.ts -model/./apiResponse.ts -model/./category.ts -model/./order.ts -model/./pet.ts -model/./tag.ts -model/./user.ts +model/apiResponse.ts +model/category.ts +model/order.ts +model/pet.ts +model/tag.ts +model/user.ts model/models.ts ng-package.json package.json diff --git a/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/default/.openapi-generator/FILES b/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/default/.openapi-generator/FILES index bc66e2a3865f..7f11560dda7f 100644 --- a/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/default/.openapi-generator/FILES +++ b/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/default/.openapi-generator/FILES @@ -9,11 +9,11 @@ configuration.ts encoder.ts git_push.sh index.ts -model/./apiResponse.ts -model/./category.ts -model/./order.ts -model/./pet.ts -model/./tag.ts -model/./user.ts +model/apiResponse.ts +model/category.ts +model/order.ts +model/pet.ts +model/tag.ts +model/user.ts model/models.ts variables.ts diff --git a/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/with-npm/.openapi-generator/FILES b/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/with-npm/.openapi-generator/FILES index a2650d9db088..d85eeefc6f26 100644 --- a/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/with-npm/.openapi-generator/FILES +++ b/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/with-npm/.openapi-generator/FILES @@ -9,12 +9,12 @@ configuration.ts encoder.ts git_push.sh index.ts -model/./apiResponse.ts -model/./category.ts -model/./order.ts -model/./pet.ts -model/./tag.ts -model/./user.ts +model/apiResponse.ts +model/category.ts +model/order.ts +model/pet.ts +model/tag.ts +model/user.ts model/models.ts ng-package.json package.json diff --git a/samples/client/petstore/typescript-angular-v7-not-provided-in-root/builds/default/.openapi-generator/FILES b/samples/client/petstore/typescript-angular-v7-not-provided-in-root/builds/default/.openapi-generator/FILES index bc66e2a3865f..7f11560dda7f 100644 --- a/samples/client/petstore/typescript-angular-v7-not-provided-in-root/builds/default/.openapi-generator/FILES +++ b/samples/client/petstore/typescript-angular-v7-not-provided-in-root/builds/default/.openapi-generator/FILES @@ -9,11 +9,11 @@ configuration.ts encoder.ts git_push.sh index.ts -model/./apiResponse.ts -model/./category.ts -model/./order.ts -model/./pet.ts -model/./tag.ts -model/./user.ts +model/apiResponse.ts +model/category.ts +model/order.ts +model/pet.ts +model/tag.ts +model/user.ts model/models.ts variables.ts diff --git a/samples/client/petstore/typescript-angular-v7-not-provided-in-root/builds/with-npm/.openapi-generator/FILES b/samples/client/petstore/typescript-angular-v7-not-provided-in-root/builds/with-npm/.openapi-generator/FILES index a2650d9db088..d85eeefc6f26 100644 --- a/samples/client/petstore/typescript-angular-v7-not-provided-in-root/builds/with-npm/.openapi-generator/FILES +++ b/samples/client/petstore/typescript-angular-v7-not-provided-in-root/builds/with-npm/.openapi-generator/FILES @@ -9,12 +9,12 @@ configuration.ts encoder.ts git_push.sh index.ts -model/./apiResponse.ts -model/./category.ts -model/./order.ts -model/./pet.ts -model/./tag.ts -model/./user.ts +model/apiResponse.ts +model/category.ts +model/order.ts +model/pet.ts +model/tag.ts +model/user.ts model/models.ts ng-package.json package.json diff --git a/samples/client/petstore/typescript-angular-v7-provided-in-root/builds/default/.openapi-generator/FILES b/samples/client/petstore/typescript-angular-v7-provided-in-root/builds/default/.openapi-generator/FILES index bc66e2a3865f..7f11560dda7f 100644 --- a/samples/client/petstore/typescript-angular-v7-provided-in-root/builds/default/.openapi-generator/FILES +++ b/samples/client/petstore/typescript-angular-v7-provided-in-root/builds/default/.openapi-generator/FILES @@ -9,11 +9,11 @@ configuration.ts encoder.ts git_push.sh index.ts -model/./apiResponse.ts -model/./category.ts -model/./order.ts -model/./pet.ts -model/./tag.ts -model/./user.ts +model/apiResponse.ts +model/category.ts +model/order.ts +model/pet.ts +model/tag.ts +model/user.ts model/models.ts variables.ts diff --git a/samples/client/petstore/typescript-angular-v7-provided-in-root/builds/with-npm/.openapi-generator/FILES b/samples/client/petstore/typescript-angular-v7-provided-in-root/builds/with-npm/.openapi-generator/FILES index a2650d9db088..d85eeefc6f26 100644 --- a/samples/client/petstore/typescript-angular-v7-provided-in-root/builds/with-npm/.openapi-generator/FILES +++ b/samples/client/petstore/typescript-angular-v7-provided-in-root/builds/with-npm/.openapi-generator/FILES @@ -9,12 +9,12 @@ configuration.ts encoder.ts git_push.sh index.ts -model/./apiResponse.ts -model/./category.ts -model/./order.ts -model/./pet.ts -model/./tag.ts -model/./user.ts +model/apiResponse.ts +model/category.ts +model/order.ts +model/pet.ts +model/tag.ts +model/user.ts model/models.ts ng-package.json package.json diff --git a/samples/client/petstore/typescript-angular-v8-provided-in-root/builds/single-request-parameter/.openapi-generator/FILES b/samples/client/petstore/typescript-angular-v8-provided-in-root/builds/single-request-parameter/.openapi-generator/FILES index a2650d9db088..d85eeefc6f26 100644 --- a/samples/client/petstore/typescript-angular-v8-provided-in-root/builds/single-request-parameter/.openapi-generator/FILES +++ b/samples/client/petstore/typescript-angular-v8-provided-in-root/builds/single-request-parameter/.openapi-generator/FILES @@ -9,12 +9,12 @@ configuration.ts encoder.ts git_push.sh index.ts -model/./apiResponse.ts -model/./category.ts -model/./order.ts -model/./pet.ts -model/./tag.ts -model/./user.ts +model/apiResponse.ts +model/category.ts +model/order.ts +model/pet.ts +model/tag.ts +model/user.ts model/models.ts ng-package.json package.json diff --git a/samples/client/petstore/typescript-angular-v8-provided-in-root/builds/with-npm/.openapi-generator/FILES b/samples/client/petstore/typescript-angular-v8-provided-in-root/builds/with-npm/.openapi-generator/FILES index a2650d9db088..d85eeefc6f26 100644 --- a/samples/client/petstore/typescript-angular-v8-provided-in-root/builds/with-npm/.openapi-generator/FILES +++ b/samples/client/petstore/typescript-angular-v8-provided-in-root/builds/with-npm/.openapi-generator/FILES @@ -9,12 +9,12 @@ configuration.ts encoder.ts git_push.sh index.ts -model/./apiResponse.ts -model/./category.ts -model/./order.ts -model/./pet.ts -model/./tag.ts -model/./user.ts +model/apiResponse.ts +model/category.ts +model/order.ts +model/pet.ts +model/tag.ts +model/user.ts model/models.ts ng-package.json package.json diff --git a/samples/client/petstore/typescript-angular-v8-provided-in-root/builds/with-prefixed-module-name/.openapi-generator/FILES b/samples/client/petstore/typescript-angular-v8-provided-in-root/builds/with-prefixed-module-name/.openapi-generator/FILES index a2650d9db088..d85eeefc6f26 100644 --- a/samples/client/petstore/typescript-angular-v8-provided-in-root/builds/with-prefixed-module-name/.openapi-generator/FILES +++ b/samples/client/petstore/typescript-angular-v8-provided-in-root/builds/with-prefixed-module-name/.openapi-generator/FILES @@ -9,12 +9,12 @@ configuration.ts encoder.ts git_push.sh index.ts -model/./apiResponse.ts -model/./category.ts -model/./order.ts -model/./pet.ts -model/./tag.ts -model/./user.ts +model/apiResponse.ts +model/category.ts +model/order.ts +model/pet.ts +model/tag.ts +model/user.ts model/models.ts ng-package.json package.json diff --git a/samples/client/petstore/typescript-angular-v9-provided-in-root/builds/default/.openapi-generator/FILES b/samples/client/petstore/typescript-angular-v9-provided-in-root/builds/default/.openapi-generator/FILES index bc66e2a3865f..7f11560dda7f 100644 --- a/samples/client/petstore/typescript-angular-v9-provided-in-root/builds/default/.openapi-generator/FILES +++ b/samples/client/petstore/typescript-angular-v9-provided-in-root/builds/default/.openapi-generator/FILES @@ -9,11 +9,11 @@ configuration.ts encoder.ts git_push.sh index.ts -model/./apiResponse.ts -model/./category.ts -model/./order.ts -model/./pet.ts -model/./tag.ts -model/./user.ts +model/apiResponse.ts +model/category.ts +model/order.ts +model/pet.ts +model/tag.ts +model/user.ts model/models.ts variables.ts diff --git a/samples/client/petstore/typescript-angular-v9-provided-in-root/builds/with-npm/.openapi-generator/FILES b/samples/client/petstore/typescript-angular-v9-provided-in-root/builds/with-npm/.openapi-generator/FILES index a2650d9db088..d85eeefc6f26 100644 --- a/samples/client/petstore/typescript-angular-v9-provided-in-root/builds/with-npm/.openapi-generator/FILES +++ b/samples/client/petstore/typescript-angular-v9-provided-in-root/builds/with-npm/.openapi-generator/FILES @@ -9,12 +9,12 @@ configuration.ts encoder.ts git_push.sh index.ts -model/./apiResponse.ts -model/./category.ts -model/./order.ts -model/./pet.ts -model/./tag.ts -model/./user.ts +model/apiResponse.ts +model/category.ts +model/order.ts +model/pet.ts +model/tag.ts +model/user.ts model/models.ts ng-package.json package.json diff --git a/samples/client/petstore/typescript-node/default/.openapi-generator/FILES b/samples/client/petstore/typescript-node/default/.openapi-generator/FILES index c4f1df469e4b..ef154e74955a 100644 --- a/samples/client/petstore/typescript-node/default/.openapi-generator/FILES +++ b/samples/client/petstore/typescript-node/default/.openapi-generator/FILES @@ -5,10 +5,11 @@ api/petApi.ts api/storeApi.ts api/userApi.ts git_push.sh -model/./apiResponse.ts -model/./category.ts -model/./order.ts -model/./pet.ts -model/./tag.ts -model/./user.ts +model/apiResponse.ts +model/category.ts +model/order.ts +model/pet.ts +model/tag.ts +model/user.ts +model/index.ts model/models.ts diff --git a/samples/client/petstore/typescript-node/default/api/apis.ts b/samples/client/petstore/typescript-node/default/api/apis.ts index 50e5ef8303a9..022a0383c494 100644 --- a/samples/client/petstore/typescript-node/default/api/apis.ts +++ b/samples/client/petstore/typescript-node/default/api/apis.ts @@ -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 { @@ -14,14 +13,4 @@ export class HttpError extends Error { } } -export interface RequestDetailedFile { - value: Buffer; - options?: { - filename?: string; - contentType?: string; - } -} - -export type RequestFile = string | Buffer | fs.ReadStream | RequestDetailedFile; - export const APIS = [PetApi, StoreApi, UserApi]; diff --git a/samples/client/petstore/typescript-node/default/api/petApi.ts b/samples/client/petstore/typescript-node/default/api/petApi.ts index f9bc6cfb93d7..52ec608a5f76 100644 --- a/samples/client/petstore/typescript-node/default/api/petApi.ts +++ b/samples/client/petstore/typescript-node/default/api/petApi.ts @@ -21,7 +21,8 @@ import { Pet } from '../model/pet'; import { ObjectSerializer, Authentication, VoidAuth, Interceptor } from '../model/models'; import { HttpBasicAuth, HttpBearerAuth, ApiKeyAuth, OAuth } from '../model/models'; -import { HttpError, RequestFile } from './apis'; +import { HttpError } from './apis'; +import { RequestFile } from '../model'; let defaultBasePath = 'http://petstore.swagger.io/v2'; diff --git a/samples/client/petstore/typescript-node/default/api/storeApi.ts b/samples/client/petstore/typescript-node/default/api/storeApi.ts index 075dc6126fb3..23da295bf4aa 100644 --- a/samples/client/petstore/typescript-node/default/api/storeApi.ts +++ b/samples/client/petstore/typescript-node/default/api/storeApi.ts @@ -20,7 +20,8 @@ import { Order } from '../model/order'; import { ObjectSerializer, Authentication, VoidAuth, Interceptor } from '../model/models'; import { HttpBasicAuth, HttpBearerAuth, ApiKeyAuth, OAuth } from '../model/models'; -import { HttpError, RequestFile } from './apis'; +import { HttpError } from './apis'; +import { RequestFile } from '../model'; let defaultBasePath = 'http://petstore.swagger.io/v2'; diff --git a/samples/client/petstore/typescript-node/default/api/userApi.ts b/samples/client/petstore/typescript-node/default/api/userApi.ts index 6122ed4221e6..dda07522c876 100644 --- a/samples/client/petstore/typescript-node/default/api/userApi.ts +++ b/samples/client/petstore/typescript-node/default/api/userApi.ts @@ -19,7 +19,8 @@ import { User } from '../model/user'; import { ObjectSerializer, Authentication, VoidAuth, Interceptor } from '../model/models'; -import { HttpError, RequestFile } from './apis'; +import { HttpError } from './apis'; +import { RequestFile } from '../model'; let defaultBasePath = 'http://petstore.swagger.io/v2'; diff --git a/samples/client/petstore/typescript-node/default/model/apiResponse.ts b/samples/client/petstore/typescript-node/default/model/apiResponse.ts index ae84669a8422..59236cdec4f6 100644 --- a/samples/client/petstore/typescript-node/default/model/apiResponse.ts +++ b/samples/client/petstore/typescript-node/default/model/apiResponse.ts @@ -10,7 +10,7 @@ * Do not edit the class manually. */ -import { RequestFile } from '../api'; +import { RequestFile } from './'; /** * Describes the result of uploading an image resource diff --git a/samples/client/petstore/typescript-node/default/model/category.ts b/samples/client/petstore/typescript-node/default/model/category.ts index 1babd0fd22e3..4dde2adb5b13 100644 --- a/samples/client/petstore/typescript-node/default/model/category.ts +++ b/samples/client/petstore/typescript-node/default/model/category.ts @@ -10,7 +10,7 @@ * Do not edit the class manually. */ -import { RequestFile } from '../api'; +import { RequestFile } from './'; /** * A category for a pet diff --git a/samples/client/petstore/typescript-node/default/model/index.ts b/samples/client/petstore/typescript-node/default/model/index.ts new file mode 100644 index 000000000000..7c953d0c5d6c --- /dev/null +++ b/samples/client/petstore/typescript-node/default/model/index.ts @@ -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; + diff --git a/samples/client/petstore/typescript-node/default/model/models.ts b/samples/client/petstore/typescript-node/default/model/models.ts index 1da13addd120..7d186ff09814 100644 --- a/samples/client/petstore/typescript-node/default/model/models.ts +++ b/samples/client/petstore/typescript-node/default/model/models.ts @@ -1,10 +1,3 @@ -export * from './apiResponse'; -export * from './category'; -export * from './order'; -export * from './pet'; -export * from './tag'; -export * from './user'; - import localVarRequest from 'request'; import { ApiResponse } from './apiResponse'; diff --git a/samples/client/petstore/typescript-node/default/model/order.ts b/samples/client/petstore/typescript-node/default/model/order.ts index 1ee3ea280c61..4d52e243dcc3 100644 --- a/samples/client/petstore/typescript-node/default/model/order.ts +++ b/samples/client/petstore/typescript-node/default/model/order.ts @@ -10,7 +10,7 @@ * Do not edit the class manually. */ -import { RequestFile } from '../api'; +import { RequestFile } from './'; /** * An order for a pets from the pet store diff --git a/samples/client/petstore/typescript-node/default/model/pet.ts b/samples/client/petstore/typescript-node/default/model/pet.ts index 141c4ebc17c9..1622e5282306 100644 --- a/samples/client/petstore/typescript-node/default/model/pet.ts +++ b/samples/client/petstore/typescript-node/default/model/pet.ts @@ -10,7 +10,7 @@ * Do not edit the class manually. */ -import { RequestFile } from '../api'; +import { RequestFile } from './'; import { Category } from './category'; import { Tag } from './tag'; diff --git a/samples/client/petstore/typescript-node/default/model/tag.ts b/samples/client/petstore/typescript-node/default/model/tag.ts index 96e644974ef1..bbfa6ef37f35 100644 --- a/samples/client/petstore/typescript-node/default/model/tag.ts +++ b/samples/client/petstore/typescript-node/default/model/tag.ts @@ -10,7 +10,7 @@ * Do not edit the class manually. */ -import { RequestFile } from '../api'; +import { RequestFile } from './'; /** * A tag for a pet diff --git a/samples/client/petstore/typescript-node/default/model/user.ts b/samples/client/petstore/typescript-node/default/model/user.ts index 62b0b6436898..7c86fb7664cc 100644 --- a/samples/client/petstore/typescript-node/default/model/user.ts +++ b/samples/client/petstore/typescript-node/default/model/user.ts @@ -10,7 +10,7 @@ * Do not edit the class manually. */ -import { RequestFile } from '../api'; +import { RequestFile } from './'; /** * A User who is purchasing from the pet store diff --git a/samples/client/petstore/typescript-node/npm/.openapi-generator/FILES b/samples/client/petstore/typescript-node/npm/.openapi-generator/FILES index 914f5ced854a..31854c240c5b 100644 --- a/samples/client/petstore/typescript-node/npm/.openapi-generator/FILES +++ b/samples/client/petstore/typescript-node/npm/.openapi-generator/FILES @@ -5,12 +5,13 @@ api/petApi.ts api/storeApi.ts api/userApi.ts git_push.sh -model/./apiResponse.ts -model/./category.ts -model/./order.ts -model/./pet.ts -model/./tag.ts -model/./user.ts +model/apiResponse.ts +model/category.ts +model/order.ts +model/pet.ts +model/tag.ts +model/user.ts +model/index.ts model/models.ts package.json tsconfig.json diff --git a/samples/client/petstore/typescript-node/npm/api/apis.ts b/samples/client/petstore/typescript-node/npm/api/apis.ts index 50e5ef8303a9..022a0383c494 100644 --- a/samples/client/petstore/typescript-node/npm/api/apis.ts +++ b/samples/client/petstore/typescript-node/npm/api/apis.ts @@ -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 { @@ -14,14 +13,4 @@ export class HttpError extends Error { } } -export interface RequestDetailedFile { - value: Buffer; - options?: { - filename?: string; - contentType?: string; - } -} - -export type RequestFile = string | Buffer | fs.ReadStream | RequestDetailedFile; - export const APIS = [PetApi, StoreApi, UserApi]; diff --git a/samples/client/petstore/typescript-node/npm/api/petApi.ts b/samples/client/petstore/typescript-node/npm/api/petApi.ts index f9bc6cfb93d7..52ec608a5f76 100644 --- a/samples/client/petstore/typescript-node/npm/api/petApi.ts +++ b/samples/client/petstore/typescript-node/npm/api/petApi.ts @@ -21,7 +21,8 @@ import { Pet } from '../model/pet'; import { ObjectSerializer, Authentication, VoidAuth, Interceptor } from '../model/models'; import { HttpBasicAuth, HttpBearerAuth, ApiKeyAuth, OAuth } from '../model/models'; -import { HttpError, RequestFile } from './apis'; +import { HttpError } from './apis'; +import { RequestFile } from '../model'; let defaultBasePath = 'http://petstore.swagger.io/v2'; diff --git a/samples/client/petstore/typescript-node/npm/api/storeApi.ts b/samples/client/petstore/typescript-node/npm/api/storeApi.ts index 075dc6126fb3..23da295bf4aa 100644 --- a/samples/client/petstore/typescript-node/npm/api/storeApi.ts +++ b/samples/client/petstore/typescript-node/npm/api/storeApi.ts @@ -20,7 +20,8 @@ import { Order } from '../model/order'; import { ObjectSerializer, Authentication, VoidAuth, Interceptor } from '../model/models'; import { HttpBasicAuth, HttpBearerAuth, ApiKeyAuth, OAuth } from '../model/models'; -import { HttpError, RequestFile } from './apis'; +import { HttpError } from './apis'; +import { RequestFile } from '../model'; let defaultBasePath = 'http://petstore.swagger.io/v2'; diff --git a/samples/client/petstore/typescript-node/npm/api/userApi.ts b/samples/client/petstore/typescript-node/npm/api/userApi.ts index 6122ed4221e6..dda07522c876 100644 --- a/samples/client/petstore/typescript-node/npm/api/userApi.ts +++ b/samples/client/petstore/typescript-node/npm/api/userApi.ts @@ -19,7 +19,8 @@ import { User } from '../model/user'; import { ObjectSerializer, Authentication, VoidAuth, Interceptor } from '../model/models'; -import { HttpError, RequestFile } from './apis'; +import { HttpError } from './apis'; +import { RequestFile } from '../model'; let defaultBasePath = 'http://petstore.swagger.io/v2'; diff --git a/samples/client/petstore/typescript-node/npm/model/apiResponse.ts b/samples/client/petstore/typescript-node/npm/model/apiResponse.ts index ae84669a8422..59236cdec4f6 100644 --- a/samples/client/petstore/typescript-node/npm/model/apiResponse.ts +++ b/samples/client/petstore/typescript-node/npm/model/apiResponse.ts @@ -10,7 +10,7 @@ * Do not edit the class manually. */ -import { RequestFile } from '../api'; +import { RequestFile } from './'; /** * Describes the result of uploading an image resource diff --git a/samples/client/petstore/typescript-node/npm/model/category.ts b/samples/client/petstore/typescript-node/npm/model/category.ts index 1babd0fd22e3..4dde2adb5b13 100644 --- a/samples/client/petstore/typescript-node/npm/model/category.ts +++ b/samples/client/petstore/typescript-node/npm/model/category.ts @@ -10,7 +10,7 @@ * Do not edit the class manually. */ -import { RequestFile } from '../api'; +import { RequestFile } from './'; /** * A category for a pet diff --git a/samples/client/petstore/typescript-node/npm/model/index.ts b/samples/client/petstore/typescript-node/npm/model/index.ts new file mode 100644 index 000000000000..7c953d0c5d6c --- /dev/null +++ b/samples/client/petstore/typescript-node/npm/model/index.ts @@ -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; + diff --git a/samples/client/petstore/typescript-node/npm/model/models.ts b/samples/client/petstore/typescript-node/npm/model/models.ts index 1da13addd120..7d186ff09814 100644 --- a/samples/client/petstore/typescript-node/npm/model/models.ts +++ b/samples/client/petstore/typescript-node/npm/model/models.ts @@ -1,10 +1,3 @@ -export * from './apiResponse'; -export * from './category'; -export * from './order'; -export * from './pet'; -export * from './tag'; -export * from './user'; - import localVarRequest from 'request'; import { ApiResponse } from './apiResponse'; diff --git a/samples/client/petstore/typescript-node/npm/model/order.ts b/samples/client/petstore/typescript-node/npm/model/order.ts index 1ee3ea280c61..4d52e243dcc3 100644 --- a/samples/client/petstore/typescript-node/npm/model/order.ts +++ b/samples/client/petstore/typescript-node/npm/model/order.ts @@ -10,7 +10,7 @@ * Do not edit the class manually. */ -import { RequestFile } from '../api'; +import { RequestFile } from './'; /** * An order for a pets from the pet store diff --git a/samples/client/petstore/typescript-node/npm/model/pet.ts b/samples/client/petstore/typescript-node/npm/model/pet.ts index 141c4ebc17c9..1622e5282306 100644 --- a/samples/client/petstore/typescript-node/npm/model/pet.ts +++ b/samples/client/petstore/typescript-node/npm/model/pet.ts @@ -10,7 +10,7 @@ * Do not edit the class manually. */ -import { RequestFile } from '../api'; +import { RequestFile } from './'; import { Category } from './category'; import { Tag } from './tag'; diff --git a/samples/client/petstore/typescript-node/npm/model/tag.ts b/samples/client/petstore/typescript-node/npm/model/tag.ts index 96e644974ef1..bbfa6ef37f35 100644 --- a/samples/client/petstore/typescript-node/npm/model/tag.ts +++ b/samples/client/petstore/typescript-node/npm/model/tag.ts @@ -10,7 +10,7 @@ * Do not edit the class manually. */ -import { RequestFile } from '../api'; +import { RequestFile } from './'; /** * A tag for a pet diff --git a/samples/client/petstore/typescript-node/npm/model/user.ts b/samples/client/petstore/typescript-node/npm/model/user.ts index 62b0b6436898..7c86fb7664cc 100644 --- a/samples/client/petstore/typescript-node/npm/model/user.ts +++ b/samples/client/petstore/typescript-node/npm/model/user.ts @@ -10,7 +10,7 @@ * Do not edit the class manually. */ -import { RequestFile } from '../api'; +import { RequestFile } from './'; /** * A User who is purchasing from the pet store From fe55d197e924453633f14cacb75a72469ce23b22 Mon Sep 17 00:00:00 2001 From: Richard Kolkovich Date: Tue, 4 Aug 2020 14:37:38 -0600 Subject: [PATCH 3/8] Back out models/index.ts Make this backwards-compatible: - move `RequestFile` definition to `model/models.ts` - remove `model/index.ts` - re-export `RequestFile` from `api/apis.ts` - make generation of `ObjectSerializer` conditional --- .../TypeScriptNodeClientCodegen.java | 1 - .../typescript-node/api-all.mustache | 2 ++ .../typescript-node/api-single.mustache | 3 +-- .../typescript-node/model-index.mustache | 18 -------------- .../resources/typescript-node/model.mustache | 2 +- .../resources/typescript-node/models.mustache | 24 +++++++++++++++++++ .../default/.openapi-generator/FILES | 1 - .../typescript-node/default/api/apis.ts | 2 ++ .../typescript-node/default/api/petApi.ts | 3 +-- .../typescript-node/default/api/storeApi.ts | 3 +-- .../typescript-node/default/api/userApi.ts | 3 +-- .../default/model/apiResponse.ts | 2 +- .../typescript-node/default/model/category.ts | 2 +- .../typescript-node/default/model/models.ts | 21 ++++++++++++++++ .../typescript-node/default/model/order.ts | 2 +- .../typescript-node/default/model/pet.ts | 2 +- .../typescript-node/default/model/tag.ts | 2 +- .../typescript-node/default/model/user.ts | 2 +- .../npm/.openapi-generator/FILES | 1 - .../petstore/typescript-node/npm/api/apis.ts | 2 ++ .../typescript-node/npm/api/petApi.ts | 3 +-- .../typescript-node/npm/api/storeApi.ts | 3 +-- .../typescript-node/npm/api/userApi.ts | 3 +-- .../typescript-node/npm/model/apiResponse.ts | 2 +- .../typescript-node/npm/model/category.ts | 2 +- .../typescript-node/npm/model/models.ts | 21 ++++++++++++++++ .../typescript-node/npm/model/order.ts | 2 +- .../petstore/typescript-node/npm/model/pet.ts | 2 +- .../petstore/typescript-node/npm/model/tag.ts | 2 +- .../typescript-node/npm/model/user.ts | 2 +- 30 files changed, 92 insertions(+), 48 deletions(-) delete mode 100644 modules/openapi-generator/src/main/resources/typescript-node/model-index.mustache diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptNodeClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptNodeClientCodegen.java index d7f231b9665b..09d5ae4df4e8 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptNodeClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptNodeClientCodegen.java @@ -241,7 +241,6 @@ public void setNpmRepository(String npmRepository) { public void processOpts() { super.processOpts(); supportingFiles.add(new SupportingFile("models.mustache", modelPackage().replace('.', File.separatorChar), "models.ts")); - supportingFiles.add(new SupportingFile("model-index.mustache", modelPackage().replace('.', File.separatorChar), "index.ts")); supportingFiles.add(new SupportingFile("api-all.mustache", apiPackage().replace('.', File.separatorChar), "apis.ts")); supportingFiles.add(new SupportingFile("api.mustache", getIndexDirectory(), "api.ts")); supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh")); diff --git a/modules/openapi-generator/src/main/resources/typescript-node/api-all.mustache b/modules/openapi-generator/src/main/resources/typescript-node/api-all.mustache index 1a8d2f1dbd6e..3836aa7ace31 100644 --- a/modules/openapi-generator/src/main/resources/typescript-node/api-all.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-node/api-all.mustache @@ -17,5 +17,7 @@ export class HttpError extends Error { } } +export { RequestFile } from '../model/models'; + export const APIS = [{{#apis}}{{#operations}}{{ classname }}{{/operations}}{{^-last}}, {{/-last}}{{/apis}}]; {{/apiInfo}} diff --git a/modules/openapi-generator/src/main/resources/typescript-node/api-single.mustache b/modules/openapi-generator/src/main/resources/typescript-node/api-single.mustache index 7e733dffb013..e8a6cc5bf360 100644 --- a/modules/openapi-generator/src/main/resources/typescript-node/api-single.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-node/api-single.mustache @@ -13,8 +13,7 @@ import { ObjectSerializer, Authentication, VoidAuth, Interceptor } from '../mode import { HttpBasicAuth, HttpBearerAuth, ApiKeyAuth, OAuth } from '../model/models'; {{/hasAuthMethods}} -import { HttpError } from './apis'; -import { RequestFile } from '../model'; +import { HttpError, RequestFile } from './apis'; let defaultBasePath = '{{{basePath}}}'; diff --git a/modules/openapi-generator/src/main/resources/typescript-node/model-index.mustache b/modules/openapi-generator/src/main/resources/typescript-node/model-index.mustache deleted file mode 100644 index 16f93cbe5e8e..000000000000 --- a/modules/openapi-generator/src/main/resources/typescript-node/model-index.mustache +++ /dev/null @@ -1,18 +0,0 @@ -{{#models}} -{{#model}} -export * from '{{{ classFilename }}}'; -{{/model}} -{{/models}} - -import * as fs from 'fs'; - -export interface RequestDetailedFile { - value: Buffer; - options?: { - filename?: string; - contentType?: string; - } -} - -export type RequestFile = string | Buffer | fs.ReadStream | RequestDetailedFile; - diff --git a/modules/openapi-generator/src/main/resources/typescript-node/model.mustache b/modules/openapi-generator/src/main/resources/typescript-node/model.mustache index 1472d83a0863..e728b68ac4c0 100644 --- a/modules/openapi-generator/src/main/resources/typescript-node/model.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-node/model.mustache @@ -1,7 +1,7 @@ {{>licenseInfo}} {{#models}} {{#model}} -import { RequestFile } from './'; +import { RequestFile } from './models'; {{#tsImports}} import { {{classname}} } from '{{filename}}'; {{/tsImports}} diff --git a/modules/openapi-generator/src/main/resources/typescript-node/models.mustache b/modules/openapi-generator/src/main/resources/typescript-node/models.mustache index 250a5c22fc2c..6f60837c04f5 100644 --- a/modules/openapi-generator/src/main/resources/typescript-node/models.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-node/models.mustache @@ -1,4 +1,27 @@ +{{#generateApis}} import localVarRequest from 'request'; +{{/generateApis}} + +{{#models}} +{{#model}} +export * from '{{{ classFilename }}}'; +{{/model}} +{{/models}} + +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 +{{#generateApis}} {{#models}} {{#model}} @@ -229,3 +252,4 @@ export class VoidAuth implements Authentication { } export type Interceptor = (requestOptions: localVarRequest.Options) => (Promise | void); +{{/generateApis}} diff --git a/samples/client/petstore/typescript-node/default/.openapi-generator/FILES b/samples/client/petstore/typescript-node/default/.openapi-generator/FILES index ef154e74955a..ff52c7c5b2b8 100644 --- a/samples/client/petstore/typescript-node/default/.openapi-generator/FILES +++ b/samples/client/petstore/typescript-node/default/.openapi-generator/FILES @@ -11,5 +11,4 @@ model/order.ts model/pet.ts model/tag.ts model/user.ts -model/index.ts model/models.ts diff --git a/samples/client/petstore/typescript-node/default/api/apis.ts b/samples/client/petstore/typescript-node/default/api/apis.ts index 022a0383c494..7a7314a1e873 100644 --- a/samples/client/petstore/typescript-node/default/api/apis.ts +++ b/samples/client/petstore/typescript-node/default/api/apis.ts @@ -13,4 +13,6 @@ export class HttpError extends Error { } } +export { RequestFile } from '../model/models'; + export const APIS = [PetApi, StoreApi, UserApi]; diff --git a/samples/client/petstore/typescript-node/default/api/petApi.ts b/samples/client/petstore/typescript-node/default/api/petApi.ts index 52ec608a5f76..f9bc6cfb93d7 100644 --- a/samples/client/petstore/typescript-node/default/api/petApi.ts +++ b/samples/client/petstore/typescript-node/default/api/petApi.ts @@ -21,8 +21,7 @@ import { Pet } from '../model/pet'; import { ObjectSerializer, Authentication, VoidAuth, Interceptor } from '../model/models'; import { HttpBasicAuth, HttpBearerAuth, ApiKeyAuth, OAuth } from '../model/models'; -import { HttpError } from './apis'; -import { RequestFile } from '../model'; +import { HttpError, RequestFile } from './apis'; let defaultBasePath = 'http://petstore.swagger.io/v2'; diff --git a/samples/client/petstore/typescript-node/default/api/storeApi.ts b/samples/client/petstore/typescript-node/default/api/storeApi.ts index 23da295bf4aa..075dc6126fb3 100644 --- a/samples/client/petstore/typescript-node/default/api/storeApi.ts +++ b/samples/client/petstore/typescript-node/default/api/storeApi.ts @@ -20,8 +20,7 @@ import { Order } from '../model/order'; import { ObjectSerializer, Authentication, VoidAuth, Interceptor } from '../model/models'; import { HttpBasicAuth, HttpBearerAuth, ApiKeyAuth, OAuth } from '../model/models'; -import { HttpError } from './apis'; -import { RequestFile } from '../model'; +import { HttpError, RequestFile } from './apis'; let defaultBasePath = 'http://petstore.swagger.io/v2'; diff --git a/samples/client/petstore/typescript-node/default/api/userApi.ts b/samples/client/petstore/typescript-node/default/api/userApi.ts index dda07522c876..6122ed4221e6 100644 --- a/samples/client/petstore/typescript-node/default/api/userApi.ts +++ b/samples/client/petstore/typescript-node/default/api/userApi.ts @@ -19,8 +19,7 @@ import { User } from '../model/user'; import { ObjectSerializer, Authentication, VoidAuth, Interceptor } from '../model/models'; -import { HttpError } from './apis'; -import { RequestFile } from '../model'; +import { HttpError, RequestFile } from './apis'; let defaultBasePath = 'http://petstore.swagger.io/v2'; diff --git a/samples/client/petstore/typescript-node/default/model/apiResponse.ts b/samples/client/petstore/typescript-node/default/model/apiResponse.ts index 59236cdec4f6..aa4047061f9c 100644 --- a/samples/client/petstore/typescript-node/default/model/apiResponse.ts +++ b/samples/client/petstore/typescript-node/default/model/apiResponse.ts @@ -10,7 +10,7 @@ * Do not edit the class manually. */ -import { RequestFile } from './'; +import { RequestFile } from './models'; /** * Describes the result of uploading an image resource diff --git a/samples/client/petstore/typescript-node/default/model/category.ts b/samples/client/petstore/typescript-node/default/model/category.ts index 4dde2adb5b13..facdc9d479f6 100644 --- a/samples/client/petstore/typescript-node/default/model/category.ts +++ b/samples/client/petstore/typescript-node/default/model/category.ts @@ -10,7 +10,7 @@ * Do not edit the class manually. */ -import { RequestFile } from './'; +import { RequestFile } from './models'; /** * A category for a pet diff --git a/samples/client/petstore/typescript-node/default/model/models.ts b/samples/client/petstore/typescript-node/default/model/models.ts index 7d186ff09814..84ee10037dbf 100644 --- a/samples/client/petstore/typescript-node/default/model/models.ts +++ b/samples/client/petstore/typescript-node/default/model/models.ts @@ -1,5 +1,26 @@ import localVarRequest from 'request'; +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; + +// Object serialization only relevant if generating APIs, too + import { ApiResponse } from './apiResponse'; import { Category } from './category'; import { Order } from './order'; diff --git a/samples/client/petstore/typescript-node/default/model/order.ts b/samples/client/petstore/typescript-node/default/model/order.ts index 4d52e243dcc3..18d5a8f2e861 100644 --- a/samples/client/petstore/typescript-node/default/model/order.ts +++ b/samples/client/petstore/typescript-node/default/model/order.ts @@ -10,7 +10,7 @@ * Do not edit the class manually. */ -import { RequestFile } from './'; +import { RequestFile } from './models'; /** * An order for a pets from the pet store diff --git a/samples/client/petstore/typescript-node/default/model/pet.ts b/samples/client/petstore/typescript-node/default/model/pet.ts index 1622e5282306..10fd0c33207b 100644 --- a/samples/client/petstore/typescript-node/default/model/pet.ts +++ b/samples/client/petstore/typescript-node/default/model/pet.ts @@ -10,7 +10,7 @@ * Do not edit the class manually. */ -import { RequestFile } from './'; +import { RequestFile } from './models'; import { Category } from './category'; import { Tag } from './tag'; diff --git a/samples/client/petstore/typescript-node/default/model/tag.ts b/samples/client/petstore/typescript-node/default/model/tag.ts index bbfa6ef37f35..6b0f9752ee90 100644 --- a/samples/client/petstore/typescript-node/default/model/tag.ts +++ b/samples/client/petstore/typescript-node/default/model/tag.ts @@ -10,7 +10,7 @@ * Do not edit the class manually. */ -import { RequestFile } from './'; +import { RequestFile } from './models'; /** * A tag for a pet diff --git a/samples/client/petstore/typescript-node/default/model/user.ts b/samples/client/petstore/typescript-node/default/model/user.ts index 7c86fb7664cc..0b1401384c07 100644 --- a/samples/client/petstore/typescript-node/default/model/user.ts +++ b/samples/client/petstore/typescript-node/default/model/user.ts @@ -10,7 +10,7 @@ * Do not edit the class manually. */ -import { RequestFile } from './'; +import { RequestFile } from './models'; /** * A User who is purchasing from the pet store diff --git a/samples/client/petstore/typescript-node/npm/.openapi-generator/FILES b/samples/client/petstore/typescript-node/npm/.openapi-generator/FILES index 31854c240c5b..d24a1934784b 100644 --- a/samples/client/petstore/typescript-node/npm/.openapi-generator/FILES +++ b/samples/client/petstore/typescript-node/npm/.openapi-generator/FILES @@ -11,7 +11,6 @@ model/order.ts model/pet.ts model/tag.ts model/user.ts -model/index.ts model/models.ts package.json tsconfig.json diff --git a/samples/client/petstore/typescript-node/npm/api/apis.ts b/samples/client/petstore/typescript-node/npm/api/apis.ts index 022a0383c494..7a7314a1e873 100644 --- a/samples/client/petstore/typescript-node/npm/api/apis.ts +++ b/samples/client/petstore/typescript-node/npm/api/apis.ts @@ -13,4 +13,6 @@ export class HttpError extends Error { } } +export { RequestFile } from '../model/models'; + export const APIS = [PetApi, StoreApi, UserApi]; diff --git a/samples/client/petstore/typescript-node/npm/api/petApi.ts b/samples/client/petstore/typescript-node/npm/api/petApi.ts index 52ec608a5f76..f9bc6cfb93d7 100644 --- a/samples/client/petstore/typescript-node/npm/api/petApi.ts +++ b/samples/client/petstore/typescript-node/npm/api/petApi.ts @@ -21,8 +21,7 @@ import { Pet } from '../model/pet'; import { ObjectSerializer, Authentication, VoidAuth, Interceptor } from '../model/models'; import { HttpBasicAuth, HttpBearerAuth, ApiKeyAuth, OAuth } from '../model/models'; -import { HttpError } from './apis'; -import { RequestFile } from '../model'; +import { HttpError, RequestFile } from './apis'; let defaultBasePath = 'http://petstore.swagger.io/v2'; diff --git a/samples/client/petstore/typescript-node/npm/api/storeApi.ts b/samples/client/petstore/typescript-node/npm/api/storeApi.ts index 23da295bf4aa..075dc6126fb3 100644 --- a/samples/client/petstore/typescript-node/npm/api/storeApi.ts +++ b/samples/client/petstore/typescript-node/npm/api/storeApi.ts @@ -20,8 +20,7 @@ import { Order } from '../model/order'; import { ObjectSerializer, Authentication, VoidAuth, Interceptor } from '../model/models'; import { HttpBasicAuth, HttpBearerAuth, ApiKeyAuth, OAuth } from '../model/models'; -import { HttpError } from './apis'; -import { RequestFile } from '../model'; +import { HttpError, RequestFile } from './apis'; let defaultBasePath = 'http://petstore.swagger.io/v2'; diff --git a/samples/client/petstore/typescript-node/npm/api/userApi.ts b/samples/client/petstore/typescript-node/npm/api/userApi.ts index dda07522c876..6122ed4221e6 100644 --- a/samples/client/petstore/typescript-node/npm/api/userApi.ts +++ b/samples/client/petstore/typescript-node/npm/api/userApi.ts @@ -19,8 +19,7 @@ import { User } from '../model/user'; import { ObjectSerializer, Authentication, VoidAuth, Interceptor } from '../model/models'; -import { HttpError } from './apis'; -import { RequestFile } from '../model'; +import { HttpError, RequestFile } from './apis'; let defaultBasePath = 'http://petstore.swagger.io/v2'; diff --git a/samples/client/petstore/typescript-node/npm/model/apiResponse.ts b/samples/client/petstore/typescript-node/npm/model/apiResponse.ts index 59236cdec4f6..aa4047061f9c 100644 --- a/samples/client/petstore/typescript-node/npm/model/apiResponse.ts +++ b/samples/client/petstore/typescript-node/npm/model/apiResponse.ts @@ -10,7 +10,7 @@ * Do not edit the class manually. */ -import { RequestFile } from './'; +import { RequestFile } from './models'; /** * Describes the result of uploading an image resource diff --git a/samples/client/petstore/typescript-node/npm/model/category.ts b/samples/client/petstore/typescript-node/npm/model/category.ts index 4dde2adb5b13..facdc9d479f6 100644 --- a/samples/client/petstore/typescript-node/npm/model/category.ts +++ b/samples/client/petstore/typescript-node/npm/model/category.ts @@ -10,7 +10,7 @@ * Do not edit the class manually. */ -import { RequestFile } from './'; +import { RequestFile } from './models'; /** * A category for a pet diff --git a/samples/client/petstore/typescript-node/npm/model/models.ts b/samples/client/petstore/typescript-node/npm/model/models.ts index 7d186ff09814..84ee10037dbf 100644 --- a/samples/client/petstore/typescript-node/npm/model/models.ts +++ b/samples/client/petstore/typescript-node/npm/model/models.ts @@ -1,5 +1,26 @@ import localVarRequest from 'request'; +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; + +// Object serialization only relevant if generating APIs, too + import { ApiResponse } from './apiResponse'; import { Category } from './category'; import { Order } from './order'; diff --git a/samples/client/petstore/typescript-node/npm/model/order.ts b/samples/client/petstore/typescript-node/npm/model/order.ts index 4d52e243dcc3..18d5a8f2e861 100644 --- a/samples/client/petstore/typescript-node/npm/model/order.ts +++ b/samples/client/petstore/typescript-node/npm/model/order.ts @@ -10,7 +10,7 @@ * Do not edit the class manually. */ -import { RequestFile } from './'; +import { RequestFile } from './models'; /** * An order for a pets from the pet store diff --git a/samples/client/petstore/typescript-node/npm/model/pet.ts b/samples/client/petstore/typescript-node/npm/model/pet.ts index 1622e5282306..10fd0c33207b 100644 --- a/samples/client/petstore/typescript-node/npm/model/pet.ts +++ b/samples/client/petstore/typescript-node/npm/model/pet.ts @@ -10,7 +10,7 @@ * Do not edit the class manually. */ -import { RequestFile } from './'; +import { RequestFile } from './models'; import { Category } from './category'; import { Tag } from './tag'; diff --git a/samples/client/petstore/typescript-node/npm/model/tag.ts b/samples/client/petstore/typescript-node/npm/model/tag.ts index bbfa6ef37f35..6b0f9752ee90 100644 --- a/samples/client/petstore/typescript-node/npm/model/tag.ts +++ b/samples/client/petstore/typescript-node/npm/model/tag.ts @@ -10,7 +10,7 @@ * Do not edit the class manually. */ -import { RequestFile } from './'; +import { RequestFile } from './models'; /** * A tag for a pet diff --git a/samples/client/petstore/typescript-node/npm/model/user.ts b/samples/client/petstore/typescript-node/npm/model/user.ts index 7c86fb7664cc..0b1401384c07 100644 --- a/samples/client/petstore/typescript-node/npm/model/user.ts +++ b/samples/client/petstore/typescript-node/npm/model/user.ts @@ -10,7 +10,7 @@ * Do not edit the class manually. */ -import { RequestFile } from './'; +import { RequestFile } from './models'; /** * A User who is purchasing from the pet store From 88419f1f26c9a173887840f3c9ea66f26e178e8b Mon Sep 17 00:00:00 2001 From: Richard Kolkovich Date: Wed, 5 Aug 2020 09:22:13 -0600 Subject: [PATCH 4/8] for some reason, Symfony isn't up to date --- .../.openapi-generator/FILES | 46 +++++++++---------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/samples/server/petstore/php-symfony/SymfonyBundle-php/.openapi-generator/FILES b/samples/server/petstore/php-symfony/SymfonyBundle-php/.openapi-generator/FILES index b00a0510b77f..8c41d6e8cf56 100644 --- a/samples/server/petstore/php-symfony/SymfonyBundle-php/.openapi-generator/FILES +++ b/samples/server/petstore/php-symfony/SymfonyBundle-php/.openapi-generator/FILES @@ -1,26 +1,26 @@ -./Api/ApiServer.php -./Api/PetApiInterface.php -./Api/StoreApiInterface.php -./Api/UserApiInterface.php -./Controller/Controller.php -./Controller/PetController.php -./Controller/StoreController.php -./Controller/UserController.php -./Model/ApiResponse.php -./Model/Category.php -./Model/Order.php -./Model/Pet.php -./Model/Tag.php -./Model/User.php -./Service/JmsSerializer.php -./Service/SerializerInterface.php -./Service/StrictJsonDeserializationVisitor.php -./Service/SymfonyValidator.php -./Service/TypeMismatchException.php -./Service/ValidatorInterface.php -./Tests/AppKernel.php -./Tests/Controller/ControllerTest.php -./Tests/test_config.yml +Api/ApiServer.php +Api/PetApiInterface.php +Api/StoreApiInterface.php +Api/UserApiInterface.php +Controller/Controller.php +Controller/PetController.php +Controller/StoreController.php +Controller/UserController.php +Model/ApiResponse.php +Model/Category.php +Model/Order.php +Model/Pet.php +Model/Tag.php +Model/User.php +Service/JmsSerializer.php +Service/SerializerInterface.php +Service/StrictJsonDeserializationVisitor.php +Service/SymfonyValidator.php +Service/TypeMismatchException.php +Service/ValidatorInterface.php +Tests/AppKernel.php +Tests/Controller/ControllerTest.php +Tests/test_config.yml .coveralls.yml .gitignore .php_cs.dist From 478ea53f3eee2afdacba88a3ba5138ca6599915e Mon Sep 17 00:00:00 2001 From: Richard Kolkovich Date: Tue, 18 Aug 2020 08:44:31 -0600 Subject: [PATCH 5/8] reverts changes to php-symfony sample --- .../.openapi-generator/FILES | 46 +++++++++---------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/samples/server/petstore/php-symfony/SymfonyBundle-php/.openapi-generator/FILES b/samples/server/petstore/php-symfony/SymfonyBundle-php/.openapi-generator/FILES index 8c41d6e8cf56..b00a0510b77f 100644 --- a/samples/server/petstore/php-symfony/SymfonyBundle-php/.openapi-generator/FILES +++ b/samples/server/petstore/php-symfony/SymfonyBundle-php/.openapi-generator/FILES @@ -1,26 +1,26 @@ -Api/ApiServer.php -Api/PetApiInterface.php -Api/StoreApiInterface.php -Api/UserApiInterface.php -Controller/Controller.php -Controller/PetController.php -Controller/StoreController.php -Controller/UserController.php -Model/ApiResponse.php -Model/Category.php -Model/Order.php -Model/Pet.php -Model/Tag.php -Model/User.php -Service/JmsSerializer.php -Service/SerializerInterface.php -Service/StrictJsonDeserializationVisitor.php -Service/SymfonyValidator.php -Service/TypeMismatchException.php -Service/ValidatorInterface.php -Tests/AppKernel.php -Tests/Controller/ControllerTest.php -Tests/test_config.yml +./Api/ApiServer.php +./Api/PetApiInterface.php +./Api/StoreApiInterface.php +./Api/UserApiInterface.php +./Controller/Controller.php +./Controller/PetController.php +./Controller/StoreController.php +./Controller/UserController.php +./Model/ApiResponse.php +./Model/Category.php +./Model/Order.php +./Model/Pet.php +./Model/Tag.php +./Model/User.php +./Service/JmsSerializer.php +./Service/SerializerInterface.php +./Service/StrictJsonDeserializationVisitor.php +./Service/SymfonyValidator.php +./Service/TypeMismatchException.php +./Service/ValidatorInterface.php +./Tests/AppKernel.php +./Tests/Controller/ControllerTest.php +./Tests/test_config.yml .coveralls.yml .gitignore .php_cs.dist From ac4b68c039b3cf30665fad380db0e940bb754372 Mon Sep 17 00:00:00 2001 From: Richard Kolkovich Date: Fri, 28 Aug 2020 08:30:12 -0600 Subject: [PATCH 6/8] moves comment to mustache comment rather than TS comment Co-authored-by: Esteban Gehring --- .../src/main/resources/typescript-node/models.mustache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/openapi-generator/src/main/resources/typescript-node/models.mustache b/modules/openapi-generator/src/main/resources/typescript-node/models.mustache index 6f60837c04f5..93f3790d667d 100644 --- a/modules/openapi-generator/src/main/resources/typescript-node/models.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-node/models.mustache @@ -20,7 +20,7 @@ export interface RequestDetailedFile { export type RequestFile = string | Buffer | fs.ReadStream | RequestDetailedFile; -// Object serialization only relevant if generating APIs, too +{{! Object serialization only relevant if generating APIs, too }} {{#generateApis}} {{#models}} From aa9b11c21a84ab9217b1b3d355be1579f058709e Mon Sep 17 00:00:00 2001 From: Richard Kolkovich Date: Fri, 28 Aug 2020 08:37:44 -0600 Subject: [PATCH 7/8] removes stale files from samples (no longer generated) --- .../typescript-node/default/model/index.ts | 19 ------------------- .../typescript-node/npm/model/index.ts | 19 ------------------- 2 files changed, 38 deletions(-) delete mode 100644 samples/client/petstore/typescript-node/default/model/index.ts delete mode 100644 samples/client/petstore/typescript-node/npm/model/index.ts diff --git a/samples/client/petstore/typescript-node/default/model/index.ts b/samples/client/petstore/typescript-node/default/model/index.ts deleted file mode 100644 index 7c953d0c5d6c..000000000000 --- a/samples/client/petstore/typescript-node/default/model/index.ts +++ /dev/null @@ -1,19 +0,0 @@ -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; - diff --git a/samples/client/petstore/typescript-node/npm/model/index.ts b/samples/client/petstore/typescript-node/npm/model/index.ts deleted file mode 100644 index 7c953d0c5d6c..000000000000 --- a/samples/client/petstore/typescript-node/npm/model/index.ts +++ /dev/null @@ -1,19 +0,0 @@ -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; - From 043b7447e42d760a09d1e8fcd713db253e4b690d Mon Sep 17 00:00:00 2001 From: Richard Kolkovich Date: Fri, 28 Aug 2020 08:38:17 -0600 Subject: [PATCH 8/8] updates samples --- samples/client/petstore/typescript-node/default/model/models.ts | 1 - samples/client/petstore/typescript-node/npm/model/models.ts | 1 - 2 files changed, 2 deletions(-) diff --git a/samples/client/petstore/typescript-node/default/model/models.ts b/samples/client/petstore/typescript-node/default/model/models.ts index 84ee10037dbf..ba05217de7e8 100644 --- a/samples/client/petstore/typescript-node/default/model/models.ts +++ b/samples/client/petstore/typescript-node/default/model/models.ts @@ -19,7 +19,6 @@ export interface RequestDetailedFile { export type RequestFile = string | Buffer | fs.ReadStream | RequestDetailedFile; -// Object serialization only relevant if generating APIs, too import { ApiResponse } from './apiResponse'; import { Category } from './category'; diff --git a/samples/client/petstore/typescript-node/npm/model/models.ts b/samples/client/petstore/typescript-node/npm/model/models.ts index 84ee10037dbf..ba05217de7e8 100644 --- a/samples/client/petstore/typescript-node/npm/model/models.ts +++ b/samples/client/petstore/typescript-node/npm/model/models.ts @@ -19,7 +19,6 @@ export interface RequestDetailedFile { export type RequestFile = string | Buffer | fs.ReadStream | RequestDetailedFile; -// Object serialization only relevant if generating APIs, too import { ApiResponse } from './apiResponse'; import { Category } from './category';