Skip to content

Commit 050da18

Browse files
authored
Merge pull request #127 from AET-DevOps25/update-swagger
Update user ms swagger
2 parents 8b76605 + 980a5df commit 050da18

File tree

2 files changed

+72
-18
lines changed

2 files changed

+72
-18
lines changed

server/user/openapi.yml

Lines changed: 68 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,37 +3,90 @@ info:
33
title: OpenAPI definition
44
version: v0
55
servers:
6-
- url: http://localhost:8081
7-
description: Generated server url
6+
- url: http://localhost:8081
7+
description: Generated server url
88
tags:
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"
1113
paths:
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"
3056
components:
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

server/user/src/main/java/com/continiousdisappointment/user/controller/UserPreferencesController.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,31 @@
22

33
import org.springframework.http.HttpStatus;
44
import org.springframework.http.ResponseEntity;
5-
import org.springframework.stereotype.Controller;
65
import org.springframework.web.bind.annotation.PostMapping;
76
import org.springframework.web.bind.annotation.RequestBody;
87
import org.springframework.web.bind.annotation.RequestHeader;
98
import org.springframework.web.bind.annotation.RequestMapping;
9+
import org.springframework.web.bind.annotation.RestController;
1010

1111
import com.continiousdisappointment.user.dto.SaveUserPreferencesRequestDto;
1212
import com.continiousdisappointment.user.service.UserService;
1313

14+
import io.swagger.v3.oas.annotations.tags.Tag;
1415
import lombok.RequiredArgsConstructor;
1516
import 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")
2123
public 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) {

0 commit comments

Comments
 (0)