Skip to content
This repository was archived by the owner on Oct 30, 2023. It is now read-only.

Commit e59f2d9

Browse files
committed
merged more detailled annotations from swagger-jaxrs2-resources
1 parent 14400e2 commit e59f2d9

File tree

1 file changed

+68
-17
lines changed
  • java/java-cxf-spring-boot-minimal/src/main/java/io/swagger/sample/resource

1 file changed

+68
-17
lines changed

java/java-cxf-spring-boot-minimal/src/main/java/io/swagger/sample/resource/PetResource.java

Lines changed: 68 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import io.swagger.sample.model.Pet;
2626
import org.springframework.stereotype.Service;
2727

28-
import javax.validation.constraints.NotNull;
2928
import javax.ws.rs.BeanParam;
3029
import javax.ws.rs.GET;
3130
import javax.ws.rs.POST;
@@ -46,7 +45,27 @@ public class PetResource {
4645

4746
@GET
4847
@Path("/{petId}")
49-
public Pet getPetById(@PathParam("petId") Long petId) throws io.swagger.sample.exception.NotFoundException {
48+
@Operation(summary = "Find pet by ID",
49+
tags = {"pets"},
50+
description = "Returns a pet when 0 < ID <= 10. ID > 10 or nonintegers will simulate API error conditions",
51+
responses = {
52+
@ApiResponse(description = "The pet", content = @Content(
53+
schema = @Schema(implementation = Pet.class)
54+
)),
55+
@ApiResponse(responseCode = "400", description = "Invalid ID supplied"),
56+
@ApiResponse(responseCode = "404", description = "Pet not found")
57+
})
58+
public Pet getPetById(
59+
@Parameter(
60+
description = "ID of pet that needs to be fetched",
61+
schema = @Schema(
62+
type = "integer",
63+
format = "int64",
64+
description = "param ID of pet that needs to be fetched",
65+
allowableValues = {"1","2","3"}
66+
),
67+
required = true)
68+
@PathParam("petId") Long petId) throws io.swagger.sample.exception.NotFoundException {
5069
Pet pet = petData.getPetById(petId);
5170
if (null != pet) {
5271
return pet;
@@ -57,41 +76,73 @@ public Pet getPetById(@PathParam("petId") Long petId) throws io.swagger.sample.e
5776

5877
@POST
5978
@Consumes("application/json")
79+
@Operation(summary = "Add a new pet to the store",
80+
tags = {"pets"},
81+
responses = {
82+
@ApiResponse(responseCode = "405", description = "Invalid input")
83+
})
6084
public Response addPet(
61-
@Parameter(description = "Pet object that needs to be added to the store", required = true) Pet pet) {
85+
@Parameter(description = "Pet object that needs to be added to the store", required = true) Pet pet) {
6286
petData.addPet(pet);
6387
return Response.ok().entity("SUCCESS").build();
6488
}
6589

6690
@PUT
91+
@Operation(summary = "Update an existing pet",
92+
tags = {"pets"},
93+
responses = {
94+
@ApiResponse(responseCode = "400", description = "Invalid ID supplied"),
95+
@ApiResponse(responseCode = "404", description = "Pet not found"),
96+
@ApiResponse(responseCode = "405", description = "Validation exception") })
6797
public Response updatePet(
68-
@Parameter(description = "Pet object that needs to be added to the store", required = true) Pet pet) {
98+
@Parameter(description = "Pet object that needs to be added to the store", required = true) Pet pet) {
6999
petData.addPet(pet);
70100
return Response.ok().entity("SUCCESS").build();
71101
}
72102

73103
@GET
74104
@Path("/findByStatus")
105+
@Operation(summary = "Finds Pets by status",
106+
tags = {"pets"},
107+
description = "Multiple status values can be provided with comma seperated strings",
108+
responses = {
109+
@ApiResponse(
110+
content = @Content(mediaType = "application/json",
111+
schema = @Schema(implementation = Pet.class))),
112+
@ApiResponse(
113+
responseCode = "400", description = "Invalid status value"
114+
)}
115+
)
75116
public List<Pet> findPetsByStatus(
76-
@Parameter(
77-
description = "Status values that need to be considered for filter",
78-
required = true,
79-
schema = @Schema(
80-
allowableValues = {"available","pending","sold"},
81-
defaultValue = "available"
82-
)
83-
)
84-
@QueryParam("status") String status,
85-
@BeanParam QueryResultBean qr
86-
){
117+
@Parameter(
118+
description = "Status values that need to be considered for filter",
119+
required = true,
120+
schema = @Schema(
121+
allowableValues = {"available","pending","sold"},
122+
defaultValue = "available"
123+
)
124+
)
125+
@QueryParam("status") String status,
126+
@BeanParam QueryResultBean qr
127+
){
87128
return petData.findPetByStatus(status);
88129
}
89130

90131
@GET
91132
@Path("/findByTags")
133+
@Operation(summary = "Finds Pets by tags",
134+
tags = {"pets"},
135+
description = "Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.",
136+
responses = {
137+
@ApiResponse(description = "Pets matching criteria",
138+
content = @Content(mediaType = "application/json",
139+
schema = @Schema(implementation = Pet.class))
140+
),
141+
@ApiResponse(description = "Invalid tag value", responseCode = "400")
142+
})
92143
@Deprecated
93144
public List<Pet> findPetsByTags(
94-
@NotNull @QueryParam("tags") String tags) {
145+
@Parameter(description = "Tags to filter by", required = true) @QueryParam("tags") String tags) {
95146
return petData.findPetByTags(tags);
96147
}
97-
}
148+
}

0 commit comments

Comments
 (0)