forked from loafle/openapi-generator-original
Merge branch 'SamuelBeliveau-angular2-standalone-enums-support'
This commit is contained in:
commit
c1f498f24f
@ -26,6 +26,7 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
|
|||||||
|
|
||||||
protected String modelPropertyNaming= "camelCase";
|
protected String modelPropertyNaming= "camelCase";
|
||||||
protected Boolean supportsES6 = true;
|
protected Boolean supportsES6 = true;
|
||||||
|
protected HashSet<String> languageGenericTypes;
|
||||||
|
|
||||||
public AbstractTypeScriptClientCodegen() {
|
public AbstractTypeScriptClientCodegen() {
|
||||||
super();
|
super();
|
||||||
@ -58,6 +59,11 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
|
|||||||
"any",
|
"any",
|
||||||
"Error"
|
"Error"
|
||||||
));
|
));
|
||||||
|
|
||||||
|
languageGenericTypes = new HashSet<String>(Arrays.asList(
|
||||||
|
"Array"
|
||||||
|
));
|
||||||
|
|
||||||
instantiationTypes.put("array", "Array");
|
instantiationTypes.put("array", "Array");
|
||||||
|
|
||||||
typeMapping = new HashMap<String, String>();
|
typeMapping = new HashMap<String, String>();
|
||||||
|
@ -132,7 +132,7 @@ public class TypeScriptAngular2ClientCodegen extends AbstractTypeScriptClientCod
|
|||||||
@Override
|
@Override
|
||||||
public String getSwaggerType(Property p) {
|
public String getSwaggerType(Property p) {
|
||||||
String swaggerType = super.getSwaggerType(p);
|
String swaggerType = super.getSwaggerType(p);
|
||||||
if(languageSpecificPrimitives.contains(swaggerType)) {
|
if(isLanguagePrimitive(swaggerType) || isLanguageGenericType(swaggerType)) {
|
||||||
return swaggerType;
|
return swaggerType;
|
||||||
}
|
}
|
||||||
return addModelPrefix(swaggerType);
|
return addModelPrefix(swaggerType);
|
||||||
@ -146,15 +146,19 @@ public class TypeScriptAngular2ClientCodegen extends AbstractTypeScriptClientCod
|
|||||||
type = swaggerType;
|
type = swaggerType;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!startsWithLanguageSpecificPrimitiv(type)) {
|
if (!isLanguagePrimitive(type) && !isLanguageGenericType(type)) {
|
||||||
type = "models." + swaggerType;
|
type = "models." + swaggerType;
|
||||||
}
|
}
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean startsWithLanguageSpecificPrimitiv(String type) {
|
private boolean isLanguagePrimitive(String type) {
|
||||||
for (String langPrimitive:languageSpecificPrimitives) {
|
return languageSpecificPrimitives.contains(type);
|
||||||
if (type.startsWith(langPrimitive)) {
|
}
|
||||||
|
|
||||||
|
private boolean isLanguageGenericType(String type) {
|
||||||
|
for (String genericType: languageGenericTypes) {
|
||||||
|
if (type.startsWith(genericType + "<")) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,35 +8,6 @@ import * as models from './models';
|
|||||||
* {{{description}}}
|
* {{{description}}}
|
||||||
*/
|
*/
|
||||||
{{/description}}
|
{{/description}}
|
||||||
export interface {{classname}} {{#parent}}extends models.{{{parent}}} {{/parent}}{
|
{{#isEnum}}{{>modelEnum}}{{/isEnum}}{{^isEnum}}{{>modelGeneric}}{{/isEnum}}
|
||||||
{{#additionalPropertiesType}}
|
|
||||||
[key: string]: {{{additionalPropertiesType}}}{{#hasVars}} | any{{/hasVars}};
|
|
||||||
|
|
||||||
{{/additionalPropertiesType}}
|
|
||||||
{{#vars}}
|
|
||||||
{{#description}}
|
|
||||||
/**
|
|
||||||
* {{{description}}}
|
|
||||||
*/
|
|
||||||
{{/description}}
|
|
||||||
{{name}}{{^required}}?{{/required}}: {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{datatype}}}{{/isEnum}};
|
|
||||||
|
|
||||||
{{/vars}}
|
|
||||||
}
|
|
||||||
{{#hasEnums}}
|
|
||||||
export namespace {{classname}} {
|
|
||||||
{{#vars}}
|
|
||||||
{{#isEnum}}
|
|
||||||
export enum {{enumName}} {
|
|
||||||
{{#allowableValues}}
|
|
||||||
{{#enumVars}}
|
|
||||||
{{{name}}} = <any> {{{value}}}{{^-last}},{{/-last}}
|
|
||||||
{{/enumVars}}
|
|
||||||
{{/allowableValues}}
|
|
||||||
}
|
|
||||||
{{/isEnum}}
|
|
||||||
{{/vars}}
|
|
||||||
}
|
|
||||||
{{/hasEnums}}
|
|
||||||
{{/model}}
|
{{/model}}
|
||||||
{{/models}}
|
{{/models}}
|
@ -0,0 +1,12 @@
|
|||||||
|
{{#description}}
|
||||||
|
/**
|
||||||
|
* {{{description}}}
|
||||||
|
*/
|
||||||
|
{{/description}}
|
||||||
|
export enum {{classname}} {
|
||||||
|
{{#allowableValues}}
|
||||||
|
{{#enumVars}}
|
||||||
|
{{{name}}} = <any> {{{value}}}{{^-last}},{{/-last}}
|
||||||
|
{{/enumVars}}
|
||||||
|
{{/allowableValues}}
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
export interface {{classname}} {{#parent}}extends models.{{{parent}}} {{/parent}}{
|
||||||
|
{{#additionalPropertiesType}}
|
||||||
|
[key: string]: {{{additionalPropertiesType}}}{{#hasVars}} | any{{/hasVars}};
|
||||||
|
|
||||||
|
{{/additionalPropertiesType}}
|
||||||
|
{{#vars}}
|
||||||
|
{{#description}}
|
||||||
|
/**
|
||||||
|
* {{{description}}}
|
||||||
|
*/
|
||||||
|
{{/description}}
|
||||||
|
{{name}}{{^required}}?{{/required}}: {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{datatype}}}{{/isEnum}};
|
||||||
|
|
||||||
|
{{/vars}}
|
||||||
|
}{{#hasEnums}}
|
||||||
|
export namespace {{classname}} {
|
||||||
|
{{#vars}}
|
||||||
|
{{#isEnum}}
|
||||||
|
export enum {{enumName}} {
|
||||||
|
{{#allowableValues}}
|
||||||
|
{{#enumVars}}
|
||||||
|
{{{name}}} = <any> {{{value}}}{{^-last}},{{/-last}}
|
||||||
|
{{/enumVars}}
|
||||||
|
{{/allowableValues}}
|
||||||
|
}
|
||||||
|
{{/isEnum}}
|
||||||
|
{{/vars}}
|
||||||
|
}{{/hasEnums}}
|
@ -427,6 +427,11 @@ export class PetApi {
|
|||||||
'application/xml'
|
'application/xml'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// authentication (api_key) required
|
||||||
|
if (this.configuration.apiKey)
|
||||||
|
{
|
||||||
|
headers.set('api_key', this.configuration.apiKey);
|
||||||
|
}
|
||||||
// authentication (petstore_auth) required
|
// authentication (petstore_auth) required
|
||||||
// oauth required
|
// oauth required
|
||||||
if (this.configuration.accessToken)
|
if (this.configuration.accessToken)
|
||||||
@ -436,11 +441,6 @@ export class PetApi {
|
|||||||
: this.configuration.accessToken;
|
: this.configuration.accessToken;
|
||||||
headers.set('Authorization', 'Bearer ' + accessToken);
|
headers.set('Authorization', 'Bearer ' + accessToken);
|
||||||
}
|
}
|
||||||
// authentication (api_key) required
|
|
||||||
if (this.configuration.apiKey)
|
|
||||||
{
|
|
||||||
headers.set('api_key', this.configuration.apiKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
## @swagger/angular2-typescript-petstore@0.0.1-SNAPSHOT.201612061134
|
## @swagger/angular2-typescript-petstore@0.0.1-SNAPSHOT.201612150011
|
||||||
|
|
||||||
### Building
|
### Building
|
||||||
|
|
||||||
@ -19,7 +19,7 @@ navigate to the folder of your consuming project and run one of next commando's.
|
|||||||
_published:_
|
_published:_
|
||||||
|
|
||||||
```
|
```
|
||||||
npm install @swagger/angular2-typescript-petstore@0.0.1-SNAPSHOT.201612061134 --save
|
npm install @swagger/angular2-typescript-petstore@0.0.1-SNAPSHOT.201612150011 --save
|
||||||
```
|
```
|
||||||
|
|
||||||
_unPublished (not recommended):_
|
_unPublished (not recommended):_
|
||||||
|
@ -217,7 +217,10 @@ export class PetApi {
|
|||||||
// oauth required
|
// oauth required
|
||||||
if (this.configuration.accessToken)
|
if (this.configuration.accessToken)
|
||||||
{
|
{
|
||||||
headers.set('Authorization', 'Bearer ' + this.configuration.accessToken);
|
let accessToken = typeof this.configuration.accessToken === 'function'
|
||||||
|
? this.configuration.accessToken()
|
||||||
|
: this.configuration.accessToken;
|
||||||
|
headers.set('Authorization', 'Bearer ' + accessToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -271,7 +274,10 @@ export class PetApi {
|
|||||||
// oauth required
|
// oauth required
|
||||||
if (this.configuration.accessToken)
|
if (this.configuration.accessToken)
|
||||||
{
|
{
|
||||||
headers.set('Authorization', 'Bearer ' + this.configuration.accessToken);
|
let accessToken = typeof this.configuration.accessToken === 'function'
|
||||||
|
? this.configuration.accessToken()
|
||||||
|
: this.configuration.accessToken;
|
||||||
|
headers.set('Authorization', 'Bearer ' + accessToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -320,7 +326,10 @@ export class PetApi {
|
|||||||
// oauth required
|
// oauth required
|
||||||
if (this.configuration.accessToken)
|
if (this.configuration.accessToken)
|
||||||
{
|
{
|
||||||
headers.set('Authorization', 'Bearer ' + this.configuration.accessToken);
|
let accessToken = typeof this.configuration.accessToken === 'function'
|
||||||
|
? this.configuration.accessToken()
|
||||||
|
: this.configuration.accessToken;
|
||||||
|
headers.set('Authorization', 'Bearer ' + accessToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -369,7 +378,10 @@ export class PetApi {
|
|||||||
// oauth required
|
// oauth required
|
||||||
if (this.configuration.accessToken)
|
if (this.configuration.accessToken)
|
||||||
{
|
{
|
||||||
headers.set('Authorization', 'Bearer ' + this.configuration.accessToken);
|
let accessToken = typeof this.configuration.accessToken === 'function'
|
||||||
|
? this.configuration.accessToken()
|
||||||
|
: this.configuration.accessToken;
|
||||||
|
headers.set('Authorization', 'Bearer ' + accessToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -424,7 +436,10 @@ export class PetApi {
|
|||||||
// oauth required
|
// oauth required
|
||||||
if (this.configuration.accessToken)
|
if (this.configuration.accessToken)
|
||||||
{
|
{
|
||||||
headers.set('Authorization', 'Bearer ' + this.configuration.accessToken);
|
let accessToken = typeof this.configuration.accessToken === 'function'
|
||||||
|
? this.configuration.accessToken()
|
||||||
|
: this.configuration.accessToken;
|
||||||
|
headers.set('Authorization', 'Bearer ' + accessToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -472,7 +487,10 @@ export class PetApi {
|
|||||||
// oauth required
|
// oauth required
|
||||||
if (this.configuration.accessToken)
|
if (this.configuration.accessToken)
|
||||||
{
|
{
|
||||||
headers.set('Authorization', 'Bearer ' + this.configuration.accessToken);
|
let accessToken = typeof this.configuration.accessToken === 'function'
|
||||||
|
? this.configuration.accessToken()
|
||||||
|
: this.configuration.accessToken;
|
||||||
|
headers.set('Authorization', 'Bearer ' + accessToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -529,7 +547,10 @@ export class PetApi {
|
|||||||
// oauth required
|
// oauth required
|
||||||
if (this.configuration.accessToken)
|
if (this.configuration.accessToken)
|
||||||
{
|
{
|
||||||
headers.set('Authorization', 'Bearer ' + this.configuration.accessToken);
|
let accessToken = typeof this.configuration.accessToken === 'function'
|
||||||
|
? this.configuration.accessToken()
|
||||||
|
: this.configuration.accessToken;
|
||||||
|
headers.set('Authorization', 'Bearer ' + accessToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
headers.set('Content-Type', 'application/x-www-form-urlencoded');
|
headers.set('Content-Type', 'application/x-www-form-urlencoded');
|
||||||
@ -592,7 +613,10 @@ export class PetApi {
|
|||||||
// oauth required
|
// oauth required
|
||||||
if (this.configuration.accessToken)
|
if (this.configuration.accessToken)
|
||||||
{
|
{
|
||||||
headers.set('Authorization', 'Bearer ' + this.configuration.accessToken);
|
let accessToken = typeof this.configuration.accessToken === 'function'
|
||||||
|
? this.configuration.accessToken()
|
||||||
|
: this.configuration.accessToken;
|
||||||
|
headers.set('Authorization', 'Bearer ' + accessToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
headers.set('Content-Type', 'application/x-www-form-urlencoded');
|
headers.set('Content-Type', 'application/x-www-form-urlencoded');
|
||||||
|
@ -2,5 +2,5 @@ export class Configuration {
|
|||||||
apiKey: string;
|
apiKey: string;
|
||||||
username: string;
|
username: string;
|
||||||
password: string;
|
password: string;
|
||||||
accessToken: string;
|
accessToken: string | (() => string);
|
||||||
}
|
}
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@swagger/angular2-typescript-petstore",
|
"name": "@swagger/angular2-typescript-petstore",
|
||||||
"version": "0.0.1-SNAPSHOT.201612061134",
|
"version": "0.0.1-SNAPSHOT.201612150011",
|
||||||
"description": "swagger client for @swagger/angular2-typescript-petstore",
|
"description": "swagger client for @swagger/angular2-typescript-petstore",
|
||||||
"author": "Swagger Codegen Contributors",
|
"author": "Swagger Codegen Contributors",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
|
Loading…
x
Reference in New Issue
Block a user