Restructured TypeScript generator

This commit is contained in:
Tino Fuhrmann 2018-10-17 17:10:14 +02:00
parent 61a1bbdabe
commit a6560e5530
15 changed files with 30 additions and 35 deletions

View File

@ -124,26 +124,27 @@ public class TypeScriptClientCodegen extends DefaultCodegen implements CodegenCo
// http
supportingFiles.add(new SupportingFile("http" + File.separator + "http.mustache", "http", "http.ts"));
supportingFiles.add(new SupportingFile("http" + File.separator + "isomorphic-fetch.mustache", "http", "isomorphic-fetch.ts"));
supportingFiles.add(new SupportingFile("http/servers.mustache", "servers.ts"));
supportingFiles.add(new SupportingFile("configuration.mustache", "", "configuration.ts"));
supportingFiles.add(new SupportingFile("middleware.mustache", "", "middleware.ts"));
supportingFiles.add(new SupportingFile("auth" + File.separator + "auth.mustache", "auth", "auth.ts"));
supportingFiles.add(new SupportingFile("servers.mustache", "servers.ts"));
supportingFiles.add(new SupportingFile("index.mustache", "index.ts"));
supportingFiles.add(new SupportingFile("models_all.mustache", "models", "all.ts"));
supportingFiles.add(new SupportingFile("model/models_all.mustache", "models", "all.ts"));
// TODO: add supporting files depending on cli parameter e.g. fetch vs angular
supportingFiles.add(new SupportingFile("generators/fetch/fetch.mustache", "api.ts"));
supportingFiles.add(new SupportingFile("generators/PromiseAPI.mustache", "PromiseAPI.ts"));
supportingFiles.add(new SupportingFile("generators/fetch/index.mustache", "index.ts"));
// models
// TODO: properly set model and api packages
this.setModelPackage("");
supportingFiles.add(new SupportingFile("ObjectSerializer.mustache", "models", "ObjectSerializer.ts"));
modelTemplateFiles.put("model.mustache", ".ts");
supportingFiles.add(new SupportingFile("api/ObjectSerializer.mustache", "models", "ObjectSerializer.ts"));
modelTemplateFiles.put("model/model.mustache", ".ts");
// api
this.setApiPackage("");
this.supportingFiles.add(new SupportingFile("baseapi.mustache", "apis", "baseapi.ts"));
this.apiTemplateFiles.put("api.mustache", ".ts");
supportingFiles.add(new SupportingFile("api/middleware.mustache", "", "middleware.ts"));
this.supportingFiles.add(new SupportingFile("api/baseapi.mustache", "apis", "baseapi.ts"));
this.apiTemplateFiles.put("api/api.mustache", ".ts");
}

View File

@ -0,0 +1,6 @@
export * from './http/http';
export * from './auth/auth';
export * from './middleware';
export * from './models/all';
export { Configuration} from './configuration'
export * from './PromiseAPI';

View File

@ -1,9 +0,0 @@
export * from './configuration'
export * from './http/http';
export * from './auth/auth';
export * from './middleware';
export * from './servers';
// TODO: export models, export API
// TODO: make this export conditional => only if isomorphic-fetch is included
export * from './http/isomorphic-fetch';

View File

@ -1,9 +1,6 @@
export * from './configuration'
export * from './http/http';
export * from './auth/auth';
export * from './middleware';
export * from './servers';
// TODO: export models, export API
// TODO: make this export conditional => only if isomorphic-fetch is included
export * from './http/isomorphic-fetch';
export * from './models/all';
export { Configuration} from './configuration'
export * from './PromiseAPI';

View File

@ -30,9 +30,9 @@
"dev": true
},
"@types/node": {
"version": "10.11.7",
"resolved": "https://registry.npmjs.org/@types/node/-/node-10.11.7.tgz",
"integrity": "sha512-yOxFfkN9xUFLyvWaeYj90mlqTJ41CsQzWKS3gXdOMOyPVacUsymejKxJ4/pMW7exouubuEeZLJawGgcNGYlTeg=="
"version": "10.12.0",
"resolved": "https://registry.npmjs.org/@types/node/-/node-10.12.0.tgz",
"integrity": "sha512-3TUHC3jsBAB7qVRGxT6lWyYo2v96BMmD2PTcl47H25Lu7UXtFH/2qqmKiVrnel6Ne//0TFYf6uvNX+HW2FRkLQ=="
},
"arrify": {
"version": "1.0.1",
@ -105,9 +105,9 @@
"dev": true
},
"combined-stream": {
"version": "1.0.6",
"resolved": "http://registry.npmjs.org/combined-stream/-/combined-stream-1.0.6.tgz",
"integrity": "sha1-cj599ugBrFYTETp+RFqbactjKBg=",
"version": "1.0.7",
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.7.tgz",
"integrity": "sha512-brWl9y6vOB1xYPZcpZde3N9zDByXTosAeMDo4p1wzo6UMOX4vumB+TP1RZ76sfE6Md68Q0NJSrE/gbezd4Ul+w==",
"requires": {
"delayed-stream": "~1.0.0"
}
@ -173,12 +173,12 @@
"dev": true
},
"form-data": {
"version": "2.3.2",
"resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.2.tgz",
"integrity": "sha1-SXBJi+YEwgwAXU9cI67NIda0kJk=",
"version": "2.3.3",
"resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.3.tgz",
"integrity": "sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ==",
"requires": {
"asynckit": "^0.4.0",
"combined-stream": "1.0.6",
"combined-stream": "^1.0.6",
"mime-types": "^2.1.12"
}
},

View File

@ -1,4 +1,4 @@
import {PetApi} from './api';
import {PetApi} from './index';
import {Configuration } from './configuration';
import { Middleware } from './middleware';
import { RequestContext, ResponseContext } from './http/http';