forked from loafle/openapi-generator-original
fix typescript angular2 model - optional/required
This commit is contained in:
parent
ff90954dc6
commit
d11c7ad09a
@ -19,7 +19,7 @@ export interface {{classname}} {{#parent}}extends models.{{{parent}}} {{/parent}
|
|||||||
* {{{description}}}
|
* {{{description}}}
|
||||||
*/
|
*/
|
||||||
{{/description}}
|
{{/description}}
|
||||||
{{name}}?: {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{datatype}}}{{/isEnum}};
|
{{name}}{{^required}}?{{/required}}: {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{datatype}}}{{/isEnum}};
|
||||||
|
|
||||||
{{/vars}}
|
{{/vars}}
|
||||||
}
|
}
|
||||||
|
@ -395,17 +395,17 @@ 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)
|
||||||
{
|
{
|
||||||
headers.set('Authorization', 'Bearer ' + this.configuration.accessToken);
|
headers.set('Authorization', 'Bearer ' + this.configuration.accessToken);
|
||||||
}
|
}
|
||||||
// authentication (api_key) required
|
|
||||||
if (this.configuration.apiKey)
|
|
||||||
{
|
|
||||||
headers.set('api_key', this.configuration.apiKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -29,9 +29,9 @@ export interface Pet {
|
|||||||
|
|
||||||
category?: models.Category;
|
category?: models.Category;
|
||||||
|
|
||||||
name?: string;
|
name: string;
|
||||||
|
|
||||||
photoUrls?: Array<string>;
|
photoUrls: Array<string>;
|
||||||
|
|
||||||
tags?: Array<models.Tag>;
|
tags?: Array<models.Tag>;
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
## @swagger/angular2-typescript-petstore@0.0.1-SNAPSHOT.201609141041
|
## @swagger/angular2-typescript-petstore@0.0.1-SNAPSHOT.201609212006
|
||||||
|
|
||||||
### 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.201609141041 --save
|
npm install @swagger/angular2-typescript-petstore@0.0.1-SNAPSHOT.201609212006 --save
|
||||||
```
|
```
|
||||||
|
|
||||||
_unPublished (not recommended):_
|
_unPublished (not recommended):_
|
||||||
|
@ -32,6 +32,7 @@ import 'rxjs/add/operator/map';
|
|||||||
|
|
||||||
import * as models from '../model/models';
|
import * as models from '../model/models';
|
||||||
import { BASE_PATH } from '../variables';
|
import { BASE_PATH } from '../variables';
|
||||||
|
import { Configuration } from '../configuration';
|
||||||
|
|
||||||
/* tslint:disable:no-unused-variable member-ordering */
|
/* tslint:disable:no-unused-variable member-ordering */
|
||||||
|
|
||||||
@ -40,11 +41,15 @@ import { BASE_PATH } from '../variables'
|
|||||||
export class PetApi {
|
export class PetApi {
|
||||||
protected basePath = 'http://petstore.swagger.io/v2';
|
protected basePath = 'http://petstore.swagger.io/v2';
|
||||||
public defaultHeaders: Headers = new Headers();
|
public defaultHeaders: Headers = new Headers();
|
||||||
|
public configuration: Configuration = new Configuration();
|
||||||
|
|
||||||
constructor(protected http: Http, @Optional()@Inject(BASE_PATH) basePath: string) {
|
constructor(protected http: Http, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) {
|
||||||
if (basePath) {
|
if (basePath) {
|
||||||
this.basePath = basePath;
|
this.basePath = basePath;
|
||||||
}
|
}
|
||||||
|
if (configuration) {
|
||||||
|
this.configuration = configuration;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -204,7 +209,14 @@ export class PetApi {
|
|||||||
'application/json',
|
'application/json',
|
||||||
'application/xml'
|
'application/xml'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// authentication (petstore_auth) required
|
||||||
|
// oauth required
|
||||||
|
if (this.configuration.accessToken)
|
||||||
|
{
|
||||||
|
headers.set('Authorization', 'Bearer ' + this.configuration.accessToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
headers.set('Content-Type', 'application/json');
|
headers.set('Content-Type', 'application/json');
|
||||||
|
|
||||||
@ -246,7 +258,14 @@ export class PetApi {
|
|||||||
'application/json',
|
'application/json',
|
||||||
'application/xml'
|
'application/xml'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// authentication (petstore_auth) required
|
||||||
|
// oauth required
|
||||||
|
if (this.configuration.accessToken)
|
||||||
|
{
|
||||||
|
headers.set('Authorization', 'Bearer ' + this.configuration.accessToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -284,7 +303,14 @@ export class PetApi {
|
|||||||
'application/json',
|
'application/json',
|
||||||
'application/xml'
|
'application/xml'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// authentication (petstore_auth) required
|
||||||
|
// oauth required
|
||||||
|
if (this.configuration.accessToken)
|
||||||
|
{
|
||||||
|
headers.set('Authorization', 'Bearer ' + this.configuration.accessToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -322,7 +348,14 @@ export class PetApi {
|
|||||||
'application/json',
|
'application/json',
|
||||||
'application/xml'
|
'application/xml'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// authentication (petstore_auth) required
|
||||||
|
// oauth required
|
||||||
|
if (this.configuration.accessToken)
|
||||||
|
{
|
||||||
|
headers.set('Authorization', 'Bearer ' + this.configuration.accessToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -361,7 +394,19 @@ export class PetApi {
|
|||||||
'application/json',
|
'application/json',
|
||||||
'application/xml'
|
'application/xml'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// authentication (api_key) required
|
||||||
|
if (this.configuration.apiKey)
|
||||||
|
{
|
||||||
|
headers.set('api_key', this.configuration.apiKey);
|
||||||
|
}
|
||||||
|
// authentication (petstore_auth) required
|
||||||
|
// oauth required
|
||||||
|
if (this.configuration.accessToken)
|
||||||
|
{
|
||||||
|
headers.set('Authorization', 'Bearer ' + this.configuration.accessToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -398,7 +443,14 @@ export class PetApi {
|
|||||||
'application/json',
|
'application/json',
|
||||||
'application/xml'
|
'application/xml'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// authentication (petstore_auth) required
|
||||||
|
// oauth required
|
||||||
|
if (this.configuration.accessToken)
|
||||||
|
{
|
||||||
|
headers.set('Authorization', 'Bearer ' + this.configuration.accessToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
headers.set('Content-Type', 'application/json');
|
headers.set('Content-Type', 'application/json');
|
||||||
|
|
||||||
@ -444,15 +496,22 @@ export class PetApi {
|
|||||||
'application/json',
|
'application/json',
|
||||||
'application/xml'
|
'application/xml'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// authentication (petstore_auth) required
|
||||||
|
// oauth required
|
||||||
|
if (this.configuration.accessToken)
|
||||||
|
{
|
||||||
|
headers.set('Authorization', 'Bearer ' + this.configuration.accessToken);
|
||||||
|
}
|
||||||
|
|
||||||
headers.set('Content-Type', 'application/x-www-form-urlencoded');
|
headers.set('Content-Type', 'application/x-www-form-urlencoded');
|
||||||
|
|
||||||
|
|
||||||
if (name !== undefined) {
|
if (name !== undefined) {
|
||||||
formParams.set('name', <any>name);
|
formParams.set('name', <any>name);
|
||||||
}
|
}
|
||||||
if (status !== undefined) {
|
if (status !== undefined) {
|
||||||
formParams.set('status', <any>status);
|
formParams.set('status', <any>status);
|
||||||
}
|
}
|
||||||
|
|
||||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||||
@ -496,15 +555,22 @@ export class PetApi {
|
|||||||
'application/json',
|
'application/json',
|
||||||
'application/xml'
|
'application/xml'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// authentication (petstore_auth) required
|
||||||
|
// oauth required
|
||||||
|
if (this.configuration.accessToken)
|
||||||
|
{
|
||||||
|
headers.set('Authorization', 'Bearer ' + this.configuration.accessToken);
|
||||||
|
}
|
||||||
|
|
||||||
headers.set('Content-Type', 'application/x-www-form-urlencoded');
|
headers.set('Content-Type', 'application/x-www-form-urlencoded');
|
||||||
|
|
||||||
|
|
||||||
if (additionalMetadata !== undefined) {
|
if (additionalMetadata !== undefined) {
|
||||||
formParams.set('additionalMetadata', <any>additionalMetadata);
|
formParams.set('additionalMetadata', <any>additionalMetadata);
|
||||||
}
|
}
|
||||||
if (file !== undefined) {
|
if (file !== undefined) {
|
||||||
formParams.set('file', <any>file);
|
formParams.set('file', <any>file);
|
||||||
}
|
}
|
||||||
|
|
||||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||||
|
@ -32,6 +32,7 @@ import 'rxjs/add/operator/map';
|
|||||||
|
|
||||||
import * as models from '../model/models';
|
import * as models from '../model/models';
|
||||||
import { BASE_PATH } from '../variables';
|
import { BASE_PATH } from '../variables';
|
||||||
|
import { Configuration } from '../configuration';
|
||||||
|
|
||||||
/* tslint:disable:no-unused-variable member-ordering */
|
/* tslint:disable:no-unused-variable member-ordering */
|
||||||
|
|
||||||
@ -40,11 +41,15 @@ import { BASE_PATH } from '../variables'
|
|||||||
export class StoreApi {
|
export class StoreApi {
|
||||||
protected basePath = 'http://petstore.swagger.io/v2';
|
protected basePath = 'http://petstore.swagger.io/v2';
|
||||||
public defaultHeaders: Headers = new Headers();
|
public defaultHeaders: Headers = new Headers();
|
||||||
|
public configuration: Configuration = new Configuration();
|
||||||
|
|
||||||
constructor(protected http: Http, @Optional()@Inject(BASE_PATH) basePath: string) {
|
constructor(protected http: Http, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) {
|
||||||
if (basePath) {
|
if (basePath) {
|
||||||
this.basePath = basePath;
|
this.basePath = basePath;
|
||||||
}
|
}
|
||||||
|
if (configuration) {
|
||||||
|
this.configuration = configuration;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -136,7 +141,8 @@ export class StoreApi {
|
|||||||
'application/json',
|
'application/json',
|
||||||
'application/xml'
|
'application/xml'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -170,7 +176,13 @@ export class StoreApi {
|
|||||||
'application/json',
|
'application/json',
|
||||||
'application/xml'
|
'application/xml'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// authentication (api_key) required
|
||||||
|
if (this.configuration.apiKey)
|
||||||
|
{
|
||||||
|
headers.set('api_key', this.configuration.apiKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -209,7 +221,8 @@ export class StoreApi {
|
|||||||
'application/json',
|
'application/json',
|
||||||
'application/xml'
|
'application/xml'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -244,7 +257,8 @@ export class StoreApi {
|
|||||||
'application/json',
|
'application/json',
|
||||||
'application/xml'
|
'application/xml'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
headers.set('Content-Type', 'application/json');
|
headers.set('Content-Type', 'application/json');
|
||||||
|
|
||||||
|
@ -32,6 +32,7 @@ import 'rxjs/add/operator/map';
|
|||||||
|
|
||||||
import * as models from '../model/models';
|
import * as models from '../model/models';
|
||||||
import { BASE_PATH } from '../variables';
|
import { BASE_PATH } from '../variables';
|
||||||
|
import { Configuration } from '../configuration';
|
||||||
|
|
||||||
/* tslint:disable:no-unused-variable member-ordering */
|
/* tslint:disable:no-unused-variable member-ordering */
|
||||||
|
|
||||||
@ -40,11 +41,15 @@ import { BASE_PATH } from '../variables'
|
|||||||
export class UserApi {
|
export class UserApi {
|
||||||
protected basePath = 'http://petstore.swagger.io/v2';
|
protected basePath = 'http://petstore.swagger.io/v2';
|
||||||
public defaultHeaders: Headers = new Headers();
|
public defaultHeaders: Headers = new Headers();
|
||||||
|
public configuration: Configuration = new Configuration();
|
||||||
|
|
||||||
constructor(protected http: Http, @Optional()@Inject(BASE_PATH) basePath: string) {
|
constructor(protected http: Http, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) {
|
||||||
if (basePath) {
|
if (basePath) {
|
||||||
this.basePath = basePath;
|
this.basePath = basePath;
|
||||||
}
|
}
|
||||||
|
if (configuration) {
|
||||||
|
this.configuration = configuration;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -198,7 +203,8 @@ export class UserApi {
|
|||||||
'application/json',
|
'application/json',
|
||||||
'application/xml'
|
'application/xml'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
headers.set('Content-Type', 'application/json');
|
headers.set('Content-Type', 'application/json');
|
||||||
|
|
||||||
@ -235,7 +241,8 @@ export class UserApi {
|
|||||||
'application/json',
|
'application/json',
|
||||||
'application/xml'
|
'application/xml'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
headers.set('Content-Type', 'application/json');
|
headers.set('Content-Type', 'application/json');
|
||||||
|
|
||||||
@ -272,7 +279,8 @@ export class UserApi {
|
|||||||
'application/json',
|
'application/json',
|
||||||
'application/xml'
|
'application/xml'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
headers.set('Content-Type', 'application/json');
|
headers.set('Content-Type', 'application/json');
|
||||||
|
|
||||||
@ -313,7 +321,8 @@ export class UserApi {
|
|||||||
'application/json',
|
'application/json',
|
||||||
'application/xml'
|
'application/xml'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -352,7 +361,8 @@ export class UserApi {
|
|||||||
'application/json',
|
'application/json',
|
||||||
'application/xml'
|
'application/xml'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -394,7 +404,8 @@ export class UserApi {
|
|||||||
'application/json',
|
'application/json',
|
||||||
'application/xml'
|
'application/xml'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -428,7 +439,8 @@ export class UserApi {
|
|||||||
'application/json',
|
'application/json',
|
||||||
'application/xml'
|
'application/xml'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -468,7 +480,8 @@ export class UserApi {
|
|||||||
'application/json',
|
'application/json',
|
||||||
'application/xml'
|
'application/xml'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
headers.set('Content-Type', 'application/json');
|
headers.set('Content-Type', 'application/json');
|
||||||
|
|
||||||
|
@ -0,0 +1,6 @@
|
|||||||
|
export class Configuration {
|
||||||
|
apiKey: string;
|
||||||
|
username: string;
|
||||||
|
password: string;
|
||||||
|
accessToken: string;
|
||||||
|
}
|
@ -1,3 +1,4 @@
|
|||||||
export * from './api/api';
|
export * from './api/api';
|
||||||
export * from './model/models';
|
export * from './model/models';
|
||||||
export * from './variables';
|
export * from './variables';
|
||||||
|
export * from './configuration';
|
@ -29,9 +29,9 @@ export interface Pet {
|
|||||||
|
|
||||||
category?: models.Category;
|
category?: models.Category;
|
||||||
|
|
||||||
name?: string;
|
name: string;
|
||||||
|
|
||||||
photoUrls?: Array<string>;
|
photoUrls: Array<string>;
|
||||||
|
|
||||||
tags?: Array<models.Tag>;
|
tags?: Array<models.Tag>;
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@swagger/angular2-typescript-petstore",
|
"name": "@swagger/angular2-typescript-petstore",
|
||||||
"version": "0.0.1-SNAPSHOT.201609141041",
|
"version": "0.0.1-SNAPSHOT.201609212006",
|
||||||
"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