mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-08 19:33:55 +00:00
Merge pull request #968 from mhardorf/develop_2.0
Cleaned up TypeScript code generator
This commit is contained in:
commit
68915eeb8f
@ -18,7 +18,7 @@ public class TypeScriptAngularClientCodegen extends TypeScriptNodeClientCodegen
|
|||||||
apiTemplateFiles.put("api.mustache", ".ts");
|
apiTemplateFiles.put("api.mustache", ".ts");
|
||||||
templateDir = "TypeScript-Angular";
|
templateDir = "TypeScript-Angular";
|
||||||
apiPackage = "api";
|
apiPackage = "api";
|
||||||
modelPackage = "api";
|
modelPackage = "model";
|
||||||
|
|
||||||
supportingFiles.add(new SupportingFile("api.d.mustache", apiPackage + File.separator, "api.d.ts"));
|
supportingFiles.add(new SupportingFile("api.d.mustache", apiPackage + File.separator, "api.d.ts"));
|
||||||
}
|
}
|
||||||
|
@ -77,6 +77,8 @@ public class TypeScriptNodeClientCodegen extends DefaultCodegen implements Codeg
|
|||||||
typeMapping.put("double", "number");
|
typeMapping.put("double", "number");
|
||||||
typeMapping.put("object", "any");
|
typeMapping.put("object", "any");
|
||||||
typeMapping.put("integer", "number");
|
typeMapping.put("integer", "number");
|
||||||
|
typeMapping.put("Map", "any");
|
||||||
|
typeMapping.put("DateTime", "Date");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ module {{package}} {
|
|||||||
*/
|
*/
|
||||||
{{/description}}
|
{{/description}}
|
||||||
export class {{classname}} {
|
export class {{classname}} {
|
||||||
private basePath = '{{basePath}}';
|
private basePath = '{{contextPath}}';
|
||||||
|
|
||||||
static $inject: string[] = ['$http'];
|
static $inject: string[] = ['$http'];
|
||||||
|
|
||||||
@ -22,7 +22,7 @@ module {{package}} {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
{{#operation}}
|
{{#operation}}
|
||||||
public {{nickname}} ({{#allParams}}{{paramName}}: {{{dataType}}}, {{/allParams}} extraHttpRequestParams?: any ) : ng.IHttpPromise<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}{}{{/returnType}}> {
|
public {{nickname}} ({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}extraHttpRequestParams?: any ) : ng.IHttpPromise<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}{}{{/returnType}}> {
|
||||||
var path = this.basePath + '{{path}}';
|
var path = this.basePath + '{{path}}';
|
||||||
{{#pathParams}}
|
{{#pathParams}}
|
||||||
path = path.replace('{' + '{{paramName}}' + '}', String({{paramName}}));
|
path = path.replace('{' + '{{paramName}}' + '}', String({{paramName}}));
|
||||||
@ -61,8 +61,5 @@ module {{package}} {
|
|||||||
}
|
}
|
||||||
{{/operation}}
|
{{/operation}}
|
||||||
}
|
}
|
||||||
|
|
||||||
angular.module('{{package}}_{{classname}}', ['$http'])
|
|
||||||
.service('{{classname}}', {{classname}});
|
|
||||||
}
|
}
|
||||||
{{/operations}}
|
{{/operations}}
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
*/
|
*/
|
||||||
{{/description}}
|
{{/description}}
|
||||||
export class {{classname}} {
|
export class {{classname}} {
|
||||||
private basePath = '{{basePath}}';
|
private basePath = '{{contextPath}}';
|
||||||
|
|
||||||
constructor(private url: string, private username: string, private password: string, basePath?: string) {
|
constructor(private url: string, private username: string, private password: string, basePath?: string) {
|
||||||
if (basePath) {
|
if (basePath) {
|
||||||
@ -16,7 +16,7 @@ export class {{classname}} {
|
|||||||
}
|
}
|
||||||
|
|
||||||
{{#operation}}
|
{{#operation}}
|
||||||
public {{nickname}} ({{#allParams}}{{paramName}}: {{{dataType}}}{{#hasMore}}, {{/hasMore}}{{/allParams}} ) : Promise<{ response: http.ClientResponse; {{#returnType}}body: {{{returnType}}}; {{/returnType}} }> {
|
public {{nickname}} ({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) : Promise<{ response: http.ClientResponse; {{#returnType}}body: {{{returnType}}}; {{/returnType}} }> {
|
||||||
var path = this.url + this.basePath + '{{path}}';
|
var path = this.url + this.basePath + '{{path}}';
|
||||||
|
|
||||||
{{#pathParams}}
|
{{#pathParams}}
|
||||||
|
@ -49,8 +49,8 @@ class TypeScriptAngularModelTest extends FlatSpec with Matchers {
|
|||||||
vars.get(1).isNotContainer should equal(true)
|
vars.get(1).isNotContainer should equal(true)
|
||||||
|
|
||||||
vars.get(2).baseName should be("createdAt")
|
vars.get(2).baseName should be("createdAt")
|
||||||
vars.get(2).complexType should be("DateTime")
|
vars.get(2).complexType should be("Date")
|
||||||
vars.get(2).datatype should be("DateTime")
|
vars.get(2).datatype should be("Date")
|
||||||
vars.get(2).name should be("createdAt")
|
vars.get(2).name should be("createdAt")
|
||||||
vars.get(2).defaultValue should be("null")
|
vars.get(2).defaultValue should be("null")
|
||||||
vars.get(2).hasMore should equal(null)
|
vars.get(2).hasMore should equal(null)
|
||||||
|
@ -49,8 +49,8 @@ class TypeScriptNodeModelTest extends FlatSpec with Matchers {
|
|||||||
vars.get(1).isNotContainer should equal(true)
|
vars.get(1).isNotContainer should equal(true)
|
||||||
|
|
||||||
vars.get(2).baseName should be("createdAt")
|
vars.get(2).baseName should be("createdAt")
|
||||||
vars.get(2).complexType should be("DateTime")
|
vars.get(2).complexType should be("Date")
|
||||||
vars.get(2).datatype should be("DateTime")
|
vars.get(2).datatype should be("Date")
|
||||||
vars.get(2).name should be("createdAt")
|
vars.get(2).name should be("createdAt")
|
||||||
vars.get(2).defaultValue should be("null")
|
vars.get(2).defaultValue should be("null")
|
||||||
vars.get(2).hasMore should equal(null)
|
vars.get(2).hasMore should equal(null)
|
||||||
|
Loading…
Reference in New Issue
Block a user