File tree Expand file tree Collapse file tree 2 files changed +72
-18
lines changed
src/main/java/com/continiousdisappointment/user/controller Expand file tree Collapse file tree 2 files changed +72
-18
lines changed Original file line number Diff line number Diff line change 33 title : OpenAPI definition
44 version : v0
55servers :
6- - url : http://localhost:8081
7- description : Generated server url
6+ - url : http://localhost:8081
7+ description : Generated server url
88tags :
9- - name : User Controller
10- description : Returns user information, requires bearer authorization
9+ - name : User Preferences Controller
10+ description : " Handles user dietary preferences, requires bearer authorization"
11+ - name : User Controller
12+ description : " Returns user information, requires bearer authorization"
1113paths :
12- /info :
14+ /user/preferences :
15+ post :
16+ tags :
17+ - User Preferences Controller
18+ operationId : saveUserPreferences
19+ parameters :
20+ - name : Authorization
21+ in : header
22+ required : true
23+ schema :
24+ type : string
25+ requestBody :
26+ content :
27+ application/json :
28+ schema :
29+ $ref : " #/components/schemas/SaveUserPreferencesRequestDto"
30+ required : true
31+ responses :
32+ " 200 " :
33+ description : OK
34+ content :
35+ ' */* ' :
36+ schema :
37+ type : object
38+ /user/info :
1339 get :
1440 tags :
15- - User Controller
41+ - User Controller
1642 operationId : getUserInfo
1743 parameters :
18- - name : Authorization
19- in : header
20- required : true
21- schema :
22- type : string
44+ - name : Authorization
45+ in : header
46+ required : true
47+ schema :
48+ type : string
2349 responses :
24- ' 200 ' :
50+ " 200 " :
2551 description : OK
2652 content :
2753 ' */* ' :
2854 schema :
29- $ref : ' #/components/schemas/User'
55+ $ref : " #/components/schemas/User"
3056components :
3157 schemas :
58+ SaveUserPreferencesRequestDto :
59+ type : object
60+ properties :
61+ dietaryPreferences :
62+ uniqueItems : true
63+ type : array
64+ items :
65+ type : string
66+ enum :
67+ - VEGETARIAN
68+ - VEGAN
69+ - GLUTEN_FREE
70+ - DAIRY_FREE
71+ - NUT_FREE
72+ - SPICY_FOOD
3273 User :
3374 type : object
3475 properties :
76+ username :
77+ type : string
3578 id :
3679 type : integer
3780 format : int32
38- username :
39- type : string
81+ dietaryPreferences :
82+ uniqueItems : true
83+ type : array
84+ items :
85+ type : string
86+ enum :
87+ - VEGETARIAN
88+ - VEGAN
89+ - GLUTEN_FREE
90+ - DAIRY_FREE
91+ - NUT_FREE
92+ - SPICY_FOOD
Original file line number Diff line number Diff line change 22
33import org .springframework .http .HttpStatus ;
44import org .springframework .http .ResponseEntity ;
5- import org .springframework .stereotype .Controller ;
65import org .springframework .web .bind .annotation .PostMapping ;
76import org .springframework .web .bind .annotation .RequestBody ;
87import org .springframework .web .bind .annotation .RequestHeader ;
98import org .springframework .web .bind .annotation .RequestMapping ;
9+ import org .springframework .web .bind .annotation .RestController ;
1010
1111import com .continiousdisappointment .user .dto .SaveUserPreferencesRequestDto ;
1212import com .continiousdisappointment .user .service .UserService ;
1313
14+ import io .swagger .v3 .oas .annotations .tags .Tag ;
1415import lombok .RequiredArgsConstructor ;
1516import lombok .extern .log4j .Log4j2 ;
1617
17- @ Controller
18+ @ RestController
1819@ RequestMapping ("user/preferences" )
1920@ Log4j2
2021@ RequiredArgsConstructor
22+ @ Tag (name = "User Preferences Controller" , description = "Handles user dietary preferences, requires bearer authorization" )
2123public class UserPreferencesController {
2224 private final UserService userService ;
2325
2426 @ PostMapping
2527 public ResponseEntity <Object > saveUserPreferences (@ RequestHeader ("Authorization" ) String authorization ,
2628 @ RequestBody SaveUserPreferencesRequestDto request ) {
2729 try {
28-
2930 userService .saveUserPreferences (authorization , request .dietaryPreferences ());
3031
3132 } catch (Exception e ) {
You can’t perform that action at this time.
0 commit comments