forked from loafle/openapi-generator-original
Adding an index file and avoiding the use of the model.d.ts files because typescript doesn't compile it correctly.
This commit is contained in:
parent
2af29fa831
commit
1825a467d8
@ -37,7 +37,15 @@ public class TypeScriptAngular2ClientCodegen extends AbstractTypeScriptClientCod
|
|||||||
public void processOpts() {
|
public void processOpts() {
|
||||||
super.processOpts();
|
super.processOpts();
|
||||||
supportingFiles.clear();
|
supportingFiles.clear();
|
||||||
supportingFiles.add(new SupportingFile("model.d.mustache", modelPackage().replace('.', File.separatorChar), "model.d.ts"));
|
|
||||||
|
supportingFiles.add(new SupportingFile("models.mustache", modelPackage().replace('.', File.separatorChar), "models.ts"));
|
||||||
|
supportingFiles.add(new SupportingFile("apis.mustache", apiPackage().replace('.', File.separatorChar), "api.ts"));
|
||||||
|
supportingFiles.add(new SupportingFile("index.mustache", getIndexDirectory(), "index.ts"));
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getIndexDirectory() {
|
||||||
|
String indexPackage = modelPackage.substring(0, Math.max(0, modelPackage.lastIndexOf('.')));
|
||||||
|
return indexPackage.replace('.', File.separatorChar);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -69,7 +77,7 @@ public class TypeScriptAngular2ClientCodegen extends AbstractTypeScriptClientCod
|
|||||||
if (languageSpecificPrimitives.contains(type))
|
if (languageSpecificPrimitives.contains(type))
|
||||||
return type;
|
return type;
|
||||||
} else
|
} else
|
||||||
type = "model." + swaggerType;
|
type = "models." + swaggerType;
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,4 +86,5 @@ public class TypeScriptAngular2ClientCodegen extends AbstractTypeScriptClientCod
|
|||||||
super.postProcessParameter(parameter);
|
super.postProcessParameter(parameter);
|
||||||
parameter.dataType = addModelPrefix(parameter.dataType);
|
parameter.dataType = addModelPrefix(parameter.dataType);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import {Http, Headers, RequestOptionsArgs, Response, URLSearchParams} from 'angular2/http';
|
import {Http, Headers, RequestOptionsArgs, Response, URLSearchParams} from 'angular2/http';
|
||||||
import {Injectable} from 'angular2/core';
|
import {Injectable} from 'angular2/core';
|
||||||
import {Observable} from 'rxjs/Observable';
|
import {Observable} from 'rxjs/Observable';
|
||||||
import * as model from "../model/model.d.ts"
|
import * as models from "../model/models.ts"
|
||||||
|
|
||||||
/* tslint:disable:no-unused-variable member-ordering */
|
/* tslint:disable:no-unused-variable member-ordering */
|
||||||
|
|
||||||
|
@ -1,11 +1,3 @@
|
|||||||
{{#models}}
|
|
||||||
{{#model}}
|
|
||||||
export * from './{{{ classname }}}';
|
|
||||||
{{/model}}
|
|
||||||
{{/models}}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{{#apiInfo}}
|
{{#apiInfo}}
|
||||||
{{#apis}}
|
{{#apis}}
|
||||||
{{#operations}}
|
{{#operations}}
|
@ -0,0 +1,2 @@
|
|||||||
|
export * from './api/apis.ts';
|
||||||
|
export * from './model/models.ts';
|
@ -1,14 +1,14 @@
|
|||||||
{{#models}}
|
{{#models}}
|
||||||
{{#model}}
|
{{#model}}
|
||||||
'use strict';
|
'use strict';
|
||||||
import * as model from "./model.d.ts"
|
import * as models from "./models.ts"
|
||||||
|
|
||||||
{{#description}}
|
{{#description}}
|
||||||
/**
|
/**
|
||||||
* {{{description}}}
|
* {{{description}}}
|
||||||
*/
|
*/
|
||||||
{{/description}}
|
{{/description}}
|
||||||
export interface {{classname}} {{#parent}}extends model.{{{parent}}} {{/parent}}{
|
export interface {{classname}} {{#parent}}extends models.{{{parent}}} {{/parent}}{
|
||||||
{{#vars}}
|
{{#vars}}
|
||||||
|
|
||||||
{{#description}}
|
{{#description}}
|
||||||
|
@ -0,0 +1,8 @@
|
|||||||
|
{{#models}}
|
||||||
|
{{#model}}
|
||||||
|
export * from './{{{ classname }}}';
|
||||||
|
{{/model}}
|
||||||
|
{{/models}}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -119,10 +119,10 @@ public class TypeScriptAngular2ModelTest {
|
|||||||
|
|
||||||
final CodegenProperty property1 = cm.vars.get(0);
|
final CodegenProperty property1 = cm.vars.get(0);
|
||||||
Assert.assertEquals(property1.baseName, "children");
|
Assert.assertEquals(property1.baseName, "children");
|
||||||
Assert.assertEquals(property1.datatype, "model.Children");
|
Assert.assertEquals(property1.datatype, "models.Children");
|
||||||
Assert.assertEquals(property1.name, "children");
|
Assert.assertEquals(property1.name, "children");
|
||||||
Assert.assertEquals(property1.defaultValue, "null");
|
Assert.assertEquals(property1.defaultValue, "null");
|
||||||
Assert.assertEquals(property1.baseType, "model.Children");
|
Assert.assertEquals(property1.baseType, "models.Children");
|
||||||
Assert.assertNull(property1.required);
|
Assert.assertNull(property1.required);
|
||||||
Assert.assertTrue(property1.isNotContainer);
|
Assert.assertTrue(property1.isNotContainer);
|
||||||
}
|
}
|
||||||
@ -143,8 +143,8 @@ public class TypeScriptAngular2ModelTest {
|
|||||||
|
|
||||||
final CodegenProperty property1 = cm.vars.get(0);
|
final CodegenProperty property1 = cm.vars.get(0);
|
||||||
Assert.assertEquals(property1.baseName, "children");
|
Assert.assertEquals(property1.baseName, "children");
|
||||||
Assert.assertEquals(property1.complexType, "model.Children");
|
Assert.assertEquals(property1.complexType, "models.Children");
|
||||||
Assert.assertEquals(property1.datatype, "Array<model.Children>");
|
Assert.assertEquals(property1.datatype, "Array<models.Children>");
|
||||||
Assert.assertEquals(property1.name, "children");
|
Assert.assertEquals(property1.name, "children");
|
||||||
Assert.assertEquals(property1.baseType, "Array");
|
Assert.assertEquals(property1.baseType, "Array");
|
||||||
Assert.assertNull(property1.required);
|
Assert.assertNull(property1.required);
|
||||||
@ -178,6 +178,6 @@ public class TypeScriptAngular2ModelTest {
|
|||||||
Assert.assertEquals(cm.description, "a map model");
|
Assert.assertEquals(cm.description, "a map model");
|
||||||
Assert.assertEquals(cm.vars.size(), 0);
|
Assert.assertEquals(cm.vars.size(), 0);
|
||||||
Assert.assertEquals(cm.imports.size(), 1);
|
Assert.assertEquals(cm.imports.size(), 1);
|
||||||
Assert.assertEquals(Sets.intersection(cm.imports, Sets.newHashSet("model.Children")).size(), 1);
|
Assert.assertEquals(Sets.intersection(cm.imports, Sets.newHashSet("models.Children")).size(), 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user