Guest User

Untitled

a guest
Jun 3rd, 2022
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.39 KB | None | 0 0
  1. import org.springframework.http.ResponseEntity;
  2. import org.springframework.web.bind.annotation.PostMapping;
  3. import org.springframework.web.bind.annotation.RequestBody;
  4. import org.springframework.web.bind.annotation.RequestMapping;
  5. import org.springframework.web.bind.annotation.RestController;
  6.  
  7. import io.swagger.v3.oas.annotations.Operation;
  8. import io.swagger.v3.oas.annotations.media.Content;
  9. import io.swagger.v3.oas.annotations.media.ExampleObject;
  10.  
  11. @RestController
  12. @RequestMapping("/api/my/problem")
  13. public class MyProblemResource {
  14.  
  15.     @PostMapping(value = "/")
  16.     @Operation(summary = "Create person")
  17.     @io.swagger.v3.oas.annotations.parameters.RequestBody(
  18.             description = "the person you want to create, in json format",
  19.             content = @Content(examples = @ExampleObject( value = "foobar"))
  20.             )
  21.     public ResponseEntity<PersonDTO> getPerson(
  22.             @RequestBody PersonDTO person){
  23.         return ResponseEntity.ok().build();
  24.     }
  25. }
  26.  
  27. class PersonDTO{
  28.     String firstName;
  29.     String lastName;
  30.     public PersonDTO() {}
  31.     public String getFirstName() {
  32.         return firstName;
  33.     }
  34.     public void setFirstName(String firstName) {
  35.         this.firstName = firstName;
  36.     }
  37.     public String getLastName() {
  38.         return lastName;
  39.     }
  40.     public void setLastName(String lastName) {
  41.         this.lastName = lastName;
  42.     }
  43. }
Add Comment
Please, Sign In to add comment