Skip to content

Commit 36fe2df

Browse files
author
Kunal Singh
committed
1. avoided the required check if it is of type single constant enum. 2. Added case in a seperate petstore specification Updated the test sample by regenerating it with the changes
1 parent 1151b39 commit 36fe2df

File tree

9 files changed

+886
-30
lines changed

9 files changed

+886
-30
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,16 @@ export class {{classname}} {
133133
public {{nickname}}WithHttpInfo({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}extraHttpRequestParams?: RequestOptionsArgs): Observable<Response> {
134134
{{/useHttpClient}}
135135
{{#allParams}}
136+
136137
{{#required}}
137138
{{#isConstEnumParam}}
138139
let {{paramName}} = {{{dataType}}};
139140
{{/isConstEnumParam}}
141+
{{^isConstEnumParam}}
140142
if ({{paramName}} === null || {{paramName}} === undefined) {
141143
throw new Error('Required parameter {{paramName}} was null or undefined when calling {{nickname}}.');
142144
}
145+
{{/isConstEnumParam}}
143146
{{/required}}
144147
{{/allParams}}
145148

modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -28,36 +28,7 @@ schemes:
2828
- http
2929
paths:
3030
/pet:
31-
get:
32-
tags:
33-
- pet
34-
summary: Lists all the Pets
35-
description: Lists all the Pets
36-
operationId: listPets
37-
produces:
38-
- application/xml
39-
- application/json
40-
parameters:
41-
- name: action
42-
in: query
43-
description: Action type to be passed on to the get the Pets
44-
required: true
45-
type: string
46-
enum:
47-
- list
48-
responses:
49-
'200':
50-
description: successful operation
51-
schema:
52-
type: array
53-
items:
54-
$ref: '#/definitions/Pet'
55-
'400':
56-
description: Invalid status value
57-
security:
58-
- petstore_auth:
59-
- 'write:pets'
60-
- 'read:pets'
31+
6132
post:
6233
tags:
6334
- pet

0 commit comments

Comments
 (0)