Configure discriminator correctly

This commit is contained in:
Tino Fuhrmann 2019-03-09 15:58:03 +01:00
parent 01b0ff6008
commit 74bb8ccfe7
16 changed files with 226 additions and 7 deletions

View File

@ -28,7 +28,7 @@ export class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{
{{/discriminator}}
{{^isArrayModel}}
private static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [
static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [
{{#vars}}
{
"name": "{{name}}",
@ -48,6 +48,20 @@ export class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{
{{/parent}}
}
{{/isArrayModel}}
public constructor() {
{{#parent}}
super();
{{/parent}}
{{#allVars}}
{{#discriminatorValue}}
this.{{name}} = "{{discriminatorValue}}";
{{/discriminatorValue}}
{{/allVars}}
{{#discriminatorName}}
this.{{discriminatorName}} = "{{classname}}";
{{/discriminatorName}}
}
}
{{#hasEnums}}

View File

@ -12,7 +12,7 @@ export class ApiResponse {
static readonly discriminator: string | undefined = undefined;
private static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [
static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [
{
"name": "code",
"baseName": "code",
@ -32,5 +32,8 @@ export class ApiResponse {
static getAttributeTypeMap() {
return ApiResponse.attributeTypeMap;
}
public constructor() {
}
}

View File

@ -0,0 +1,36 @@
/*
TODO: LICENSE INFO
*/
import { Pet2 } from './Pet2';
/**
* A representation of a cat
*/
export class Cat extends Pet2 {
/**
* The measured skill for hunting
*/
'huntingSkill': CatHuntingSkillEnum;
static readonly discriminator: string | undefined = undefined;
static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [
{
"name": "huntingSkill",
"baseName": "huntingSkill",
"type": "CatHuntingSkillEnum"
} ];
static getAttributeTypeMap() {
return super.getAttributeTypeMap().concat(Cat.attributeTypeMap);
}
public constructor() {
super();
this.petType = "Cat";
}
}
export type CatHuntingSkillEnum = "clueless" | "lazy" | "adventurous" | "aggressive" ;

View File

@ -11,7 +11,7 @@ export class Category {
static readonly discriminator: string | undefined = undefined;
private static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [
static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [
{
"name": "id",
"baseName": "id",
@ -26,5 +26,8 @@ export class Category {
static getAttributeTypeMap() {
return Category.attributeTypeMap;
}
public constructor() {
}
}

View File

@ -0,0 +1,33 @@
/*
TODO: LICENSE INFO
*/
import { Pet2 } from './Pet2';
/**
* A representation of a dog
*/
export class Dog extends Pet2 {
/**
* the size of the pack the dog is from
*/
'packSize': number;
static readonly discriminator: string | undefined = undefined;
static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [
{
"name": "packSize",
"baseName": "packSize",
"type": "number"
} ];
static getAttributeTypeMap() {
return super.getAttributeTypeMap().concat(Dog.attributeTypeMap);
}
public constructor() {
super();
this.petType = "Dog";
}
}

View File

@ -0,0 +1,30 @@
/*
TODO: LICENSE INFO
*/
export class ErrorModel {
'message': string;
'code': number;
static readonly discriminator: string | undefined = undefined;
static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [
{
"name": "message",
"baseName": "message",
"type": "string"
},
{
"name": "code",
"baseName": "code",
"type": "number"
} ];
static getAttributeTypeMap() {
return ErrorModel.attributeTypeMap;
}
public constructor() {
}
}

View File

@ -0,0 +1,26 @@
/*
TODO: LICENSE INFO
*/
import { ErrorModel } from './ErrorModel';
export class ExtendedErrorModel extends ErrorModel {
'rootCause': string;
static readonly discriminator: string | undefined = undefined;
static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [
{
"name": "rootCause",
"baseName": "rootCause",
"type": "string"
} ];
static getAttributeTypeMap() {
return super.getAttributeTypeMap().concat(ExtendedErrorModel.attributeTypeMap);
}
public constructor() {
super();
}
}

View File

@ -1,14 +1,24 @@
export * from './ApiResponse';
export * from './Cat';
export * from './Category';
export * from './Dog';
export * from './ErrorModel';
export * from './ExtendedErrorModel';
export * from './Order';
export * from './Pet';
export * from './Pet2';
export * from './Tag';
export * from './User';
import { ApiResponse } from './ApiResponse';
import { Cat, CatHuntingSkillEnum } from './Cat';
import { Category } from './Category';
import { Dog } from './Dog';
import { ErrorModel } from './ErrorModel';
import { ExtendedErrorModel } from './ExtendedErrorModel';
import { Order , OrderStatusEnum } from './Order';
import { Pet , PetStatusEnum } from './Pet';
import { Pet2 } from './Pet2';
import { Tag } from './Tag';
import { User } from './User';
@ -25,15 +35,21 @@ let primitives = [
];
let enumsMap: Set<string> = new Set<string>([
"CatHuntingSkillEnum",
"OrderStatusEnum",
"PetStatusEnum",
]);
let typeMap: {[index: string]: any} = {
"ApiResponse": ApiResponse,
"Cat": Cat,
"Category": Category,
"Dog": Dog,
"ErrorModel": ErrorModel,
"ExtendedErrorModel": ExtendedErrorModel,
"Order": Order,
"Pet": Pet,
"Pet2": Pet2,
"Tag": Tag,
"User": User,
}

View File

@ -18,7 +18,7 @@ export class Order {
static readonly discriminator: string | undefined = undefined;
private static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [
static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [
{
"name": "id",
"baseName": "id",
@ -53,6 +53,9 @@ export class Order {
static getAttributeTypeMap() {
return Order.attributeTypeMap;
}
public constructor() {
}
}

View File

@ -20,7 +20,7 @@ export class Pet {
static readonly discriminator: string | undefined = undefined;
private static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [
static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [
{
"name": "id",
"baseName": "id",
@ -55,6 +55,9 @@ export class Pet {
static getAttributeTypeMap() {
return Pet.attributeTypeMap;
}
public constructor() {
}
}

View File

@ -0,0 +1,31 @@
/*
TODO: LICENSE INFO
*/
export class Pet2 {
'name': string;
'petType': string;
static readonly discriminator: string | undefined = "petType";
static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [
{
"name": "name",
"baseName": "name",
"type": "string"
},
{
"name": "petType",
"baseName": "petType",
"type": "string"
} ];
static getAttributeTypeMap() {
return Pet2.attributeTypeMap;
}
public constructor() {
this.petType = "Pet2";
}
}

View File

@ -11,7 +11,7 @@ export class Tag {
static readonly discriminator: string | undefined = undefined;
private static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [
static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [
{
"name": "id",
"baseName": "id",
@ -26,5 +26,8 @@ export class Tag {
static getAttributeTypeMap() {
return Tag.attributeTypeMap;
}
public constructor() {
}
}

View File

@ -20,7 +20,7 @@ export class User {
static readonly discriminator: string | undefined = undefined;
private static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [
static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [
{
"name": "id",
"baseName": "id",
@ -65,5 +65,8 @@ export class User {
static getAttributeTypeMap() {
return User.attributeTypeMap;
}
public constructor() {
}
}

View File

@ -1,6 +1,11 @@
export * from './ApiResponse'
export * from './Cat'
export * from './Category'
export * from './Dog'
export * from './ErrorModel'
export * from './ExtendedErrorModel'
export * from './Order'
export * from './Pet'
export * from './Pet2'
export * from './Tag'
export * from './User'

View File

@ -5,9 +5,14 @@ import { Observable, of } from 'rxjs';
import {mergeMap, map} from 'rxjs/operators';
import { ApiResponse } from '../models/ApiResponse';
import { Cat } from '../models/Cat';
import { Category } from '../models/Category';
import { Dog } from '../models/Dog';
import { ErrorModel } from '../models/ErrorModel';
import { ExtendedErrorModel } from '../models/ExtendedErrorModel';
import { Order } from '../models/Order';
import { Pet } from '../models/Pet';
import { Pet2 } from '../models/Pet2';
import { Tag } from '../models/Tag';
import { User } from '../models/User';

View File

@ -3,9 +3,14 @@ import * as models from '../models/all';
import { Configuration} from '../configuration'
import { ApiResponse } from '../models/ApiResponse';
import { Cat } from '../models/Cat';
import { Category } from '../models/Category';
import { Dog } from '../models/Dog';
import { ErrorModel } from '../models/ErrorModel';
import { ExtendedErrorModel } from '../models/ExtendedErrorModel';
import { Order } from '../models/Order';
import { Pet } from '../models/Pet';
import { Pet2 } from '../models/Pet2';
import { Tag } from '../models/Tag';
import { User } from '../models/User';
import { ObservablePetApi } from './ObservableAPI';