mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-08 03:18:53 +00:00
Merge pull request #884 from xhh/params-order
Make sure "required" parameters are placed in front of "optional" parameters
This commit is contained in:
commit
80303b524d
@ -18,22 +18,28 @@ if [ ! -d "${APP_DIR}" ]; then
|
||||
fi
|
||||
|
||||
cd $APP_DIR
|
||||
./bin/akka-scala-petstore.sh
|
||||
./bin/android-java-petstore.sh
|
||||
./bin/csharp-petstore.sh
|
||||
./bin/dynamic-html.sh
|
||||
./bin/html-petstore.sh
|
||||
./bin/jaxrs-petstore-server.sh
|
||||
./bin/java-petstore.sh
|
||||
./bin/qt5-petstore.sh
|
||||
./bin/jaxrs-petstore-server.sh
|
||||
./bin/nodejs-petstore-server.sh
|
||||
./bin/objc-petstore.sh
|
||||
./bin/perl-petstore.sh
|
||||
./bin/php-petstore.sh
|
||||
./bin/python-petstore.sh
|
||||
./bin/python3-petstore.sh
|
||||
./bin/qt5-petstore.sh
|
||||
./bin/retrofit-petstore.sh
|
||||
./bin/ruby-petstore.sh
|
||||
./bin/objc-petstore.sh
|
||||
./bin/scala-async-petstore.sh
|
||||
./bin/scala-petstore.sh
|
||||
./bin/scalatra-petstore-server.sh
|
||||
./bin/silex-petstore-server.sh
|
||||
./bin/spring-mvc-petstore-server.sh
|
||||
./bin/swift-petstore.sh
|
||||
./bin/tizen-petstore.sh
|
||||
./bin/typescript-angular-petstore.sh
|
||||
./bin/typescript-node-petstore.sh
|
||||
|
@ -50,6 +50,7 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
@ -851,6 +852,17 @@ public class DefaultCodegen {
|
||||
}
|
||||
op.bodyParam = bodyParam;
|
||||
op.httpMethod = httpMethod.toUpperCase();
|
||||
// move "required" parameters in front of "optional" parameters
|
||||
Collections.sort(allParams, new Comparator<CodegenParameter>() {
|
||||
@Override
|
||||
public int compare(CodegenParameter one, CodegenParameter another) {
|
||||
boolean oneRequired = one.required == null ? false : one.required;
|
||||
boolean anotherRequired = another.required == null ? false : another.required;
|
||||
if (oneRequired == anotherRequired) return 0;
|
||||
else if (oneRequired) return -1;
|
||||
else return 1;
|
||||
}
|
||||
});
|
||||
op.allParams = addHasMore(allParams);
|
||||
op.bodyParams = addHasMore(bodyParams);
|
||||
op.pathParams = addHasMore(pathParams);
|
||||
|
@ -108,10 +108,10 @@ object PetApi {
|
||||
* Expected answers:
|
||||
* code 400 : (Invalid pet value)
|
||||
*
|
||||
* @param apiKey
|
||||
* @param petId Pet id to delete
|
||||
* @param apiKey
|
||||
*/
|
||||
def deletePet(apiKey: Option[String] = None, petId: Long): ApiRequest[Unit] =
|
||||
def deletePet(petId: Long, apiKey: Option[String] = None): ApiRequest[Unit] =
|
||||
ApiRequest[Unit](ApiMethods.DELETE, "http://petstore.swagger.io/v2", "/pet/{petId}", "application/json")
|
||||
.withPathParam("petId", petId)
|
||||
.withHeaderParam("api_key", apiKey)
|
||||
|
@ -392,11 +392,11 @@ public class PetApi {
|
||||
/**
|
||||
* Deletes a pet
|
||||
*
|
||||
* @param apiKey
|
||||
* @param petId Pet id to delete
|
||||
* @param apiKey
|
||||
* @return void
|
||||
*/
|
||||
public void deletePet (String apiKey, Long petId) throws ApiException {
|
||||
public void deletePet (Long petId, String apiKey) throws ApiException {
|
||||
Object postBody = null;
|
||||
|
||||
// verify the required parameter 'petId' is set
|
||||
|
@ -118,7 +118,7 @@ public class PetApiTest {
|
||||
api.addPet(pet);
|
||||
|
||||
Pet fetched = api.getPetById(pet.getId());
|
||||
api.deletePet(null, fetched.getId());
|
||||
api.deletePet(fetched.getId(), null);
|
||||
|
||||
try {
|
||||
fetched = api.getPetById(fetched.getId());
|
||||
|
@ -418,11 +418,11 @@ public class PetApi {
|
||||
/**
|
||||
* Deletes a pet
|
||||
*
|
||||
* @param apiKey
|
||||
* @param petId Pet id to delete
|
||||
* @param apiKey
|
||||
* @return void
|
||||
*/
|
||||
public void deletePet (String apiKey, Long petId) throws ApiException {
|
||||
public void deletePet (Long petId, String apiKey) throws ApiException {
|
||||
Object postBody = null;
|
||||
|
||||
// verify the required parameter 'petId' is set
|
||||
|
@ -151,7 +151,7 @@ public class PetApiTest {
|
||||
api.addPet(pet);
|
||||
|
||||
Pet fetched = api.getPetById(pet.getId());
|
||||
api.deletePet(null, fetched.getId());
|
||||
api.deletePet(fetched.getId(), null);
|
||||
|
||||
try {
|
||||
fetched = api.getPetById(fetched.getId());
|
||||
|
@ -537,12 +537,12 @@ class PetApi
|
||||
*
|
||||
* Deletes a pet
|
||||
*
|
||||
* @param string $api_key (optional)
|
||||
* @param int $pet_id Pet id to delete (required)
|
||||
* @param string $api_key (optional)
|
||||
* @return void
|
||||
* @throws \Swagger\Client\ApiException on non-2xx response
|
||||
*/
|
||||
public function deletePet($api_key=null, $pet_id)
|
||||
public function deletePet($pet_id, $api_key=null)
|
||||
{
|
||||
|
||||
// verify the required parameter 'pet_id' is set
|
||||
|
Loading…
Reference in New Issue
Block a user