Skip to content

Commit a9cfd26

Browse files
author
Kunal Singh
committed
Changed the Variable name from isSingleton to isConstEnumParam and modified the petstore sample with a new api with the case
1 parent 5cae6fc commit a9cfd26

File tree

3 files changed

+38
-8
lines changed

3 files changed

+38
-8
lines changed

modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenParameter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public class CodegenParameter {
1717
public boolean isString, isNumeric, isInteger, isLong, isNumber, isFloat, isDouble, isByteArray, isBinary, isBoolean, isDate, isDateTime, isUuid;
1818
public boolean isListContainer, isMapContainer;
1919
public boolean isFile, notFile;
20-
public boolean isEnum, isConstQueryParam;
20+
public boolean isEnum, isConstEnumParam;
2121
public List<String> _enum;
2222
public Map<String, Object> allowableValues;
2323
public CodegenProperty items;
@@ -119,7 +119,7 @@ public CodegenParameter copy() {
119119
output.isEnum = this.isEnum;
120120
if (this._enum != null) {
121121
output._enum = new ArrayList<String>(this._enum);
122-
this.isConstQueryParam = (this._enum.size() == 1 && this.required);
122+
this.isConstEnumParam = (this._enum.size() == 1 && this.required);
123123
}
124124
if (this.allowableValues != null) {
125125
output.allowableValues = new HashMap<String, Object>(this.allowableValues);

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,19 +124,19 @@ export class {{classname}} {
124124
* @param reportProgress flag to report request and response progress.{{/useHttpClient}}
125125
*/
126126
{{#useHttpClient}}
127-
public {{nickname}}({{#allParams}}{{^isConstQueryParam}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/isConstQueryParam}}{{/allParams}}observe?: 'body', reportProgress?: boolean): Observable<{{#returnType}}{{{returnType}}}{{#isResponseTypeFile}}|undefined{{/isResponseTypeFile}}{{/returnType}}{{^returnType}}any{{/returnType}}>;
128-
public {{nickname}}({{#allParams}}{{^isConstQueryParam}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/isConstQueryParam}}{{/allParams}}observe?: 'response', reportProgress?: boolean): Observable<HttpResponse<{{#returnType}}{{{returnType}}}{{#isResponseTypeFile}}|undefined{{/isResponseTypeFile}}{{/returnType}}{{^returnType}}any{{/returnType}}>>;
129-
public {{nickname}}({{#allParams}}{{^isConstQueryParam}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/isConstQueryParam}}{{/allParams}}observe?: 'events', reportProgress?: boolean): Observable<HttpEvent<{{#returnType}}{{{returnType}}}{{#isResponseTypeFile}}|undefined{{/isResponseTypeFile}}{{/returnType}}{{^returnType}}any{{/returnType}}>>;
130-
public {{nickname}}({{#allParams}}{{^isConstQueryParam}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/isConstQueryParam}}{{/allParams}}observe: any = 'body', reportProgress: boolean = false ): Observable<any> {
127+
public {{nickname}}({{#allParams}}{{^isConstEnumParam}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/isConstEnumParam}}{{/allParams}}observe?: 'body', reportProgress?: boolean): Observable<{{#returnType}}{{{returnType}}}{{#isResponseTypeFile}}|undefined{{/isResponseTypeFile}}{{/returnType}}{{^returnType}}any{{/returnType}}>;
128+
public {{nickname}}({{#allParams}}{{^isConstEnumParam}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/isConstEnumParam}}{{/allParams}}observe?: 'response', reportProgress?: boolean): Observable<HttpResponse<{{#returnType}}{{{returnType}}}{{#isResponseTypeFile}}|undefined{{/isResponseTypeFile}}{{/returnType}}{{^returnType}}any{{/returnType}}>>;
129+
public {{nickname}}({{#allParams}}{{^isConstEnumParam}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/isConstEnumParam}}{{/allParams}}observe?: 'events', reportProgress?: boolean): Observable<HttpEvent<{{#returnType}}{{{returnType}}}{{#isResponseTypeFile}}|undefined{{/isResponseTypeFile}}{{/returnType}}{{^returnType}}any{{/returnType}}>>;
130+
public {{nickname}}({{#allParams}}{{^isConstEnumParam}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/isConstEnumParam}}{{/allParams}}observe: any = 'body', reportProgress: boolean = false ): Observable<any> {
131131
{{/useHttpClient}}
132132
{{^useHttpClient}}
133133
public {{nickname}}WithHttpInfo({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}extraHttpRequestParams?: RequestOptionsArgs): Observable<Response> {
134134
{{/useHttpClient}}
135135
{{#allParams}}
136136
{{#required}}
137-
{{#isConstQueryParam}}
137+
{{#isConstEnumParam}}
138138
let {{paramName}} = {{{dataType}}};
139-
{{/isConstQueryParam}}
139+
{{/isConstEnumParam}}
140140
if ({{paramName}} === null || {{paramName}} === undefined) {
141141
throw new Error('Required parameter {{paramName}} was null or undefined when calling {{nickname}}.');
142142
}

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,36 @@ 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'
3161
post:
3262
tags:
3363
- pet

0 commit comments

Comments
 (0)