Skip to content

Commit

Permalink
swagger
Browse files Browse the repository at this point in the history
  • Loading branch information
YevheniiVlasenko committed May 6, 2024
1 parent ba7f612 commit 9ae642d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package mate.academy.rickandmorty.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import java.util.List;
import lombok.RequiredArgsConstructor;
import mate.academy.rickandmorty.dto.ResponseDto;
Expand All @@ -13,14 +15,19 @@
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/characters")
@Tag(name = "Rick and Morty management")
public class CharacterController {
private final CharacterService service;

@Operation(summary = "Get by name",
description = "Returns list of characters by name or name part")
@GetMapping("/by-name")
public List<ResponseDto> getCharactersByName(@RequestParam String name, Pageable pageable) {
return service.getCharactersByName(name, pageable);
}

@Operation(summary = "Get random character from DB",
description = "Returns random character from DB")
@GetMapping("/random")
public ResponseDto getRandomCharacter() {
return service.getRandomCharacter();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ public class CharacterLoaderRunner {
public ApplicationRunner loadCharactersAtStartUp() {
return args -> {
try {
System.out.println("Loading characters from external API");
repository.saveAll(client.getAll());
} catch (Exception e) {
throw new LoadExternalDataException(
Expand Down

0 comments on commit 9ae642d

Please sign in to comment.