1616
1717package io .swagger .sample .resource ;
1818
19+ import io .swagger .v3 .oas .annotations .OpenAPIDefinition ;
1920import io .swagger .v3 .oas .annotations .Operation ;
2021import io .swagger .v3 .oas .annotations .Parameter ;
22+ import io .swagger .v3 .oas .annotations .info .Info ;
2123import io .swagger .v3 .oas .annotations .media .Content ;
2224import io .swagger .v3 .oas .annotations .media .Schema ;
2325import io .swagger .v3 .oas .annotations .responses .ApiResponse ;
2426import io .swagger .sample .data .PetData ;
2527import io .swagger .sample .model .Pet ;
28+ import io .swagger .v3 .oas .annotations .servers .Server ;
2629import org .springframework .stereotype .Service ;
2730
2831import javax .ws .rs .BeanParam ;
3437import javax .ws .rs .Produces ;
3538import javax .ws .rs .Consumes ;
3639import javax .ws .rs .QueryParam ;
40+ import javax .ws .rs .core .MediaType ;
3741import javax .ws .rs .core .Response ;
3842import java .util .List ;
3943
4044@ Service
45+ @ OpenAPIDefinition (
46+ info = @ Info (title = "Petstore" , version = "2.0.0" , description = "This is a sample Petstore server." ))
4147@ Path ("/pet" )
42- @ Produces ({"application/json" , "application/xml" })
48+ @ Produces ({MediaType . APPLICATION_JSON , MediaType . APPLICATION_XML })
4349public class PetResource {
4450 static PetData petData = new PetData ();
4551
@@ -75,7 +81,7 @@ public Pet getPetById(
7581 }
7682
7783 @ POST
78- @ Consumes ("application/json" )
84+ @ Consumes (MediaType . APPLICATION_JSON )
7985 @ Operation (summary = "Add a new pet to the store" ,
8086 tags = {"pets" },
8187 responses = {
@@ -88,6 +94,7 @@ public Response addPet(
8894 }
8995
9096 @ PUT
97+ @ Consumes (MediaType .APPLICATION_JSON )
9198 @ Operation (summary = "Update an existing pet" ,
9299 tags = {"pets" },
93100 responses = {
@@ -107,7 +114,7 @@ public Response updatePet(
107114 description = "Multiple status values can be provided with comma seperated strings" ,
108115 responses = {
109116 @ ApiResponse (
110- content = @ Content (mediaType = "application/json" ,
117+ content = @ Content (mediaType = MediaType . APPLICATION_JSON ,
111118 schema = @ Schema (implementation = Pet .class ))),
112119 @ ApiResponse (
113120 responseCode = "400" , description = "Invalid status value"
@@ -135,7 +142,7 @@ public List<Pet> findPetsByStatus(
135142 description = "Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing." ,
136143 responses = {
137144 @ ApiResponse (description = "Pets matching criteria" ,
138- content = @ Content (mediaType = "application/json" ,
145+ content = @ Content (mediaType = MediaType . APPLICATION_JSON ,
139146 schema = @ Schema (implementation = Pet .class ))
140147 ),
141148 @ ApiResponse (description = "Invalid tag value" , responseCode = "400" )
0 commit comments