Skip to content

Commit 4fe79f0

Browse files
authored
Remove default format (JSON) from API operations (#4987)
* remove default format (json) and update ruby petstore * update python petstore sample * update php petstore sample * update android petstore sample * update java petstore sample * update objc sample * remove default format (json) from perl
1 parent b6d6356 commit 4fe79f0

File tree

66 files changed

+205
-384
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+205
-384
lines changed

modules/swagger-codegen/src/main/resources/Java/api.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public class {{classname}} {
6262
}
6363
{{/required}}{{/allParams}}
6464
// create path and map variables
65-
String {{localVariablePrefix}}localVarPath = "{{{path}}}".replaceAll("\\{format\\}","json"){{#pathParams}}
65+
String {{localVariablePrefix}}localVarPath = "{{{path}}}"{{#pathParams}}
6666
.replaceAll("\\{" + "{{baseName}}" + "\\}", {{localVariablePrefix}}apiClient.escapeString({{{paramName}}}.toString())){{/pathParams}};
6767

6868
// query params

modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/api.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public class {{classname}} {
5959
}
6060
{{/required}}{{/allParams}}
6161
// create path and map variables
62-
String {{localVariablePrefix}}localVarPath = "{{{path}}}".replaceAll("\\{format\\}","json"){{#pathParams}}
62+
String {{localVariablePrefix}}localVarPath = "{{{path}}}"{{#pathParams}}
6363
.replaceAll("\\{" + "{{baseName}}" + "\\}", {{localVariablePrefix}}apiClient.escapeString({{{paramName}}}.toString())){{/pathParams}};
6464

6565
// query params

modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/api.mustache

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ public class {{classname}} {
6868
Object {{localVariablePrefix}}localVarPostBody = {{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}null{{/bodyParam}};
6969

7070
// create path and map variables
71-
String {{localVariablePrefix}}localVarPath = "{{{path}}}".replaceAll("\\{format\\}","json"){{#pathParams}}
72-
.replaceAll("\\{" + "{{baseName}}" + "\\}", {{localVariablePrefix}}apiClient.escapeString({{{paramName}}}.toString())){{/pathParams}};
71+
String {{localVariablePrefix}}localVarPath = "{{{path}}}"{{#pathParams}}
72+
.replaceAll("\\{" + "{{baseName}}" + "\\}", {{localVariablePrefix}}apiClient.escapeString({{{paramName}}}.toString())){{/pathParams}};
7373

7474
{{javaUtilPrefix}}List<Pair> {{localVariablePrefix}}localVarQueryParams = new {{javaUtilPrefix}}ArrayList<Pair>();{{#queryParams}}
7575
if ({{paramName}} != null)

modules/swagger-codegen/src/main/resources/android/libraries/volley/api.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public class {{classname}} {
6666
{{/allParams}}
6767

6868
// create path and map variables
69-
String path = "{{path}}".replaceAll("\\{format\\}","json"){{#pathParams}}.replaceAll("\\{" + "{{baseName}}" + "\\}", apiInvoker.escapeString({{{paramName}}}.toString())){{/pathParams}};
69+
String path = "{{path}}"{{#pathParams}}.replaceAll("\\{" + "{{baseName}}" + "\\}", apiInvoker.escapeString({{{paramName}}}.toString())){{/pathParams}};
7070

7171
// query params
7272
List<Pair> queryParams = new ArrayList<Pair>();

modules/swagger-codegen/src/main/resources/objc/api-body.mustache

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,6 @@ NSInteger k{{classname}}MissingParamErrorCode = 234513;
7979
{{/allParams}}
8080
NSMutableString* resourcePath = [NSMutableString stringWithFormat:@"{{path}}"];
8181

82-
// remove format in URL if needed
83-
[resourcePath replaceOccurrencesOfString:@".{format}" withString:@".json" options:0 range:NSMakeRange(0,resourcePath.length)];
84-
8582
NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init];
8683
{{#pathParams}}
8784
if ({{paramName}} != nil) {

modules/swagger-codegen/src/main/resources/perl/api.mustache

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ sub {{operationId}} {
7979
{{/allParams}}
8080
# parse inputs
8181
my $_resource_path = '{{path}}';
82-
$_resource_path =~ s/{format}/json/; # default format to json
8382

8483
my $_method = '{{httpMethod}}';
8584
my $query_params = {};

modules/swagger-codegen/src/main/resources/php/api.mustache

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,6 @@ use \{{invokerPackage}}\ObjectSerializer;
211211
);
212212
}
213213
{{/pathParams}}
214-
// default format to json
215-
$resourcePath = str_replace("{format}", "json", $resourcePath);
216-
217214
{{#formParams}}
218215
// form params
219216
if (${{paramName}} !== null) {

modules/swagger-codegen/src/main/resources/python/api.mustache

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,6 @@ class {{classname}}(object):
161161
{{/allParams}}
162162
collection_formats = {}
163163

164-
resource_path = '{{path}}'.replace('{format}', 'json')
165164
path_params = {}
166165
{{#pathParams}}
167166
if '{{paramName}}' in params:
@@ -211,7 +210,7 @@ class {{classname}}(object):
211210
# Authentication setting
212211
auth_settings = [{{#authMethods}}'{{name}}'{{#hasMore}}, {{/hasMore}}{{/authMethods}}]
213212

214-
return self.api_client.call_api(resource_path, '{{httpMethod}}',
213+
return self.api_client.call_api('{{path}}', '{{httpMethod}}',
215214
path_params,
216215
query_params,
217216
header_params,

modules/swagger-codegen/src/main/resources/ruby/api.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ module {{moduleName}}
108108
{{/hasValidation}}
109109
{{/allParams}}
110110
# resource path
111-
local_var_path = "{{{path}}}".sub('{format}','json'){{#pathParams}}.sub('{' + '{{baseName}}' + '}', {{paramName}}.to_s){{/pathParams}}
111+
local_var_path = "{{{path}}}"{{#pathParams}}.sub('{' + '{{baseName}}' + '}', {{paramName}}.to_s){{/pathParams}}
112112

113113
# query parameters
114114
query_params = {}

samples/client/petstore/android/httpclient/docs/PetApi.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ Name | Type | Description | Notes
222222

223223
### Authorization
224224

225-
[api_key](../README.md#api_key), [petstore_auth](../README.md#petstore_auth)
225+
[petstore_auth](../README.md#petstore_auth), [api_key](../README.md#api_key)
226226

227227
### HTTP request headers
228228

samples/client/petstore/android/httpclient/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@
145145
</repository>
146146
</repositories>
147147
<properties>
148-
<swagger-core-version>1.5.9</swagger-core-version>
148+
<swagger-core-version>1.5.12</swagger-core-version>
149149
<gson-version>2.3.1</gson-version>
150150
<junit-version>4.8.1</junit-version>
151151
<maven-plugin-version>1.0.0</maven-plugin-version>

samples/client/petstore/android/volley/docs/PetApi.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ Name | Type | Description | Notes
222222

223223
### Authorization
224224

225-
[api_key](../README.md#api_key), [petstore_auth](../README.md#petstore_auth)
225+
[petstore_auth](../README.md#petstore_auth), [api_key](../README.md#api_key)
226226

227227
### HTTP request headers
228228

samples/client/petstore/android/volley/src/main/java/io/swagger/client/api/PetApi.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public void addPet (Pet body) throws TimeoutException, ExecutionException, Inter
6666
Object postBody = body;
6767

6868
// create path and map variables
69-
String path = "/pet".replaceAll("\\{format\\}","json");
69+
String path = "/pet";
7070

7171
// query params
7272
List<Pair> queryParams = new ArrayList<Pair>();
@@ -188,7 +188,7 @@ public void deletePet (Long petId, String apiKey) throws TimeoutException, Execu
188188
}
189189

190190
// create path and map variables
191-
String path = "/pet/{petId}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "petId" + "\\}", apiInvoker.escapeString(petId.toString()));
191+
String path = "/pet/{petId}".replaceAll("\\{" + "petId" + "\\}", apiInvoker.escapeString(petId.toString()));
192192

193193
// query params
194194
List<Pair> queryParams = new ArrayList<Pair>();
@@ -310,7 +310,7 @@ public List<Pet> findPetsByStatus (List<String> status) throws TimeoutException,
310310
Object postBody = null;
311311

312312
// create path and map variables
313-
String path = "/pet/findByStatus".replaceAll("\\{format\\}","json");
313+
String path = "/pet/findByStatus";
314314

315315
// query params
316316
List<Pair> queryParams = new ArrayList<Pair>();
@@ -430,7 +430,7 @@ public List<Pet> findPetsByTags (List<String> tags) throws TimeoutException, Exe
430430
Object postBody = null;
431431

432432
// create path and map variables
433-
String path = "/pet/findByTags".replaceAll("\\{format\\}","json");
433+
String path = "/pet/findByTags";
434434

435435
// query params
436436
List<Pair> queryParams = new ArrayList<Pair>();
@@ -555,7 +555,7 @@ public Pet getPetById (Long petId) throws TimeoutException, ExecutionException,
555555
}
556556

557557
// create path and map variables
558-
String path = "/pet/{petId}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "petId" + "\\}", apiInvoker.escapeString(petId.toString()));
558+
String path = "/pet/{petId}".replaceAll("\\{" + "petId" + "\\}", apiInvoker.escapeString(petId.toString()));
559559

560560
// query params
561561
List<Pair> queryParams = new ArrayList<Pair>();
@@ -576,7 +576,7 @@ public Pet getPetById (Long petId) throws TimeoutException, ExecutionException,
576576
// normal form params
577577
}
578578

579-
String[] authNames = new String[] { "api_key", "petstore_auth" };
579+
String[] authNames = new String[] { "petstore_auth", "api_key" };
580580

581581
try {
582582
String localVarResponse = apiInvoker.invokeAPI (basePath, path, "GET", queryParams, postBody, headerParams, formParams, contentType, authNames);
@@ -646,7 +646,7 @@ public void getPetById (Long petId, final Response.Listener<Pet> responseListene
646646
// normal form params
647647
}
648648

649-
String[] authNames = new String[] { "api_key", "petstore_auth" };
649+
String[] authNames = new String[] { "petstore_auth", "api_key" };
650650

651651
try {
652652
apiInvoker.invokeAPI(basePath, path, "GET", queryParams, postBody, headerParams, formParams, contentType, authNames,
@@ -679,7 +679,7 @@ public void updatePet (Pet body) throws TimeoutException, ExecutionException, In
679679
Object postBody = body;
680680

681681
// create path and map variables
682-
String path = "/pet".replaceAll("\\{format\\}","json");
682+
String path = "/pet";
683683

684684
// query params
685685
List<Pair> queryParams = new ArrayList<Pair>();
@@ -802,7 +802,7 @@ public void updatePetWithForm (String petId, String name, String status) throws
802802
}
803803

804804
// create path and map variables
805-
String path = "/pet/{petId}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "petId" + "\\}", apiInvoker.escapeString(petId.toString()));
805+
String path = "/pet/{petId}".replaceAll("\\{" + "petId" + "\\}", apiInvoker.escapeString(petId.toString()));
806806

807807
// query params
808808
List<Pair> queryParams = new ArrayList<Pair>();
@@ -948,7 +948,7 @@ public void uploadFile (Long petId, String additionalMetadata, File file) throws
948948
}
949949

950950
// create path and map variables
951-
String path = "/pet/{petId}/uploadImage".replaceAll("\\{format\\}","json").replaceAll("\\{" + "petId" + "\\}", apiInvoker.escapeString(petId.toString()));
951+
String path = "/pet/{petId}/uploadImage".replaceAll("\\{" + "petId" + "\\}", apiInvoker.escapeString(petId.toString()));
952952

953953
// query params
954954
List<Pair> queryParams = new ArrayList<Pair>();

samples/client/petstore/android/volley/src/main/java/io/swagger/client/api/StoreApi.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public void deleteOrder (String orderId) throws TimeoutException, ExecutionExcep
7171
}
7272

7373
// create path and map variables
74-
String path = "/store/order/{orderId}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "orderId" + "\\}", apiInvoker.escapeString(orderId.toString()));
74+
String path = "/store/order/{orderId}".replaceAll("\\{" + "orderId" + "\\}", apiInvoker.escapeString(orderId.toString()));
7575

7676
// query params
7777
List<Pair> queryParams = new ArrayList<Pair>();
@@ -190,7 +190,7 @@ public Map<String, Integer> getInventory () throws TimeoutException, ExecutionEx
190190
Object postBody = null;
191191

192192
// create path and map variables
193-
String path = "/store/inventory".replaceAll("\\{format\\}","json");
193+
String path = "/store/inventory";
194194

195195
// query params
196196
List<Pair> queryParams = new ArrayList<Pair>();
@@ -313,7 +313,7 @@ public Order getOrderById (String orderId) throws TimeoutException, ExecutionExc
313313
}
314314

315315
// create path and map variables
316-
String path = "/store/order/{orderId}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "orderId" + "\\}", apiInvoker.escapeString(orderId.toString()));
316+
String path = "/store/order/{orderId}".replaceAll("\\{" + "orderId" + "\\}", apiInvoker.escapeString(orderId.toString()));
317317

318318
// query params
319319
List<Pair> queryParams = new ArrayList<Pair>();
@@ -437,7 +437,7 @@ public Order placeOrder (Order body) throws TimeoutException, ExecutionException
437437
Object postBody = body;
438438

439439
// create path and map variables
440-
String path = "/store/order".replaceAll("\\{format\\}","json");
440+
String path = "/store/order";
441441

442442
// query params
443443
List<Pair> queryParams = new ArrayList<Pair>();

samples/client/petstore/android/volley/src/main/java/io/swagger/client/api/UserApi.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public void createUser (User body) throws TimeoutException, ExecutionException,
6666
Object postBody = body;
6767

6868
// create path and map variables
69-
String path = "/user".replaceAll("\\{format\\}","json");
69+
String path = "/user";
7070

7171
// query params
7272
List<Pair> queryParams = new ArrayList<Pair>();
@@ -180,7 +180,7 @@ public void createUsersWithArrayInput (List<User> body) throws TimeoutException,
180180
Object postBody = body;
181181

182182
// create path and map variables
183-
String path = "/user/createWithArray".replaceAll("\\{format\\}","json");
183+
String path = "/user/createWithArray";
184184

185185
// query params
186186
List<Pair> queryParams = new ArrayList<Pair>();
@@ -294,7 +294,7 @@ public void createUsersWithListInput (List<User> body) throws TimeoutException,
294294
Object postBody = body;
295295

296296
// create path and map variables
297-
String path = "/user/createWithList".replaceAll("\\{format\\}","json");
297+
String path = "/user/createWithList";
298298

299299
// query params
300300
List<Pair> queryParams = new ArrayList<Pair>();
@@ -413,7 +413,7 @@ public void deleteUser (String username) throws TimeoutException, ExecutionExcep
413413
}
414414

415415
// create path and map variables
416-
String path = "/user/{username}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "username" + "\\}", apiInvoker.escapeString(username.toString()));
416+
String path = "/user/{username}".replaceAll("\\{" + "username" + "\\}", apiInvoker.escapeString(username.toString()));
417417

418418
// query params
419419
List<Pair> queryParams = new ArrayList<Pair>();
@@ -538,7 +538,7 @@ public User getUserByName (String username) throws TimeoutException, ExecutionEx
538538
}
539539

540540
// create path and map variables
541-
String path = "/user/{username}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "username" + "\\}", apiInvoker.escapeString(username.toString()));
541+
String path = "/user/{username}".replaceAll("\\{" + "username" + "\\}", apiInvoker.escapeString(username.toString()));
542542

543543
// query params
544544
List<Pair> queryParams = new ArrayList<Pair>();
@@ -663,7 +663,7 @@ public String loginUser (String username, String password) throws TimeoutExcepti
663663
Object postBody = null;
664664

665665
// create path and map variables
666-
String path = "/user/login".replaceAll("\\{format\\}","json");
666+
String path = "/user/login";
667667

668668
// query params
669669
List<Pair> queryParams = new ArrayList<Pair>();
@@ -784,7 +784,7 @@ public void logoutUser () throws TimeoutException, ExecutionException, Interrupt
784784
Object postBody = null;
785785

786786
// create path and map variables
787-
String path = "/user/logout".replaceAll("\\{format\\}","json");
787+
String path = "/user/logout";
788788

789789
// query params
790790
List<Pair> queryParams = new ArrayList<Pair>();
@@ -904,7 +904,7 @@ public void updateUser (String username, User body) throws TimeoutException, Exe
904904
}
905905

906906
// create path and map variables
907-
String path = "/user/{username}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "username" + "\\}", apiInvoker.escapeString(username.toString()));
907+
String path = "/user/{username}".replaceAll("\\{" + "username" + "\\}", apiInvoker.escapeString(username.toString()));
908908

909909
// query params
910910
List<Pair> queryParams = new ArrayList<Pair>();

samples/client/petstore/java/jersey1/src/main/java/io/swagger/client/api/FakeApi.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public Client testClientModel(Client body) throws ApiException {
6767
}
6868

6969
// create path and map variables
70-
String localVarPath = "/fake".replaceAll("\\{format\\}","json");
70+
String localVarPath = "/fake";
7171

7272
// query params
7373
List<Pair> localVarQueryParams = new ArrayList<Pair>();
@@ -135,7 +135,7 @@ public void testEndpointParameters(BigDecimal number, Double _double, String pat
135135
}
136136

137137
// create path and map variables
138-
String localVarPath = "/fake".replaceAll("\\{format\\}","json");
138+
String localVarPath = "/fake";
139139

140140
// query params
141141
List<Pair> localVarQueryParams = new ArrayList<Pair>();
@@ -205,7 +205,7 @@ public void testEnumParameters(List<String> enumFormStringArray, String enumForm
205205
Object localVarPostBody = null;
206206

207207
// create path and map variables
208-
String localVarPath = "/fake".replaceAll("\\{format\\}","json");
208+
String localVarPath = "/fake";
209209

210210
// query params
211211
List<Pair> localVarQueryParams = new ArrayList<Pair>();

0 commit comments

Comments
 (0)