Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Java][JAXRS-CXF] Improve API documentation in the CXF Server stub and Client generation #6708

Merged
merged 8 commits into from
Oct 22, 2017
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@ import javax.validation.constraints.*;
import javax.validation.Valid;
{{/useBeanValidation}}

{{#appName}}
/**
* {{{appName}}}
*
{{#appDescription}}
* <p>{{{appDescription}}}
*
{{/appDescription}}
*/
{{/appName}}
@Path("{{^useAnnotatedBasePath}}/{{/useAnnotatedBasePath}}{{#useAnnotatedBasePath}}{{contextPath}}{{/useAnnotatedBasePath}}")
@Api(value = "/", description = "{{description}}")
{{#addConsumesProducesJson}}
Expand All @@ -32,6 +42,16 @@ public interface {{classname}} {
{{#operations}}
{{#operation}}

{{#summary}}
/**
* {{summary}}
*
{{#notes}}
* {{notes}}
*
{{/notes}}
*/
{{/summary}}
@{{httpMethod}}
{{#subresourceOperation}}@Path("{{{path}}}"){{/subresourceOperation}}
{{#hasConsumes}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,29 @@ import org.springframework.stereotype.Service;
{{/useSpringAnnotationConfig}}
{{#description}}
{{/description}}
{{#appName}}
/**
* {{{appName}}}
*
{{#appDescription}}
* <p>{{{appDescription}}}
{{/appDescription}}
*
*/
{{/appName}}
public class {{classname}}ServiceImpl implements {{classname}} {
{{#operations}}
{{#operation}}
{{#summary}}
/**
* {{summary}}
*
{{#notes}}
* {{notes}}
*
{{/notes}}
*/
{{/summary}}
public {{>returnTypes}} {{nickname}}({{#allParams}}{{>queryParamsImpl}}{{>pathParamsImpl}}{{>headerParamsImpl}}{{>bodyParamsImpl}}{{>formParamsImpl}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) {
// TODO: Implement...

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,15 @@ import org.springframework.test.context.web.WebAppConfiguration;


/**
* API tests for {{classname}}
{{#appName}}
* {{{appName}}}
*
{{/appName}}
{{#appDescription}}
* <p>{{{appDescription}}}
*
{{/appDescription}}
* API tests for {{classname}}
*/
{{#generateSpringBootApplication}}
@RunWith(SpringJUnit4ClassRunner.class)
Expand Down Expand Up @@ -91,10 +99,14 @@ public class {{classname}}Test {

{{#operations}}{{#operation}}
/**
{{#summary}}
* {{summary}}
*
{{#notes}}
* {{notes}}
*
{{/notes}}
{{/summary}}
* @throws ApiException
* if the Api call fails
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ import javax.xml.bind.annotation.XmlEnumValue;
{{^parent}}@XmlRootElement(name="{{classname}}"){{/parent}}
{{/withXml}}
{{#description}}
/**
* {{{description}}}
**/
@ApiModel(description="{{{description}}}")
{{/description}}
public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {
Expand All @@ -28,6 +31,11 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {
@XmlElement(name="{{baseName}}"{{#required}}, required = {{required}}{{/required}})
{{/withXml}}
@ApiModelProperty({{#example}}example = "{{{example}}}", {{/example}}{{#required}}required = {{required}}, {{/required}}value = "{{{description}}}")
{{#description}}
/**
* {{{description}}}
**/
{{/description}}
private {{{datatypeWithEnum}}} {{name}} = {{{defaultValue}}};{{/vars}}

{{#vars}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
<artifactId>{{artifactId}}</artifactId>
<packaging>jar</packaging>
<name>{{artifactId}}</name>
{{#appDescription}}
<description>{{appDescription}}</description>
{{/appDescription}}
<version>{{artifactVersion}}</version>
<build>
<sourceDirectory>src/main/java</sourceDirectory>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
<artifactId>{{artifactId}}</artifactId>
<packaging>war</packaging>
<name>{{artifactId}}</name>
{{#appDescription}}
<description>{{appDescription}}</description>
{{/appDescription}}
<version>{{artifactVersion}}</version>
<build>
<sourceDirectory>src/main/java</sourceDirectory>
Expand Down
1 change: 1 addition & 0 deletions samples/client/petstore/jaxrs-cxf-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<artifactId>jaxrs-cxf-petstore-client</artifactId>
<packaging>war</packaging>
<name>jaxrs-cxf-petstore-client</name>
<description>This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key &#x60;special-key&#x60; to test the authorization filters.</description>
<version>1.0.0</version>
<build>
<sourceDirectory>src/main/java</sourceDirectory>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,22 @@
import javax.validation.constraints.*;
import javax.validation.Valid;

/**
* Swagger Petstore
*
* <p>This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.
*
*/
@Path("/")
@Api(value = "/", description = "")
public interface PetApi {

/**
* Add a new pet to the store
*
*
*
*/
@POST
@Path("/pet")
@Consumes({ "application/json", "application/xml" })
Expand All @@ -34,6 +46,12 @@ public interface PetApi {
@ApiResponse(code = 405, message = "Invalid input") })
public void addPet(@Valid Pet body);

/**
* Deletes a pet
*
*
*
*/
@DELETE
@Path("/pet/{petId}")
@Produces({ "application/xml", "application/json" })
Expand All @@ -42,6 +60,12 @@ public interface PetApi {
@ApiResponse(code = 400, message = "Invalid pet value") })
public void deletePet(@PathParam("petId") Long petId, @HeaderParam("api_key") String apiKey);

/**
* Finds Pets by status
*
* Multiple status values can be provided with comma separated strings
*
*/
@GET
@Path("/pet/findByStatus")
@Produces({ "application/xml", "application/json" })
Expand All @@ -51,6 +75,12 @@ public interface PetApi {
@ApiResponse(code = 400, message = "Invalid status value") })
public List<Pet> findPetsByStatus(@QueryParam("status") @NotNull List<String> status);

/**
* Finds Pets by tags
*
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
*
*/
@GET
@Path("/pet/findByTags")
@Produces({ "application/xml", "application/json" })
Expand All @@ -60,6 +90,12 @@ public interface PetApi {
@ApiResponse(code = 400, message = "Invalid tag value") })
public List<Pet> findPetsByTags(@QueryParam("tags") @NotNull List<String> tags);

/**
* Find pet by ID
*
* Returns a single pet
*
*/
@GET
@Path("/pet/{petId}")
@Produces({ "application/xml", "application/json" })
Expand All @@ -70,6 +106,12 @@ public interface PetApi {
@ApiResponse(code = 404, message = "Pet not found") })
public Pet getPetById(@PathParam("petId") Long petId);

/**
* Update an existing pet
*
*
*
*/
@PUT
@Path("/pet")
@Consumes({ "application/json", "application/xml" })
Expand All @@ -81,6 +123,12 @@ public interface PetApi {
@ApiResponse(code = 405, message = "Validation exception") })
public void updatePet(@Valid Pet body);

/**
* Updates a pet in the store with form data
*
*
*
*/
@POST
@Path("/pet/{petId}")
@Consumes({ "application/x-www-form-urlencoded" })
Expand All @@ -90,6 +138,12 @@ public interface PetApi {
@ApiResponse(code = 405, message = "Invalid input") })
public void updatePetWithForm(@PathParam("petId") Long petId, @Multipart(value = "name", required = false) String name, @Multipart(value = "status", required = false) String status);

/**
* uploads an image
*
*
*
*/
@POST
@Path("/pet/{petId}/uploadImage")
@Consumes({ "multipart/form-data" })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,22 @@
import javax.validation.constraints.*;
import javax.validation.Valid;

/**
* Swagger Petstore
*
* <p>This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.
*
*/
@Path("/")
@Api(value = "/", description = "")
public interface StoreApi {

/**
* Delete purchase order by ID
*
* For valid response try integer IDs with value &lt; 1000. Anything above 1000 or nonintegers will generate API errors
*
*/
@DELETE
@Path("/store/order/{orderId}")
@Produces({ "application/xml", "application/json" })
Expand All @@ -33,6 +45,12 @@ public interface StoreApi {
@ApiResponse(code = 404, message = "Order not found") })
public void deleteOrder(@PathParam("orderId") String orderId);

/**
* Returns pet inventories by status
*
* Returns a map of status codes to quantities
*
*/
@GET
@Path("/store/inventory")
@Produces({ "application/json" })
Expand All @@ -41,6 +59,12 @@ public interface StoreApi {
@ApiResponse(code = 200, message = "successful operation", response = Map.class, responseContainer = "Map") })
public Map<String, Integer> getInventory();

/**
* Find purchase order by ID
*
* For valid response try integer IDs with value &lt;&#x3D; 5 or &gt; 10. Other values will generated exceptions
*
*/
@GET
@Path("/store/order/{orderId}")
@Produces({ "application/xml", "application/json" })
Expand All @@ -51,6 +75,12 @@ public interface StoreApi {
@ApiResponse(code = 404, message = "Order not found") })
public Order getOrderById(@PathParam("orderId") @Min(1) @Max(5) Long orderId);

/**
* Place an order for a pet
*
*
*
*/
@POST
@Path("/store/order")
@Produces({ "application/xml", "application/json" })
Expand Down
Loading