Skip to content

Commit

Permalink
Remove default format (JSON) from API operations (#4987)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
wing328 authored Mar 9, 2017
1 parent b6d6356 commit 4fe79f0
Show file tree
Hide file tree
Showing 66 changed files with 205 additions and 384 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public class {{classname}} {
}
{{/required}}{{/allParams}}
// create path and map variables
String {{localVariablePrefix}}localVarPath = "{{{path}}}".replaceAll("\\{format\\}","json"){{#pathParams}}
String {{localVariablePrefix}}localVarPath = "{{{path}}}"{{#pathParams}}
.replaceAll("\\{" + "{{baseName}}" + "\\}", {{localVariablePrefix}}apiClient.escapeString({{{paramName}}}.toString())){{/pathParams}};

// query params
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public class {{classname}} {
}
{{/required}}{{/allParams}}
// create path and map variables
String {{localVariablePrefix}}localVarPath = "{{{path}}}".replaceAll("\\{format\\}","json"){{#pathParams}}
String {{localVariablePrefix}}localVarPath = "{{{path}}}"{{#pathParams}}
.replaceAll("\\{" + "{{baseName}}" + "\\}", {{localVariablePrefix}}apiClient.escapeString({{{paramName}}}.toString())){{/pathParams}};

// query params
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ public class {{classname}} {
Object {{localVariablePrefix}}localVarPostBody = {{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}null{{/bodyParam}};

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

{{javaUtilPrefix}}List<Pair> {{localVariablePrefix}}localVarQueryParams = new {{javaUtilPrefix}}ArrayList<Pair>();{{#queryParams}}
if ({{paramName}} != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public class {{classname}} {
{{/allParams}}

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

// query params
List<Pair> queryParams = new ArrayList<Pair>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,6 @@ NSInteger k{{classname}}MissingParamErrorCode = 234513;
{{/allParams}}
NSMutableString* resourcePath = [NSMutableString stringWithFormat:@"{{path}}"];

// remove format in URL if needed
[resourcePath replaceOccurrencesOfString:@".{format}" withString:@".json" options:0 range:NSMakeRange(0,resourcePath.length)];

NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init];
{{#pathParams}}
if ({{paramName}} != nil) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ sub {{operationId}} {
{{/allParams}}
# parse inputs
my $_resource_path = '{{path}}';
$_resource_path =~ s/{format}/json/; # default format to json

my $_method = '{{httpMethod}}';
my $query_params = {};
Expand Down
3 changes: 0 additions & 3 deletions modules/swagger-codegen/src/main/resources/php/api.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,6 @@ use \{{invokerPackage}}\ObjectSerializer;
);
}
{{/pathParams}}
// default format to json
$resourcePath = str_replace("{format}", "json", $resourcePath);

{{#formParams}}
// form params
if (${{paramName}} !== null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ class {{classname}}(object):
{{/allParams}}
collection_formats = {}

resource_path = '{{path}}'.replace('{format}', 'json')
path_params = {}
{{#pathParams}}
if '{{paramName}}' in params:
Expand Down Expand Up @@ -211,7 +210,7 @@ class {{classname}}(object):
# Authentication setting
auth_settings = [{{#authMethods}}'{{name}}'{{#hasMore}}, {{/hasMore}}{{/authMethods}}]

return self.api_client.call_api(resource_path, '{{httpMethod}}',
return self.api_client.call_api('{{path}}', '{{httpMethod}}',
path_params,
query_params,
header_params,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ module {{moduleName}}
{{/hasValidation}}
{{/allParams}}
# resource path
local_var_path = "{{{path}}}".sub('{format}','json'){{#pathParams}}.sub('{' + '{{baseName}}' + '}', {{paramName}}.to_s){{/pathParams}}
local_var_path = "{{{path}}}"{{#pathParams}}.sub('{' + '{{baseName}}' + '}', {{paramName}}.to_s){{/pathParams}}

# query parameters
query_params = {}
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/android/httpclient/docs/PetApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ Name | Type | Description | Notes

### Authorization

[api_key](../README.md#api_key), [petstore_auth](../README.md#petstore_auth)
[petstore_auth](../README.md#petstore_auth), [api_key](../README.md#api_key)

### HTTP request headers

Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/android/httpclient/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@
</repository>
</repositories>
<properties>
<swagger-core-version>1.5.9</swagger-core-version>
<swagger-core-version>1.5.12</swagger-core-version>
<gson-version>2.3.1</gson-version>
<junit-version>4.8.1</junit-version>
<maven-plugin-version>1.0.0</maven-plugin-version>
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/android/volley/docs/PetApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ Name | Type | Description | Notes

### Authorization

[api_key](../README.md#api_key), [petstore_auth](../README.md#petstore_auth)
[petstore_auth](../README.md#petstore_auth), [api_key](../README.md#api_key)

### HTTP request headers

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public void addPet (Pet body) throws TimeoutException, ExecutionException, Inter
Object postBody = body;

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

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

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

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

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

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

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

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

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

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

String[] authNames = new String[] { "api_key", "petstore_auth" };
String[] authNames = new String[] { "petstore_auth", "api_key" };

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

String[] authNames = new String[] { "api_key", "petstore_auth" };
String[] authNames = new String[] { "petstore_auth", "api_key" };

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

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

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

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

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

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

// query params
List<Pair> queryParams = new ArrayList<Pair>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public void deleteOrder (String orderId) throws TimeoutException, ExecutionExcep
}

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

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

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

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

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

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

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

// query params
List<Pair> queryParams = new ArrayList<Pair>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public void createUser (User body) throws TimeoutException, ExecutionException,
Object postBody = body;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// query params
List<Pair> queryParams = new ArrayList<Pair>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public Client testClientModel(Client body) throws ApiException {
}

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

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

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

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

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

// query params
List<Pair> localVarQueryParams = new ArrayList<Pair>();
Expand Down
Loading

0 comments on commit 4fe79f0

Please sign in to comment.