Skip to content

Commit 499c8ac

Browse files
saigiridhar21wing328
authored andcommitted
[java-okhttpgson]: Include API's Http response codes and their corresponding description and response headers in the documentation (#2995)
* fix(okhttp-gson-java): Adding response headers on api_doc.mustache * feat(okhttp-gson): Adding Http response headers to docs and javadocs * feat(okhttp-gson): Included dots in custom tage * feat(java-okhttpgson): Updating pet project * feat(java-okhttpgson): Updating other pet project
1 parent 38b1fe2 commit 499c8ac

29 files changed

Lines changed: 2127 additions & 0 deletions

File tree

modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/api.mustache

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,15 @@ public class {{classname}} {
6969
* @param _callback Callback for upload/download progress
7070
* @return Call to execute
7171
* @throws ApiException If fail to serialize the request body object
72+
{{#responses.0}}
73+
* @http.response.details
74+
<table summary="Response Details" border="1">
75+
<tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
76+
{{#responses}}
77+
<tr><td> {{code}} </td><td> {{message}} </td><td> {{#headers}} * {{baseName}} - {{description}} <br> {{/headers}}{{^headers.0}} - {{/headers.0}} </td></tr>
78+
{{/responses}}
79+
</table>
80+
{{/responses.0}}
7281
{{#isDeprecated}}
7382
* @deprecated
7483
{{/isDeprecated}}
@@ -179,6 +188,15 @@ public class {{classname}} {
179188
* @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{^isContainer}}{{#defaultValue}}, default to {{.}}{{/defaultValue}}{{/isContainer}}){{/required}}{{/allParams}}{{#returnType}}
180189
* @return {{returnType}}{{/returnType}}
181190
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
191+
{{#responses.0}}
192+
* @http.response.details
193+
<table summary="Response Details" border="1">
194+
<tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
195+
{{#responses}}
196+
<tr><td> {{code}} </td><td> {{message}} </td><td> {{#headers}} * {{baseName}} - {{description}} <br> {{/headers}}{{^headers.0}} - {{/headers.0}} </td></tr>
197+
{{/responses}}
198+
</table>
199+
{{/responses.0}}
182200
{{#isDeprecated}}
183201
* @deprecated
184202
{{/isDeprecated}}
@@ -202,6 +220,15 @@ public class {{classname}} {
202220
* @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{^isContainer}}{{#defaultValue}}, default to {{.}}{{/defaultValue}}{{/isContainer}}){{/required}}{{/allParams}}
203221
* @return ApiResponse&lt;{{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}Void{{/returnType}}&gt;
204222
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
223+
{{#responses.0}}
224+
* @http.response.details
225+
<table summary="Response Details" border="1">
226+
<tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
227+
{{#responses}}
228+
<tr><td> {{code}} </td><td> {{message}} </td><td> {{#headers}} * {{baseName}} - {{description}} <br> {{/headers}}{{^headers.0}} - {{/headers.0}} </td></tr>
229+
{{/responses}}
230+
</table>
231+
{{/responses.0}}
205232
{{#isDeprecated}}
206233
* @deprecated
207234
{{/isDeprecated}}
@@ -226,6 +253,15 @@ public class {{classname}} {
226253
* @param _callback The callback to be executed when the API call finishes
227254
* @return The request call
228255
* @throws ApiException If fail to process the API call, e.g. serializing the request body object
256+
{{#responses.0}}
257+
* @http.response.details
258+
<table summary="Response Details" border="1">
259+
<tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
260+
{{#responses}}
261+
<tr><td> {{code}} </td><td> {{message}} </td><td> {{#headers}} * {{baseName}} - {{description}} <br> {{/headers}}{{^headers.0}} - {{/headers.0}} </td></tr>
262+
{{/responses}}
263+
</table>
264+
{{/responses.0}}
229265
{{#isDeprecated}}
230266
* @deprecated
231267
{{/isDeprecated}}
@@ -277,6 +313,15 @@ public class {{classname}} {
277313
* @param _callback ApiCallback API callback
278314
* @return Call to execute
279315
* @throws ApiException If fail to serialize the request body object
316+
{{#responses.0}}
317+
* @http.response.details
318+
<table summary="Response Details" border="1">
319+
<tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
320+
{{#responses}}
321+
<tr><td> {{code}} </td><td> {{message}} </td><td> {{#headers}} * {{baseName}} - {{description}} <br> {{/headers}}{{^headers.0}} - {{/headers.0}} </td></tr>
322+
{{/responses}}
323+
</table>
324+
{{/responses.0}}
280325
{{#isDeprecated}}
281326
* @deprecated
282327
{{/isDeprecated}}
@@ -292,6 +337,15 @@ public class {{classname}} {
292337
* Execute {{operationId}} request{{#returnType}}
293338
* @return {{returnType}}{{/returnType}}
294339
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
340+
{{#responses.0}}
341+
* @http.response.details
342+
<table summary="Response Details" border="1">
343+
<tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
344+
{{#responses}}
345+
<tr><td> {{code}} </td><td> {{message}} </td><td> {{#headers}} * {{baseName}} - {{description}} <br> {{/headers}}{{^headers.0}} - {{/headers.0}} </td></tr>
346+
{{/responses}}
347+
</table>
348+
{{/responses.0}}
295349
{{#isDeprecated}}
296350
* @deprecated
297351
{{/isDeprecated}}
@@ -308,6 +362,15 @@ public class {{classname}} {
308362
* Execute {{operationId}} request with HTTP info returned
309363
* @return ApiResponse&lt;{{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}Void{{/returnType}}&gt;
310364
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
365+
{{#responses.0}}
366+
* @http.response.details
367+
<table summary="Response Details" border="1">
368+
<tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
369+
{{#responses}}
370+
<tr><td> {{code}} </td><td> {{message}} </td><td> {{#headers}} * {{baseName}} - {{description}} <br> {{/headers}}{{^headers.0}} - {{/headers.0}} </td></tr>
371+
{{/responses}}
372+
</table>
373+
{{/responses.0}}
311374
{{#isDeprecated}}
312375
* @deprecated
313376
{{/isDeprecated}}
@@ -324,6 +387,15 @@ public class {{classname}} {
324387
* @param _callback The callback to be executed when the API call finishes
325388
* @return The request call
326389
* @throws ApiException If fail to process the API call, e.g. serializing the request body object
390+
{{#responses.0}}
391+
* @http.response.details
392+
<table summary="Response Details" border="1">
393+
<tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
394+
{{#responses}}
395+
<tr><td> {{code}} </td><td> {{message}} </td><td> {{#headers}} * {{baseName}} - {{description}} <br> {{/headers}}{{^headers.0}} - {{/headers.0}} </td></tr>
396+
{{/responses}}
397+
</table>
398+
{{/responses.0}}
327399
{{#isDeprecated}}
328400
* @deprecated
329401
{{/isDeprecated}}
@@ -341,6 +413,15 @@ public class {{classname}} {
341413
* {{notes}}{{#requiredParams}}
342414
* @param {{paramName}} {{description}} (required){{/requiredParams}}
343415
* @return API{{operationId}}Request
416+
{{#responses.0}}
417+
* @http.response.details
418+
<table summary="Response Details" border="1">
419+
<tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
420+
{{#responses}}
421+
<tr><td> {{code}} </td><td> {{message}} </td><td> {{#headers}} * {{baseName}} - {{description}} <br> {{/headers}}{{^headers.0}} - {{/headers.0}} </td></tr>
422+
{{/responses}}
423+
</table>
424+
{{/responses.0}}
344425
{{#isDeprecated}}
345426
* @deprecated
346427
{{/isDeprecated}}

modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/api_doc.mustache

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,5 +81,14 @@ Name | Type | Description | Notes
8181
- **Content-Type**: {{#consumes}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/consumes}}{{^consumes}}Not defined{{/consumes}}
8282
- **Accept**: {{#produces}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/produces}}{{^produces}}Not defined{{/produces}}
8383

84+
{{#responses.0}}
85+
### HTTP response details
86+
| Status code | Description | Response headers |
87+
|-------------|-------------|------------------|
88+
{{#responses}}
89+
**{{code}}** | {{message}} | {{#headers}} * {{baseName}} - {{description}} <br> {{/headers}}{{^headers.0}} - {{/headers.0}} |
90+
{{/responses}}
91+
{{/responses.0}}
92+
8493
{{/operation}}
8594
{{/operations}}

modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/pom.mustache

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,15 @@
149149
<goals>
150150
<goal>jar</goal>
151151
</goals>
152+
<configuration>
153+
<tags>
154+
<tag>
155+
<name>http.response.details</name>
156+
<placement>a</placement>
157+
<head>Http Response Details:</head>
158+
</tag>
159+
</tags>
160+
</configuration>
152161
</execution>
153162
</executions>
154163
</plugin>

samples/client/petstore/java/okhttp-gson-parcelableModel/docs/AnotherFakeApi.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,8 @@ No authorization required
5252
- **Content-Type**: application/json
5353
- **Accept**: application/json
5454

55+
### HTTP response details
56+
| Status code | Description | Response headers |
57+
|-------------|-------------|------------------|
58+
**200** | successful operation | - |
59+

samples/client/petstore/java/okhttp-gson-parcelableModel/docs/FakeApi.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ No authorization required
6363
- **Content-Type**: application/xml, application/xml; charset=utf-8, application/xml; charset=utf-16, text/xml, text/xml; charset=utf-8, text/xml; charset=utf-16
6464
- **Accept**: Not defined
6565

66+
### HTTP response details
67+
| Status code | Description | Response headers |
68+
|-------------|-------------|------------------|
69+
**200** | successful operation | - |
70+
6671
<a name="fakeOuterBooleanSerialize"></a>
6772
# **fakeOuterBooleanSerialize**
6873
> Boolean fakeOuterBooleanSerialize(body)
@@ -108,6 +113,11 @@ No authorization required
108113
- **Content-Type**: Not defined
109114
- **Accept**: */*
110115

116+
### HTTP response details
117+
| Status code | Description | Response headers |
118+
|-------------|-------------|------------------|
119+
**200** | Output boolean | - |
120+
111121
<a name="fakeOuterCompositeSerialize"></a>
112122
# **fakeOuterCompositeSerialize**
113123
> OuterComposite fakeOuterCompositeSerialize(body)
@@ -153,6 +163,11 @@ No authorization required
153163
- **Content-Type**: Not defined
154164
- **Accept**: */*
155165

166+
### HTTP response details
167+
| Status code | Description | Response headers |
168+
|-------------|-------------|------------------|
169+
**200** | Output composite | - |
170+
156171
<a name="fakeOuterNumberSerialize"></a>
157172
# **fakeOuterNumberSerialize**
158173
> BigDecimal fakeOuterNumberSerialize(body)
@@ -198,6 +213,11 @@ No authorization required
198213
- **Content-Type**: Not defined
199214
- **Accept**: */*
200215

216+
### HTTP response details
217+
| Status code | Description | Response headers |
218+
|-------------|-------------|------------------|
219+
**200** | Output number | - |
220+
201221
<a name="fakeOuterStringSerialize"></a>
202222
# **fakeOuterStringSerialize**
203223
> String fakeOuterStringSerialize(body)
@@ -243,6 +263,11 @@ No authorization required
243263
- **Content-Type**: Not defined
244264
- **Accept**: */*
245265

266+
### HTTP response details
267+
| Status code | Description | Response headers |
268+
|-------------|-------------|------------------|
269+
**200** | Output string | - |
270+
246271
<a name="testBodyWithFileSchema"></a>
247272
# **testBodyWithFileSchema**
248273
> testBodyWithFileSchema(body)
@@ -287,6 +312,11 @@ No authorization required
287312
- **Content-Type**: application/json
288313
- **Accept**: Not defined
289314

315+
### HTTP response details
316+
| Status code | Description | Response headers |
317+
|-------------|-------------|------------------|
318+
**200** | Success | - |
319+
290320
<a name="testBodyWithQueryParams"></a>
291321
# **testBodyWithQueryParams**
292322
> testBodyWithQueryParams(query, body)
@@ -331,6 +361,11 @@ No authorization required
331361
- **Content-Type**: application/json
332362
- **Accept**: Not defined
333363

364+
### HTTP response details
365+
| Status code | Description | Response headers |
366+
|-------------|-------------|------------------|
367+
**200** | Success | - |
368+
334369
<a name="testClientModel"></a>
335370
# **testClientModel**
336371
> Client testClientModel(body)
@@ -376,6 +411,11 @@ No authorization required
376411
- **Content-Type**: application/json
377412
- **Accept**: application/json
378413

414+
### HTTP response details
415+
| Status code | Description | Response headers |
416+
|-------------|-------------|------------------|
417+
**200** | successful operation | - |
418+
379419
<a name="testEndpointParameters"></a>
380420
# **testEndpointParameters**
381421
> testEndpointParameters(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binary, date, dateTime, password, paramCallback)
@@ -455,6 +495,12 @@ null (empty response body)
455495
- **Content-Type**: application/x-www-form-urlencoded
456496
- **Accept**: Not defined
457497

498+
### HTTP response details
499+
| Status code | Description | Response headers |
500+
|-------------|-------------|------------------|
501+
**400** | Invalid username supplied | - |
502+
**404** | User not found | - |
503+
458504
<a name="testEnumParameters"></a>
459505
# **testEnumParameters**
460506
> testEnumParameters(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString)
@@ -513,6 +559,12 @@ No authorization required
513559
- **Content-Type**: application/x-www-form-urlencoded
514560
- **Accept**: Not defined
515561

562+
### HTTP response details
563+
| Status code | Description | Response headers |
564+
|-------------|-------------|------------------|
565+
**400** | Invalid request | - |
566+
**404** | Not found | - |
567+
516568
<a name="testGroupParameters"></a>
517569
# **testGroupParameters**
518570
> testGroupParameters(requiredStringGroup, requiredBooleanGroup, requiredInt64Group).stringGroup(stringGroup).booleanGroup(booleanGroup).int64Group(int64Group).execute();
@@ -571,6 +623,11 @@ No authorization required
571623
- **Content-Type**: Not defined
572624
- **Accept**: Not defined
573625

626+
### HTTP response details
627+
| Status code | Description | Response headers |
628+
|-------------|-------------|------------------|
629+
**400** | Someting wrong | - |
630+
574631
<a name="testInlineAdditionalProperties"></a>
575632
# **testInlineAdditionalProperties**
576633
> testInlineAdditionalProperties(param)
@@ -613,6 +670,11 @@ No authorization required
613670
- **Content-Type**: application/json
614671
- **Accept**: Not defined
615672

673+
### HTTP response details
674+
| Status code | Description | Response headers |
675+
|-------------|-------------|------------------|
676+
**200** | successful operation | - |
677+
616678
<a name="testJsonFormData"></a>
617679
# **testJsonFormData**
618680
> testJsonFormData(param, param2)
@@ -657,3 +719,8 @@ No authorization required
657719
- **Content-Type**: application/x-www-form-urlencoded
658720
- **Accept**: Not defined
659721

722+
### HTTP response details
723+
| Status code | Description | Response headers |
724+
|-------------|-------------|------------------|
725+
**200** | successful operation | - |
726+

samples/client/petstore/java/okhttp-gson-parcelableModel/docs/FakeClassnameTags123Api.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,8 @@ Name | Type | Description | Notes
6262
- **Content-Type**: application/json
6363
- **Accept**: application/json
6464

65+
### HTTP response details
66+
| Status code | Description | Response headers |
67+
|-------------|-------------|------------------|
68+
**200** | successful operation | - |
69+

0 commit comments

Comments
 (0)