Unverified Commit df78b3cf authored by Alexandre Touret's avatar Alexandre Touret
Browse files

[skip ci] WIP: Saving current work

parent bf0b21f4
Branches
2 merge requests!3Forking spring-petclinic-rest attempt #2,!2Forked spring-petclinic-rest
Showing with 15 additions and 8 deletions
......@@ -33,6 +33,8 @@
<!-- Docker -->
<docker.jib-maven-plugin.version>1.3.0</docker.jib-maven-plugin.version>
<docker.image.prefix>springcommunity</docker.image.prefix>
<maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
<spring-boot-maven-plugin.version>2.6.2</spring-boot-maven-plugin.version>
</properties>
<dependencies>
......@@ -164,6 +166,7 @@
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot-maven-plugin.version}</version>
<executions>
<execution>
<!-- Spring Boot Actuator displays build-related information
......@@ -221,7 +224,7 @@
<minimum>0.66</minimum>
</limit>
</limits>
</rule>
</rule>
</rules>
</configuration>
</execution>
......@@ -272,8 +275,10 @@
<apiPackage>org.springframework.samples.petclinic.rest.api</apiPackage>
<generateModels>true</generateModels>
<modelPackage>org.springframework.samples.petclinic.rest.dto</modelPackage>
<!--
<generateSupportingFiles>true</generateSupportingFiles>
<supportingFilesToGenerate>ApiUtil.java</supportingFilesToGenerate>
-->
<generateApis>true</generateApis>
<configOptions>
<!-- RestController implementation is provided by Petclinic developers -->
......@@ -312,6 +317,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<annotationProcessorPaths>
<path>
......
......@@ -16,6 +16,7 @@
package org.springframework.samples.petclinic.rest.controller;
import io.swagger.annotations.ApiParam;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
......@@ -32,6 +33,7 @@ import org.springframework.web.util.UriComponentsBuilder;
import javax.transaction.Transactional;
import javax.validation.Valid;
import javax.validation.constraints.Min;
import java.util.ArrayList;
import java.util.List;
......@@ -61,8 +63,8 @@ public class PetTypeRestController implements PettypesApi {
}
@PreAuthorize("hasAnyRole(@roles.OWNER_ADMIN, @roles.VET_ADMIN)")
@RequestMapping(value = "/pettypes/{petTypeId}", method = RequestMethod.GET, produces = "application/json")
public ResponseEntity<PetTypeDto> getPetType(@PathVariable("petTypeId") int petTypeId) {
@Override
public ResponseEntity<PetTypeDto> getPetType(@Min(0)@ApiParam(value = "The ID of the pet type.",required=true) @PathVariable("petTypeId") Integer petTypeId){
PetType petType = this.clinicService.findPetTypeById(petTypeId);
if (petType == null) {
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
......@@ -71,7 +73,7 @@ public class PetTypeRestController implements PettypesApi {
}
@PreAuthorize("hasRole(@roles.VET_ADMIN)")
@RequestMapping(value = "/pettypes", method = RequestMethod.POST, produces = "application/json")
@Override
public ResponseEntity<PetTypeDto> addPetType(@RequestBody @Valid PetTypeFieldsDto petTypeFields, BindingResult bindingResult, UriComponentsBuilder ucBuilder) {
BindingErrorsResponse errors = new BindingErrorsResponse();
HttpHeaders headers = new HttpHeaders();
......@@ -87,7 +89,6 @@ public class PetTypeRestController implements PettypesApi {
}
@PreAuthorize("hasRole(@roles.VET_ADMIN)")
@RequestMapping(value = "/pettypes/{petTypeId}", method = RequestMethod.PUT, produces = "application/json")
public ResponseEntity<PetTypeDto> updatePetType(@PathVariable("petTypeId") int petTypeId, @RequestBody @Valid PetTypeDto petType, BindingResult bindingResult) {
BindingErrorsResponse errors = new BindingErrorsResponse();
HttpHeaders headers = new HttpHeaders();
......
......@@ -543,7 +543,7 @@ paths:
summary: Get a pet type by ID
description: Returns the pet type or a 404 error.
parameters:
- name: petType
- name: petTypeId
in: path
description: The ID of the pet type.
required: true
......@@ -596,7 +596,7 @@ paths:
summary: Update a pet type by ID
description: Returns the pet type or a 404 error.
parameters:
- name: petType
- name: petTypeId
in: path
description: The ID of the pet type.
required: true
......@@ -656,7 +656,7 @@ paths:
summary: Delete a pet type by ID
description: Returns the pet type or a 404 error.
parameters:
- name: petType
- name: petTypeId
in: path
description: The ID of the pet type.
required: true
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment