-
Notifications
You must be signed in to change notification settings - Fork 429
/
Copy pathapi.mustache
135 lines (128 loc) · 5.38 KB
/
api.mustache
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
package {{package}};
import {{invokerPackage}}.ApiClient;
import {{invokerPackage}}.EncodingUtils;
{{#legacyDates}}
import {{invokerPackage}}.ParamExpander;
{{/legacyDates}}
{{#imports}}import {{import}};
{{/imports}}
{{^fullJavaUtil}}
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
{{/fullJavaUtil}}
import feign.*;
{{>generatedAnnotation}}
public interface {{classname}} extends ApiClient.Api {
{{#operations}}
{{#operation}}
{{#contents}}
/**
* {{summary}}
* {{notes}}
{{#parameters}}
* @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}}
{{/parameters}}
{{#returnType}}
* @return {{returnType}}
{{/returnType}}
{{#vendorExtensions.x-is-deprecated}}
* @deprecated
{{/vendorExtensions.x-is-deprecated}}
{{#externalDocs}}
* {{description}}
* @see <a href="{{url}}">{{summary}} Documentation</a>
{{/externalDocs}}
*/
{{#vendorExtensions.x-is-deprecated}}
@Deprecated
{{/vendorExtensions.x-is-deprecated}}
@RequestLine("{{httpMethod}} {{{path}}}{{#hasQueryParams}}?{{/hasQueryParams}}{{#queryParams}}{{baseName}}={{braces "left"}}{{paramName}}{{braces "right"}}{{#has this 'more'}}&{{/has}}{{/queryParams}}")
@Headers({
{{#vendorExtensions.x-contentType}}
"Content-Type: {{{vendorExtensions.x-contentType}}}",
{{/vendorExtensions.x-contentType}}
{{#vendorExtensions.x-accepts}}
"Accept: {{{vendorExtensions.x-accepts}}}",
{{/vendorExtensions.x-accepts}}
{{^vendorExtensions.x-accepts}}
"Accept: */*",
{{/vendorExtensions.x-accepts}}
{{#headerParams}}
"{{baseName}}: {{braces "left"}}{{paramName}}{{braces "right"}}"{{#has this 'more'}},{{/has}}
{{/headerParams}}
})
{{#returnType}}{{{returnType}}} {{/returnType}}{{^returnType}}void {{/returnType}}{{nickname}}({{#parameters}}{{#isNot this 'body-param'}}{{^legacyDates}}@Param("{{paramName}}") {{/legacyDates}}{{#legacyDates}}@Param(value="{{paramName}}", expander=ParamExpander.class) {{/legacyDates}}{{/isNot}}{{{dataType}}} {{paramName}}{{#has this 'more'}}, {{/has}}{{/parameters}});
{{#hasQueryParams}}
/**
* {{summary}}
* {{notes}}
* Note, this is equivalent to the other <code>{{operationId}}</code> method,
* but with the query parameters collected into a single Map parameter. This
* is convenient for services with optional query parameters, especially when
* used with the {@link {{operationIdCamelCase}}QueryParams} class that allows for
* building up this map in a fluent style.
{{#parameters}}
{{#isNot this 'query-param'}}
* @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}}
{{/isNot}}
{{/parameters}}
* @param queryParams Map of query parameters as name-value pairs
* <p>The following elements may be specified in the query map:</p>
* <ul>
{{#queryParams}}
* <li>{{paramName}} - {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}}</li>
{{/queryParams}}
* </ul>
{{#returnType}}
* @return {{returnType}}
{{/returnType}}
{{#vendorExtensions.x-is-deprecated}}
* @deprecated
{{/vendorExtensions.x-is-deprecated}}
{{#externalDocs}}
* {{description}}
* @see <a href="{{url}}">{{summary}} Documentation</a>{{/externalDocs}}
*/
{{#vendorExtensions.x-is-deprecated}}
@Deprecated
{{/vendorExtensions.x-is-deprecated}}
@RequestLine("{{httpMethod}} {{{path}}}?{{#queryParams}}{{baseName}}={{braces "left"}}{{paramName}}{{braces "right"}}{{#has this 'more'}}&{{/has}}{{/queryParams}}")
@Headers({
{{#vendorExtensions.x-contentType}}
"Content-Type: {{{vendorExtensions.x-contentType}}}",
{{/vendorExtensions.x-contentType}}
{{^vendorExtensions.x-contentType}}
"Content-Type: */*",
{{/vendorExtensions.x-contentType}}
{{#vendorExtensions.x-accepts}}
"Accept: {{{vendorExtensions.x-accepts}}}",
{{/vendorExtensions.x-accepts}}
{{#headerParams}}
"{{baseName}}: {{braces "left"}}{{paramName}}{{braces "right"}}"{{#has this 'more'}},{{/has}}
{{/headerParams}}
})
{{#returnType}}{{{returnType}}} {{/returnType}}{{^returnType}}void {{/returnType}}{{nickname}}({{#parameters}}{{#isNot this 'query-param'}}{{#isNot this 'body-param'}}{{^legacyDates}}@Param("{{paramName}}") {{/legacyDates}}{{#legacyDates}}@Param(value="{{paramName}}", expander=ParamExpander.class) {{/legacyDates}}{{/isNot}}{{{dataType}}} {{paramName}}, {{/isNot}}{{/parameters}}@QueryMap(encoded=true) Map<String, Object> queryParams);
/**
* A convenience class for generating query parameters for the
* <code>{{operationId}}</code> method in a fluent style.
*/
public static class {{operationIdCamelCase}}QueryParams extends HashMap<String, Object> {
{{#queryParams}}
public {{operationIdCamelCase}}QueryParams {{paramName}}(final {{{dataType}}} value) {
{{#collectionFormat}}
put("{{baseName}}", EncodingUtils.encodeCollection(value, "{{collectionFormat}}"));
{{/collectionFormat}}
{{^collectionFormat}}
put("{{baseName}}", EncodingUtils.encode(value));
{{/collectionFormat}}
return this;
}
{{/queryParams}}
}
{{/hasQueryParams}}
{{/contents}}
{{/operation}}
{{/operations}}
}