#5142: Add @QueryMap support for Feign API (#5143)

* use builder pattern for operations

* @QueryMap parameter only for query parameters

The previous iteration had replaced all parameters (body, path, query, etc)
within a single @QueryMap. But Feign only supports this style of parameter
passing for query parameters. Besides, for the case of a body parameter (like
soxhlet uses) it only added extra verbosity. With this change, the query
parameters are gathered together in a single @QueryMap and the other parameters
are left alone.

* Adding template for generating test code

* Make javadoc consistent with rest of file's conventions/indents

* Update samples

The files in src/main were generated by running

  $ bin/java-petstore-feign.sh

The files in src/test were manually fixed.

* Correct capitalization of @QueryMap class in feign

Adds a field operationIdCamelCase (a la operationIdLowerCase) to the
CodegenOperation container and uses it in the feign-generated classes
with @QueryMap parameters. Also re-generated the feign samples.

* Adding hyphen to javadocs for extra readability.

* Adding (not replacing) api method with @QueryParam overload.

In order to keep backwards compatibility, switched to adding a new method to
the interface instead of replacing the old call.

* Adding newline to generated source for readability.
This commit is contained in:
Benjamin Douglas
2017-03-23 00:01:07 -07:00
committed by wing328
parent bd81dfd08e
commit 55b7db3456
10 changed files with 270 additions and 1 deletions

View File

@@ -36,6 +36,7 @@ public class CodegenOperation {
public Map<String, Object> vendorExtensions;
public String nickname; // legacy support
public String operationIdLowerCase; // for mardown documentation
public String operationIdCamelCase; // for class names
/**
* Check if there's at least one parameter
@@ -279,7 +280,9 @@ public class CodegenOperation {
return false;
if ( prioritizedContentTypes != null ? !prioritizedContentTypes.equals(that.prioritizedContentTypes) : that.prioritizedContentTypes != null )
return false;
return operationIdLowerCase != null ? operationIdLowerCase.equals(that.operationIdLowerCase) : that.operationIdLowerCase == null;
if ( operationIdLowerCase != null ? !operationIdLowerCase.equals(that.operationIdLowerCase) : that.operationIdLowerCase != null )
return false;
return operationIdCamelCase != null ? operationIdCamelCase.equals(that.operationIdCamelCase) : that.operationIdCamelCase == null;
}
@@ -332,6 +335,7 @@ public class CodegenOperation {
result = 31 * result + (nickname != null ? nickname.hashCode() : 0);
result = 31 * result + (prioritizedContentTypes != null ? prioritizedContentTypes.hashCode() : 0);
result = 31 * result + (operationIdLowerCase != null ? operationIdLowerCase.hashCode() : 0);
result = 31 * result + (operationIdCamelCase != null ? operationIdCamelCase.hashCode() : 0);
return result;
}
}

View File

@@ -2827,6 +2827,7 @@ public class DefaultCodegen {
}
co.operationId = uniqueName;
co.operationIdLowerCase = uniqueName.toLowerCase();
co.operationIdCamelCase = DefaultCodegen.camelize(uniqueName);
opList.add(co);
co.baseName = tag;
}

View File

@@ -356,6 +356,7 @@ public class ElixirClientCodegen extends DefaultCodegen implements CodegenConfig
this.vendorExtensions = o.vendorExtensions;
this.nickname = o.nickname;
this.operationIdLowerCase = o.operationIdLowerCase;
this.operationIdCamelCase = o.operationIdCamelCase;
}
public List<String> getPathTemplateNames() {