Merge pull request #987 from xhh/retrofit-form-field-naming

Retrofit: fix form field naming by using baseName
This commit is contained in:
wing328 2015-07-31 09:09:09 +08:00
commit 92208b4ec2
5 changed files with 47 additions and 47 deletions

View File

@ -22,7 +22,7 @@ public interface {{classname}} {
{{#isMultipart}}@Multipart{{/isMultipart}}{{^isMultipart}}@FormUrlEncoded{{/isMultipart}}{{/-first}}{{/formParams}} {{#isMultipart}}@Multipart{{/isMultipart}}{{^isMultipart}}@FormUrlEncoded{{/isMultipart}}{{/-first}}{{/formParams}}
@{{httpMethod}}("{{path}}") @{{httpMethod}}("{{path}}")
{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Object{{/returnType}} {{nickname}}({{^allParams}});{{/allParams}} {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Object{{/returnType}} {{nickname}}({{^allParams}});{{/allParams}}
{{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}},{{/hasMore}}{{^hasMore}} {{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}}, {{/hasMore}}{{^hasMore}}
);{{/hasMore}}{{/allParams}} );{{/hasMore}}{{/allParams}}
{{/operation}} {{/operation}}
} }

View File

@ -1 +1 @@
{{#isFormParam}}{{#notFile}}{{#isMultipart}}@Part{{/isMultipart}}{{^isMultipart}}@Field{{/isMultipart}}("{{paramName}}") {{{dataType}}} {{paramName}}{{/notFile}}{{#isFile}}{{#isMultipart}}@Part{{/isMultipart}}{{^isMultipart}}@Field{{/isMultipart}}("{{paramName}}") TypedFile {{paramName}}{{/isFile}}{{/isFormParam}} {{#isFormParam}}{{#notFile}}{{#isMultipart}}@Part{{/isMultipart}}{{^isMultipart}}@Field{{/isMultipart}}("{{baseName}}") {{{dataType}}} {{paramName}}{{/notFile}}{{#isFile}}{{#isMultipart}}@Part{{/isMultipart}}{{^isMultipart}}@Field{{/isMultipart}}("{{baseName}}") TypedFile {{paramName}}{{/isFile}}{{/isFormParam}}

View File

@ -83,7 +83,7 @@ public interface PetApi {
@FormUrlEncoded @FormUrlEncoded
@POST("/pet/{petId}") @POST("/pet/{petId}")
Void updatePetWithForm( Void updatePetWithForm(
@Path("petId") String petId,@Field("name") String name,@Field("status") String status @Path("petId") String petId, @Field("name") String name, @Field("status") String status
); );
/** /**
@ -96,7 +96,7 @@ public interface PetApi {
@DELETE("/pet/{petId}") @DELETE("/pet/{petId}")
Void deletePet( Void deletePet(
@Path("petId") Long petId,@Header("api_key") String apiKey @Path("petId") Long petId, @Header("api_key") String apiKey
); );
/** /**
@ -111,7 +111,7 @@ public interface PetApi {
@Multipart @Multipart
@POST("/pet/{petId}/uploadImage") @POST("/pet/{petId}/uploadImage")
Void uploadFile( Void uploadFile(
@Path("petId") Long petId,@Part("additionalMetadata") String additionalMetadata,@Part("file") TypedFile file @Path("petId") Long petId, @Part("additionalMetadata") String additionalMetadata, @Part("file") TypedFile file
); );
} }

View File

@ -57,7 +57,7 @@ public interface UserApi {
@GET("/user/login") @GET("/user/login")
String loginUser( String loginUser(
@Query("username") String username,@Query("password") String password @Query("username") String username, @Query("password") String password
); );
/** /**
@ -92,7 +92,7 @@ public interface UserApi {
@PUT("/user/{username}") @PUT("/user/{username}")
Void updateUser( Void updateUser(
@Path("username") String username,@Body User body @Path("username") String username, @Body User body
); );
/** /**

View File

@ -1,8 +1,8 @@
package io.swagger.client.model; package io.swagger.client.model;
import io.swagger.client.model.Category; import io.swagger.client.model.Category;
import java.util.*;
import io.swagger.client.model.Tag; import io.swagger.client.model.Tag;
import java.util.*;
import io.swagger.annotations.*; import io.swagger.annotations.*;
import com.google.gson.annotations.SerializedName; import com.google.gson.annotations.SerializedName;