Skip to content

Commit c8650d0

Browse files
bvwellswing328
authored andcommitted
Make optional properties in models optional parameters (#7859)
* Make optional properties in models optional parameters Move incorrect location of typescript-node client * Add typescript node package.json to swagger ignore
1 parent f2d56b0 commit c8650d0

File tree

5 files changed

+80
-76
lines changed

5 files changed

+80
-76
lines changed

modules/swagger-codegen/src/main/resources/typescript-node/api.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ export class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{
141141
* {{{description}}}
142142
*/
143143
{{/description}}
144-
'{{name}}': {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{datatype}}}{{/isEnum}};
144+
'{{name}}'{{^required}}?{{/required}}: {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{datatype}}}{{/isEnum}};
145145
{{/vars}}
146146

147147
{{#discriminator}}

samples/client/petstore/typescript-node/default/api.ts

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,9 @@ class ObjectSerializer {
140140
* Describes the result of uploading an image resource
141141
*/
142142
export class ApiResponse {
143-
'code': number;
144-
'type': string;
145-
'message': string;
143+
'code'?: number;
144+
'type'?: string;
145+
'message'?: string;
146146

147147
static discriminator = undefined;
148148

@@ -172,8 +172,8 @@ export class ApiResponse {
172172
* A category for a pet
173173
*/
174174
export class Category {
175-
'id': number;
176-
'name': string;
175+
'id'?: number;
176+
'name'?: string;
177177

178178
static discriminator = undefined;
179179

@@ -198,15 +198,15 @@ export class Category {
198198
* An order for a pets from the pet store
199199
*/
200200
export class Order {
201-
'id': number;
202-
'petId': number;
203-
'quantity': number;
204-
'shipDate': Date;
201+
'id'?: number;
202+
'petId'?: number;
203+
'quantity'?: number;
204+
'shipDate'?: Date;
205205
/**
206206
* Order Status
207207
*/
208-
'status': Order.StatusEnum;
209-
'complete': boolean;
208+
'status'?: Order.StatusEnum;
209+
'complete'?: boolean;
210210

211211
static discriminator = undefined;
212212

@@ -258,15 +258,15 @@ export namespace Order {
258258
* A pet for sale in the pet store
259259
*/
260260
export class Pet {
261-
'id': number;
262-
'category': Category;
261+
'id'?: number;
262+
'category'?: Category;
263263
'name': string;
264264
'photoUrls': Array<string>;
265-
'tags': Array<Tag>;
265+
'tags'?: Array<Tag>;
266266
/**
267267
* pet status in the store
268268
*/
269-
'status': Pet.StatusEnum;
269+
'status'?: Pet.StatusEnum;
270270

271271
static discriminator = undefined;
272272

@@ -318,8 +318,8 @@ export namespace Pet {
318318
* A tag for a pet
319319
*/
320320
export class Tag {
321-
'id': number;
322-
'name': string;
321+
'id'?: number;
322+
'name'?: string;
323323

324324
static discriminator = undefined;
325325

@@ -344,17 +344,17 @@ export class Tag {
344344
* A User who is purchasing from the pet store
345345
*/
346346
export class User {
347-
'id': number;
348-
'username': string;
349-
'firstName': string;
350-
'lastName': string;
351-
'email': string;
352-
'password': string;
353-
'phone': string;
347+
'id'?: number;
348+
'username'?: string;
349+
'firstName'?: string;
350+
'lastName'?: string;
351+
'email'?: string;
352+
'password'?: string;
353+
'phone'?: string;
354354
/**
355355
* User Status
356356
*/
357-
'userStatus': number;
357+
'userStatus'?: number;
358358

359359
static discriminator = undefined;
360360

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Do not overwrite package.json file when re-generating typescript-node client
2+
# as the package file as been modified to include dependencies required for
3+
# testing the generated client.
4+
package.json

samples/client/petstore/typescript-node/npm/api.d.ts

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import localVarRequest = require('request');
55
import http = require('http');
66
import Promise = require('bluebird');
77
export declare class ApiResponse {
8-
'code': number;
9-
'type': string;
10-
'message': string;
8+
'code'?: number;
9+
'type'?: string;
10+
'message'?: string;
1111
static discriminator: undefined;
1212
static attributeTypeMap: Array<{
1313
name: string;
@@ -21,8 +21,8 @@ export declare class ApiResponse {
2121
}[];
2222
}
2323
export declare class Category {
24-
'id': number;
25-
'name': string;
24+
'id'?: number;
25+
'name'?: string;
2626
static discriminator: undefined;
2727
static attributeTypeMap: Array<{
2828
name: string;
@@ -36,12 +36,12 @@ export declare class Category {
3636
}[];
3737
}
3838
export declare class Order {
39-
'id': number;
40-
'petId': number;
41-
'quantity': number;
42-
'shipDate': Date;
43-
'status': Order.StatusEnum;
44-
'complete': boolean;
39+
'id'?: number;
40+
'petId'?: number;
41+
'quantity'?: number;
42+
'shipDate'?: Date;
43+
'status'?: Order.StatusEnum;
44+
'complete'?: boolean;
4545
static discriminator: undefined;
4646
static attributeTypeMap: Array<{
4747
name: string;
@@ -62,12 +62,12 @@ export declare namespace Order {
6262
}
6363
}
6464
export declare class Pet {
65-
'id': number;
66-
'category': Category;
65+
'id'?: number;
66+
'category'?: Category;
6767
'name': string;
6868
'photoUrls': Array<string>;
69-
'tags': Array<Tag>;
70-
'status': Pet.StatusEnum;
69+
'tags'?: Array<Tag>;
70+
'status'?: Pet.StatusEnum;
7171
static discriminator: undefined;
7272
static attributeTypeMap: Array<{
7373
name: string;
@@ -88,8 +88,8 @@ export declare namespace Pet {
8888
}
8989
}
9090
export declare class Tag {
91-
'id': number;
92-
'name': string;
91+
'id'?: number;
92+
'name'?: string;
9393
static discriminator: undefined;
9494
static attributeTypeMap: Array<{
9595
name: string;
@@ -103,14 +103,14 @@ export declare class Tag {
103103
}[];
104104
}
105105
export declare class User {
106-
'id': number;
107-
'username': string;
108-
'firstName': string;
109-
'lastName': string;
110-
'email': string;
111-
'password': string;
112-
'phone': string;
113-
'userStatus': number;
106+
'id'?: number;
107+
'username'?: string;
108+
'firstName'?: string;
109+
'lastName'?: string;
110+
'email'?: string;
111+
'password'?: string;
112+
'phone'?: string;
113+
'userStatus'?: number;
114114
static discriminator: undefined;
115115
static attributeTypeMap: Array<{
116116
name: string;

samples/client/petstore/typescript-node/npm/api.ts

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,9 @@ class ObjectSerializer {
140140
* Describes the result of uploading an image resource
141141
*/
142142
export class ApiResponse {
143-
'code': number;
144-
'type': string;
145-
'message': string;
143+
'code'?: number;
144+
'type'?: string;
145+
'message'?: string;
146146

147147
static discriminator = undefined;
148148

@@ -172,8 +172,8 @@ export class ApiResponse {
172172
* A category for a pet
173173
*/
174174
export class Category {
175-
'id': number;
176-
'name': string;
175+
'id'?: number;
176+
'name'?: string;
177177

178178
static discriminator = undefined;
179179

@@ -198,15 +198,15 @@ export class Category {
198198
* An order for a pets from the pet store
199199
*/
200200
export class Order {
201-
'id': number;
202-
'petId': number;
203-
'quantity': number;
204-
'shipDate': Date;
201+
'id'?: number;
202+
'petId'?: number;
203+
'quantity'?: number;
204+
'shipDate'?: Date;
205205
/**
206206
* Order Status
207207
*/
208-
'status': Order.StatusEnum;
209-
'complete': boolean;
208+
'status'?: Order.StatusEnum;
209+
'complete'?: boolean;
210210

211211
static discriminator = undefined;
212212

@@ -258,15 +258,15 @@ export namespace Order {
258258
* A pet for sale in the pet store
259259
*/
260260
export class Pet {
261-
'id': number;
262-
'category': Category;
261+
'id'?: number;
262+
'category'?: Category;
263263
'name': string;
264264
'photoUrls': Array<string>;
265-
'tags': Array<Tag>;
265+
'tags'?: Array<Tag>;
266266
/**
267267
* pet status in the store
268268
*/
269-
'status': Pet.StatusEnum;
269+
'status'?: Pet.StatusEnum;
270270

271271
static discriminator = undefined;
272272

@@ -318,8 +318,8 @@ export namespace Pet {
318318
* A tag for a pet
319319
*/
320320
export class Tag {
321-
'id': number;
322-
'name': string;
321+
'id'?: number;
322+
'name'?: string;
323323

324324
static discriminator = undefined;
325325

@@ -344,17 +344,17 @@ export class Tag {
344344
* A User who is purchasing from the pet store
345345
*/
346346
export class User {
347-
'id': number;
348-
'username': string;
349-
'firstName': string;
350-
'lastName': string;
351-
'email': string;
352-
'password': string;
353-
'phone': string;
347+
'id'?: number;
348+
'username'?: string;
349+
'firstName'?: string;
350+
'lastName'?: string;
351+
'email'?: string;
352+
'password'?: string;
353+
'phone'?: string;
354354
/**
355355
* User Status
356356
*/
357-
'userStatus': number;
357+
'userStatus'?: number;
358358

359359
static discriminator = undefined;
360360

0 commit comments

Comments
 (0)