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

0 commit comments

Comments
 (0)