1 | package edu.ucsb.cs156.spring.backenddemo.controllers; | |
2 | ||
3 | import org.springframework.beans.factory.annotation.Autowired; | |
4 | import org.springframework.http.ResponseEntity; | |
5 | import org.springframework.web.bind.annotation.GetMapping; | |
6 | import org.springframework.web.bind.annotation.RequestMapping; | |
7 | import org.springframework.web.bind.annotation.RequestParam; | |
8 | import org.springframework.web.bind.annotation.RestController; | |
9 | ||
10 | import com.fasterxml.jackson.core.JsonProcessingException; | |
11 | import com.fasterxml.jackson.databind.ObjectMapper; | |
12 | ||
13 | import edu.ucsb.cs156.spring.backenddemo.services.UniversityQueryService; | |
14 | import io.swagger.v3.oas.annotations.Operation; | |
15 | import io.swagger.v3.oas.annotations.Parameter; | |
16 | import io.swagger.v3.oas.annotations.tags.Tag; | |
17 | import lombok.extern.slf4j.Slf4j; | |
18 | ||
19 | @Tag(name="University info from universities.hipolabs.com") | |
20 | @Slf4j | |
21 | @RestController | |
22 | @RequestMapping("/api/university") | |
23 | public class UniversityController { | |
24 | ||
25 | ObjectMapper mapper = new ObjectMapper(); | |
26 | ||
27 | @Autowired | |
28 | UniversityQueryService universityQueryService; | |
29 | ||
30 | @Operation(summary="Get a list of universities that match a given name", description ="Uses API documented here: http://universities.hipolabs.com/search") | |
31 | @GetMapping("/get") | |
32 | public ResponseEntity<String> getUniversityResponse( | |
33 | @Parameter(name="university", example="Harvard") @RequestParam String university | |
34 | ) throws JsonProcessingException { | |
35 | log.info("getUniversityResponse: university={}", university); | |
36 | String result = universityQueryService.getJSON(university); | |
37 |
1
1. getUniversityResponse : replaced return value with null for edu/ucsb/cs156/spring/backenddemo/controllers/UniversityController::getUniversityResponse → KILLED |
return ResponseEntity.ok().body(result); |
38 | } | |
39 | | |
40 | } | |
Mutations | ||
37 |
1.1 |