mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-08 11:23:58 +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");
|
||||
templateDir = "TypeScript-Angular";
|
||||
apiPackage = "api";
|
||||
modelPackage = "api";
|
||||
modelPackage = "model";
|
||||
|
||||
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("object", "any");
|
||||
typeMapping.put("integer", "number");
|
||||
typeMapping.put("Map", "any");
|
||||
typeMapping.put("DateTime", "Date");
|
||||
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@ module {{package}} {
|
||||
*/
|
||||
{{/description}}
|
||||
export class {{classname}} {
|
||||
private basePath = '{{basePath}}';
|
||||
private basePath = '{{contextPath}}';
|
||||
|
||||
static $inject: string[] = ['$http'];
|
||||
|
||||
@ -22,7 +22,7 @@ module {{package}} {
|
||||
}
|
||||
}
|
||||
{{#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}}';
|
||||
{{#pathParams}}
|
||||
path = path.replace('{' + '{{paramName}}' + '}', String({{paramName}}));
|
||||
@ -50,7 +50,7 @@ module {{package}} {
|
||||
};
|
||||
|
||||
if (extraHttpRequestParams) {
|
||||
for (var k in extraHttpRequestParams){
|
||||
for (var k in extraHttpRequestParams) {
|
||||
if (extraHttpRequestParams.hasOwnProperty(k)) {
|
||||
httpRequestParams[k] = extraHttpRequestParams[k];
|
||||
}
|
||||
@ -61,8 +61,5 @@ module {{package}} {
|
||||
}
|
||||
{{/operation}}
|
||||
}
|
||||
|
||||
angular.module('{{package}}_{{classname}}', ['$http'])
|
||||
.service('{{classname}}', {{classname}});
|
||||
}
|
||||
{{/operations}}
|
||||
|
@ -7,7 +7,7 @@
|
||||
*/
|
||||
{{/description}}
|
||||
export class {{classname}} {
|
||||
private basePath = '{{basePath}}';
|
||||
private basePath = '{{contextPath}}';
|
||||
|
||||
constructor(private url: string, private username: string, private password: string, basePath?: string) {
|
||||
if (basePath) {
|
||||
@ -16,7 +16,7 @@ export class {{classname}} {
|
||||
}
|
||||
|
||||
{{#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}}';
|
||||
|
||||
{{#pathParams}}
|
||||
|
@ -49,8 +49,8 @@ class TypeScriptAngularModelTest extends FlatSpec with Matchers {
|
||||
vars.get(1).isNotContainer should equal(true)
|
||||
|
||||
vars.get(2).baseName should be("createdAt")
|
||||
vars.get(2).complexType should be("DateTime")
|
||||
vars.get(2).datatype should be("DateTime")
|
||||
vars.get(2).complexType should be("Date")
|
||||
vars.get(2).datatype should be("Date")
|
||||
vars.get(2).name should be("createdAt")
|
||||
vars.get(2).defaultValue should be("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(2).baseName should be("createdAt")
|
||||
vars.get(2).complexType should be("DateTime")
|
||||
vars.get(2).datatype should be("DateTime")
|
||||
vars.get(2).complexType should be("Date")
|
||||
vars.get(2).datatype should be("Date")
|
||||
vars.get(2).name should be("createdAt")
|
||||
vars.get(2).defaultValue should be("null")
|
||||
vars.get(2).hasMore should equal(null)
|
||||
|
Loading…
Reference in New Issue
Block a user