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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -205,6 +210,13 @@ export class PetApi {
|
|||||||
'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');
|
||||||
|
|
||||||
@ -247,6 +259,13 @@ export class PetApi {
|
|||||||
'application/xml'
|
'application/xml'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// authentication (petstore_auth) required
|
||||||
|
// oauth required
|
||||||
|
if (this.configuration.accessToken)
|
||||||
|
{
|
||||||
|
headers.set('Authorization', 'Bearer ' + this.configuration.accessToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -285,6 +304,13 @@ export class PetApi {
|
|||||||
'application/xml'
|
'application/xml'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// authentication (petstore_auth) required
|
||||||
|
// oauth required
|
||||||
|
if (this.configuration.accessToken)
|
||||||
|
{
|
||||||
|
headers.set('Authorization', 'Bearer ' + this.configuration.accessToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -323,6 +349,13 @@ export class PetApi {
|
|||||||
'application/xml'
|
'application/xml'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// authentication (petstore_auth) required
|
||||||
|
// oauth required
|
||||||
|
if (this.configuration.accessToken)
|
||||||
|
{
|
||||||
|
headers.set('Authorization', 'Bearer ' + this.configuration.accessToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -362,6 +395,18 @@ 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
|
||||||
|
// oauth required
|
||||||
|
if (this.configuration.accessToken)
|
||||||
|
{
|
||||||
|
headers.set('Authorization', 'Bearer ' + this.configuration.accessToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -399,6 +444,13 @@ export class PetApi {
|
|||||||
'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');
|
||||||
|
|
||||||
@ -445,6 +497,13 @@ export class PetApi {
|
|||||||
'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');
|
||||||
|
|
||||||
|
|
||||||
@ -497,6 +556,13 @@ export class PetApi {
|
|||||||
'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');
|
||||||
|
|
||||||
|
|
||||||
|
@ -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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -140,6 +145,7 @@ export class StoreApi {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||||
method: RequestMethod.Delete,
|
method: RequestMethod.Delete,
|
||||||
headers: headers,
|
headers: headers,
|
||||||
@ -171,6 +177,12 @@ export class StoreApi {
|
|||||||
'application/xml'
|
'application/xml'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// authentication (api_key) required
|
||||||
|
if (this.configuration.apiKey)
|
||||||
|
{
|
||||||
|
headers.set('api_key', this.configuration.apiKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -213,6 +225,7 @@ export class StoreApi {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||||
method: RequestMethod.Get,
|
method: RequestMethod.Get,
|
||||||
headers: headers,
|
headers: headers,
|
||||||
@ -246,6 +259,7 @@ export class StoreApi {
|
|||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -200,6 +205,7 @@ export class UserApi {
|
|||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
headers.set('Content-Type', 'application/json');
|
headers.set('Content-Type', 'application/json');
|
||||||
|
|
||||||
|
|
||||||
@ -237,6 +243,7 @@ export class UserApi {
|
|||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
headers.set('Content-Type', 'application/json');
|
headers.set('Content-Type', 'application/json');
|
||||||
|
|
||||||
|
|
||||||
@ -274,6 +281,7 @@ export class UserApi {
|
|||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
headers.set('Content-Type', 'application/json');
|
headers.set('Content-Type', 'application/json');
|
||||||
|
|
||||||
|
|
||||||
@ -317,6 +325,7 @@ export class UserApi {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||||
method: RequestMethod.Delete,
|
method: RequestMethod.Delete,
|
||||||
headers: headers,
|
headers: headers,
|
||||||
@ -356,6 +365,7 @@ export class UserApi {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||||
method: RequestMethod.Get,
|
method: RequestMethod.Get,
|
||||||
headers: headers,
|
headers: headers,
|
||||||
@ -398,6 +408,7 @@ export class UserApi {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||||
method: RequestMethod.Get,
|
method: RequestMethod.Get,
|
||||||
headers: headers,
|
headers: headers,
|
||||||
@ -432,6 +443,7 @@ export class UserApi {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
let requestOptions: RequestOptionsArgs = new RequestOptions({
|
||||||
method: RequestMethod.Get,
|
method: RequestMethod.Get,
|
||||||
headers: headers,
|
headers: headers,
|
||||||
@ -470,6 +482,7 @@ export class UserApi {
|
|||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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