16
16
17
17
package io .swagger .sample .resource ;
18
18
19
+ import io .swagger .v3 .oas .annotations .OpenAPIDefinition ;
19
20
import io .swagger .v3 .oas .annotations .Operation ;
20
21
import io .swagger .v3 .oas .annotations .Parameter ;
22
+ import io .swagger .v3 .oas .annotations .info .Info ;
21
23
import io .swagger .v3 .oas .annotations .media .Content ;
22
24
import io .swagger .v3 .oas .annotations .media .Schema ;
23
25
import io .swagger .v3 .oas .annotations .responses .ApiResponse ;
24
26
import io .swagger .sample .data .PetData ;
25
27
import io .swagger .sample .model .Pet ;
28
+ import io .swagger .v3 .oas .annotations .servers .Server ;
26
29
import org .springframework .stereotype .Service ;
27
30
28
31
import javax .ws .rs .BeanParam ;
34
37
import javax .ws .rs .Produces ;
35
38
import javax .ws .rs .Consumes ;
36
39
import javax .ws .rs .QueryParam ;
40
+ import javax .ws .rs .core .MediaType ;
37
41
import javax .ws .rs .core .Response ;
38
42
import java .util .List ;
39
43
40
44
@ Service
45
+ @ OpenAPIDefinition (
46
+ info = @ Info (title = "Petstore" , version = "2.0.0" , description = "This is a sample Petstore server." ))
41
47
@ Path ("/pet" )
42
- @ Produces ({"application/json" , "application/xml" })
48
+ @ Produces ({MediaType . APPLICATION_JSON , MediaType . APPLICATION_XML })
43
49
public class PetResource {
44
50
static PetData petData = new PetData ();
45
51
@@ -75,7 +81,7 @@ public Pet getPetById(
75
81
}
76
82
77
83
@ POST
78
- @ Consumes ("application/json" )
84
+ @ Consumes (MediaType . APPLICATION_JSON )
79
85
@ Operation (summary = "Add a new pet to the store" ,
80
86
tags = {"pets" },
81
87
responses = {
@@ -88,6 +94,7 @@ public Response addPet(
88
94
}
89
95
90
96
@ PUT
97
+ @ Consumes (MediaType .APPLICATION_JSON )
91
98
@ Operation (summary = "Update an existing pet" ,
92
99
tags = {"pets" },
93
100
responses = {
@@ -107,7 +114,7 @@ public Response updatePet(
107
114
description = "Multiple status values can be provided with comma seperated strings" ,
108
115
responses = {
109
116
@ ApiResponse (
110
- content = @ Content (mediaType = "application/json" ,
117
+ content = @ Content (mediaType = MediaType . APPLICATION_JSON ,
111
118
schema = @ Schema (implementation = Pet .class ))),
112
119
@ ApiResponse (
113
120
responseCode = "400" , description = "Invalid status value"
@@ -135,7 +142,7 @@ public List<Pet> findPetsByStatus(
135
142
description = "Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing." ,
136
143
responses = {
137
144
@ ApiResponse (description = "Pets matching criteria" ,
138
- content = @ Content (mediaType = "application/json" ,
145
+ content = @ Content (mediaType = MediaType . APPLICATION_JSON ,
139
146
schema = @ Schema (implementation = Pet .class ))
140
147
),
141
148
@ ApiResponse (description = "Invalid tag value" , responseCode = "400" )
0 commit comments