Skip to content

Commit e51f548

Browse files
committed
Merge pull request #559 from wing328/java_doc
Update Java documentation for methods (endpoints)
2 parents 8a21483 + c2b3e68 commit e51f548

File tree

5 files changed

+132
-24
lines changed

5 files changed

+132
-24
lines changed

modules/swagger-codegen/src/main/resources/Java/api.mustache

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,12 @@ public class {{classname}} {
3737
}
3838

3939
{{#operation}}
40-
{{#errorList}} //error info- code: {{code}} reason: "{{reason}}" model: {{#responseModel}}{{responseModel}}
41-
{{/responseModel}}{{^responseModel}}<none>
42-
{{/responseModel}}
43-
{{/errorList}}
40+
/**
41+
* {{summary}}
42+
* {{notes}}
43+
{{#allParams}} * @param {{paramName}} {{description}}
44+
{{/allParams}} * @return {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}
45+
*/
4446
public {{#returnType}}{{{returnType}}} {{/returnType}}{{^returnType}}void {{/returnType}}{{nickname}} ({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) throws ApiException {
4547
Object postBody = {{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}null{{/bodyParam}};
4648
{{#requiredParamCount}}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Hello world!

samples/client/petstore/java/src/main/java/io/swagger/client/api/PetApi.java

Lines changed: 53 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,12 @@ public String getBasePath() {
3636
}
3737

3838

39-
39+
/**
40+
* Update an existing pet
41+
*
42+
* @param body Pet object that needs to be added to the store
43+
* @return void
44+
*/
4045
public void updatePet (Pet body) throws ApiException {
4146
Object postBody = body;
4247

@@ -81,7 +86,12 @@ public void updatePet (Pet body) throws ApiException {
8186
}
8287
}
8388

84-
89+
/**
90+
* Add a new pet to the store
91+
*
92+
* @param body Pet object that needs to be added to the store
93+
* @return void
94+
*/
8595
public void addPet (Pet body) throws ApiException {
8696
Object postBody = body;
8797

@@ -126,7 +136,12 @@ public void addPet (Pet body) throws ApiException {
126136
}
127137
}
128138

129-
139+
/**
140+
* Finds Pets by status
141+
* Multiple status values can be provided with comma seperated strings
142+
* @param status Status values that need to be considered for filter
143+
* @return List<Pet>
144+
*/
130145
public List<Pet> findPetsByStatus (List<String> status) throws ApiException {
131146
Object postBody = null;
132147

@@ -173,7 +188,12 @@ public List<Pet> findPetsByStatus (List<String> status) throws ApiException {
173188
}
174189
}
175190

176-
191+
/**
192+
* Finds Pets by tags
193+
* Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.
194+
* @param tags Tags to filter by
195+
* @return List<Pet>
196+
*/
177197
public List<Pet> findPetsByTags (List<String> tags) throws ApiException {
178198
Object postBody = null;
179199

@@ -220,7 +240,12 @@ public List<Pet> findPetsByTags (List<String> tags) throws ApiException {
220240
}
221241
}
222242

223-
243+
/**
244+
* Find pet by ID
245+
* Returns a pet when ID &lt; 10. ID &gt; 10 or nonintegers will simulate API error conditions
246+
* @param petId ID of pet that needs to be fetched
247+
* @return Pet
248+
*/
224249
public Pet getPetById (Long petId) throws ApiException {
225250
Object postBody = null;
226251

@@ -266,7 +291,14 @@ public Pet getPetById (Long petId) throws ApiException {
266291
}
267292
}
268293

269-
294+
/**
295+
* Updates a pet in the store with form data
296+
*
297+
* @param petId ID of pet that needs to be updated
298+
* @param name Updated name of the pet
299+
* @param status Updated status of the pet
300+
* @return void
301+
*/
270302
public void updatePetWithForm (String petId, String name, String status) throws ApiException {
271303
Object postBody = null;
272304

@@ -320,7 +352,13 @@ public void updatePetWithForm (String petId, String name, String status) throws
320352
}
321353
}
322354

323-
355+
/**
356+
* Deletes a pet
357+
*
358+
* @param apiKey
359+
* @param petId Pet id to delete
360+
* @return void
361+
*/
324362
public void deletePet (String apiKey, Long petId) throws ApiException {
325363
Object postBody = null;
326364

@@ -367,7 +405,14 @@ public void deletePet (String apiKey, Long petId) throws ApiException {
367405
}
368406
}
369407

370-
408+
/**
409+
* uploads an image
410+
*
411+
* @param petId ID of pet to update
412+
* @param additionalMetadata Additional data to pass to server
413+
* @param file file to upload
414+
* @return void
415+
*/
371416
public void uploadFile (Long petId, String additionalMetadata, File file) throws ApiException {
372417
Object postBody = null;
373418

samples/client/petstore/java/src/main/java/io/swagger/client/api/StoreApi.java

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,11 @@ public String getBasePath() {
3636
}
3737

3838

39-
39+
/**
40+
* Returns pet inventories by status
41+
* Returns a map of status codes to quantities
42+
* @return Map<String, Integer>
43+
*/
4044
public Map<String, Integer> getInventory () throws ApiException {
4145
Object postBody = null;
4246

@@ -81,7 +85,12 @@ public Map<String, Integer> getInventory () throws ApiException {
8185
}
8286
}
8387

84-
88+
/**
89+
* Place an order for a pet
90+
*
91+
* @param body order placed for purchasing the pet
92+
* @return Order
93+
*/
8594
public Order placeOrder (Order body) throws ApiException {
8695
Object postBody = body;
8796

@@ -126,7 +135,12 @@ public Order placeOrder (Order body) throws ApiException {
126135
}
127136
}
128137

129-
138+
/**
139+
* Find purchase order by ID
140+
* For valid response try integer IDs with value &lt;= 5 or &gt; 10. Other values will generated exceptions
141+
* @param orderId ID of pet that needs to be fetched
142+
* @return Order
143+
*/
130144
public Order getOrderById (String orderId) throws ApiException {
131145
Object postBody = null;
132146

@@ -172,7 +186,12 @@ public Order getOrderById (String orderId) throws ApiException {
172186
}
173187
}
174188

175-
189+
/**
190+
* Delete purchase order by ID
191+
* For valid response try integer IDs with value &lt; 1000. Anything above 1000 or nonintegers will generate API errors
192+
* @param orderId ID of the order that needs to be deleted
193+
* @return void
194+
*/
176195
public void deleteOrder (String orderId) throws ApiException {
177196
Object postBody = null;
178197

samples/client/petstore/java/src/main/java/io/swagger/client/api/UserApi.java

Lines changed: 49 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,12 @@ public String getBasePath() {
3636
}
3737

3838

39-
39+
/**
40+
* Create user
41+
* This can only be done by the logged in user.
42+
* @param body Created user object
43+
* @return void
44+
*/
4045
public void createUser (User body) throws ApiException {
4146
Object postBody = body;
4247

@@ -81,7 +86,12 @@ public void createUser (User body) throws ApiException {
8186
}
8287
}
8388

84-
89+
/**
90+
* Creates list of users with given input array
91+
*
92+
* @param body List of user object
93+
* @return void
94+
*/
8595
public void createUsersWithArrayInput (List<User> body) throws ApiException {
8696
Object postBody = body;
8797

@@ -126,7 +136,12 @@ public void createUsersWithArrayInput (List<User> body) throws ApiException {
126136
}
127137
}
128138

129-
139+
/**
140+
* Creates list of users with given input array
141+
*
142+
* @param body List of user object
143+
* @return void
144+
*/
130145
public void createUsersWithListInput (List<User> body) throws ApiException {
131146
Object postBody = body;
132147

@@ -171,7 +186,13 @@ public void createUsersWithListInput (List<User> body) throws ApiException {
171186
}
172187
}
173188

174-
189+
/**
190+
* Logs user into the system
191+
*
192+
* @param username The user name for login
193+
* @param password The password for login in clear text
194+
* @return String
195+
*/
175196
public String loginUser (String username, String password) throws ApiException {
176197
Object postBody = null;
177198

@@ -220,7 +241,11 @@ public String loginUser (String username, String password) throws ApiException {
220241
}
221242
}
222243

223-
244+
/**
245+
* Logs out current logged in user session
246+
*
247+
* @return void
248+
*/
224249
public void logoutUser () throws ApiException {
225250
Object postBody = null;
226251

@@ -265,7 +290,12 @@ public void logoutUser () throws ApiException {
265290
}
266291
}
267292

268-
293+
/**
294+
* Get user by user name
295+
*
296+
* @param username The name that needs to be fetched. Use user1 for testing.
297+
* @return User
298+
*/
269299
public User getUserByName (String username) throws ApiException {
270300
Object postBody = null;
271301

@@ -311,7 +341,13 @@ public User getUserByName (String username) throws ApiException {
311341
}
312342
}
313343

314-
344+
/**
345+
* Updated user
346+
* This can only be done by the logged in user.
347+
* @param username name that need to be deleted
348+
* @param body Updated user object
349+
* @return void
350+
*/
315351
public void updateUser (String username, User body) throws ApiException {
316352
Object postBody = body;
317353

@@ -357,7 +393,12 @@ public void updateUser (String username, User body) throws ApiException {
357393
}
358394
}
359395

360-
396+
/**
397+
* Delete user
398+
* This can only be done by the logged in user.
399+
* @param username The name that needs to be deleted
400+
* @return void
401+
*/
361402
public void deleteUser (String username) throws ApiException {
362403
Object postBody = null;
363404

0 commit comments

Comments
 (0)