-
Notifications
You must be signed in to change notification settings - Fork 896
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
Update OpenAPI Spec #84
Update OpenAPI Spec #84
Conversation
The build has failed |
I saw that. I will fix that tomorrow |
Hi, When I put this parameter in the maven plugin configuration: <generateApis>true</generateApis> I have the template of the APIs generated in the The generated interfaces provide the default methods which should be implemented in the source code . @javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen", date = "2022-02-02T18:56:32.827+01:00[Europe/Paris]")
@Validated
@Api(value = "pettypes", description = "the pettypes API")
public interface PettypesApi {
default Optional<NativeWebRequest> getRequest() {
return Optional.empty();
}
@ApiOperation(value = "Create a pet type", nickname = "addPetType", notes = "Creates a pet type .", response = PetTypeDto.class, tags={ "pettypes", })
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Pet type created successfully.", response = PetTypeDto.class),
@ApiResponse(code = 304, message = "Not modified."),
@ApiResponse(code = 400, message = "Bad request.", response = RestErrorDto.class),
@ApiResponse(code = 404, message = "Owner not found.", response = RestErrorDto.class),
@ApiResponse(code = 500, message = "Server error.", response = RestErrorDto.class) })
@RequestMapping(
method = RequestMethod.POST,
value = "/pettypes",
produces = { "application/json" },
consumes = { "application/json" }
)
default ResponseEntity<PetTypeDto> addPetType(@ApiParam(value = "The pet type" ,required=true ) @Valid @RequestBody PetTypeDto petTypeDto) {
getRequest().ifPresent(request -> {
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
String exampleString = "null";
ApiUtil.setExampleResponse(request, "application/json", exampleString);
break;
}
}
});
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
} Unfortunately, in the current code, all the posts methods in the implemented controllers (e.g., PetTypesController) inject both the BindingResult and the UriComponentBuilder instances For instance: @PreAuthorize("hasRole(@roles.VET_ADMIN)")
@RequestMapping(value = "", method = RequestMethod.POST, produces = "application/json")
public ResponseEntity<SpecialtyDto> addSpecialty(@RequestBody @Valid SpecialtyDto specialtyDto, BindingResult bindingResult, UriComponentsBuilder ucBuilder)
❓ Tell me your opinion about this concern. Regards |
I see the problem. I prefer the 2nd solution. We could use the I'm not sure that the
|
Hi, I can :
What do you think about that ? |
Sure, great idea, the |
… into ExceptionControllerAdvice method
… api configuration
Hi @arey Regards |
src/main/java/org/springframework/samples/petclinic/rest/advice/ExceptionControllerAdvice.java
Show resolved
Hide resolved
src/main/java/org/springframework/samples/petclinic/rest/controller/OwnerRestController.java
Outdated
Show resolved
Hide resolved
...est/java/org/springframework/samples/petclinic/rest/controller/OwnerRestControllerTests.java
Show resolved
Hide resolved
Hi, |
Thanks a lot @alexandre-touret |
You're welcome ;-) |
…ot/npm_and_yarn/follow-redirects-1.14.7 Bump follow-redirects from 1.14.0 to 1.14.7
fix #69