-
Notifications
You must be signed in to change notification settings - Fork 240
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Solution #200
base: main
Are you sure you want to change the base?
Solution #200
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add DTOs for your responses and a mapper if needed and we are good:)
return characterService.getRandomCharacter(); | ||
} | ||
|
||
@GetMapping("/search") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@GetMapping
REST is rather resource oriented
@GetMapping("/random") | ||
@Operation(summary = "Get a random character", | ||
description = "Returns a random character from the database.") | ||
public Optional<Character> getRandomCharacter() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Controllers should work with DTO objects, not with model. Create a response DTO for this endpoint
@GetMapping("/search") | ||
@Operation(summary = "Search characters by name", | ||
description = "Returns a list of characters whose name contains the specified word.") | ||
public List<Character> searchCharactersByName(@RequestParam String word) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, return list of DTO responses
|
||
@Getter | ||
@Setter | ||
public class RickAndMortyResponse { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This class name is just the name of whole app, it's not clear why RickAndMorty fetches all characters, it's more like CharacterListDto or something like that
No description provided.