Skip to content
Snippets Groups Projects
Commit 8af00411 authored by Laurine's avatar Laurine
Browse files

7-2 create post user & add swagger

parent cfaa8fb5
No related branches found
No related tags found
No related merge requests found
......@@ -31,6 +31,11 @@
<version>1.18.20</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
<version>2.1.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
......
......@@ -19,4 +19,9 @@ public class UserDao {
users.add(new User("Lara", "TATOUILLE", 24));
return users;
}
public List<User> addUser(List<User> users, User user) {
users.add(user);
return users;
}
}
package com.example.livecodingjavaspring;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.util.List;
......@@ -23,4 +20,10 @@ public class UserLibraryController {
return userDao.getUsers();
}
@PostMapping("")
public List<User> addUser(@RequestBody User user) {
List<User> users= userDao.getUsers();
return userDao.addUser(users, user);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment