Remove swagger
This commit is contained in:
parent
ddbc377093
commit
36ee1bccfa
7 changed files with 1 additions and 81 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -28,3 +28,4 @@ HELP.md
|
|||
### VS Code ###
|
||||
.vscode/
|
||||
.gradle
|
||||
*.sql
|
||||
|
|
|
@ -16,8 +16,6 @@ dependencies {
|
|||
implementation "org.springframework.boot:spring-boot-starter-security"
|
||||
implementation "org.springframework.session:spring-session-jdbc"
|
||||
implementation "org.springframework.boot:spring-boot-starter-web"
|
||||
implementation "io.springfox:springfox-swagger2:2.8.0"
|
||||
implementation "io.springfox:springfox-swagger-ui:2.8.0"
|
||||
runtimeOnly "mysql:mysql-connector-java:8.0.15"
|
||||
testImplementation "org.springframework.boot:spring-boot-starter-test"
|
||||
testImplementation "org.springframework.security:spring-security-test:5.1.5.RELEASE"
|
||||
|
|
|
@ -6,9 +6,6 @@ import com.wbrawner.budgetserver.permission.UserPermissionRepository;
|
|||
import com.wbrawner.budgetserver.transaction.TransactionRepository;
|
||||
import com.wbrawner.budgetserver.user.User;
|
||||
import com.wbrawner.budgetserver.user.UserRepository;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.Authorization;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
|
@ -28,7 +25,6 @@ import static com.wbrawner.budgetserver.Utils.getCurrentUser;
|
|||
|
||||
@RestController
|
||||
@RequestMapping(value = "/budgets")
|
||||
@Api(value = "Budgets", tags = {"Budgets"}, authorizations = {@Authorization(value = "basic")})
|
||||
@Transactional
|
||||
public class BudgetController {
|
||||
private final BudgetRepository budgetRepository;
|
||||
|
@ -50,7 +46,6 @@ public class BudgetController {
|
|||
}
|
||||
|
||||
@GetMapping(value = "", produces = {MediaType.APPLICATION_JSON_VALUE})
|
||||
@ApiOperation(value = "getBudgets", nickname = "getBudgets", tags = {"Budgets"})
|
||||
public ResponseEntity<List<BudgetResponse>> getBudgets(Integer page, Integer count) {
|
||||
User user = getCurrentUser();
|
||||
if (user == null) {
|
||||
|
@ -79,7 +74,6 @@ public class BudgetController {
|
|||
}
|
||||
|
||||
@GetMapping(value = "/{id}", produces = {MediaType.APPLICATION_JSON_VALUE})
|
||||
@ApiOperation(value = "getBudget", nickname = "getBudget", tags = {"Budgets"})
|
||||
public ResponseEntity<BudgetResponse> getBudget(@PathVariable String id) {
|
||||
return getBudgetWithPermission(id, Permission.READ, (budget) ->
|
||||
ResponseEntity.ok(new BudgetResponse(budget, userPermissionsRepository.findAllByBudget(budget, null)))
|
||||
|
@ -87,7 +81,6 @@ public class BudgetController {
|
|||
}
|
||||
|
||||
@GetMapping(value = "/{id}/balance", produces = {MediaType.APPLICATION_JSON_VALUE})
|
||||
@ApiOperation(value = "getBudgetBalance", nickname = "getBudgetBalance", tags = {"Budgets"})
|
||||
public ResponseEntity<BudgetBalanceResponse> getBudgetBalance(
|
||||
@PathVariable String id,
|
||||
@RequestParam(value = "from", required = false) String from,
|
||||
|
@ -116,7 +109,6 @@ public class BudgetController {
|
|||
}
|
||||
|
||||
@PostMapping(value = "", consumes = {MediaType.APPLICATION_JSON_VALUE}, produces = {MediaType.APPLICATION_JSON_VALUE})
|
||||
@ApiOperation(value = "newBudget", nickname = "newBudget", tags = {"Budgets"})
|
||||
public ResponseEntity<BudgetResponse> newBudget(@RequestBody BudgetRequest request) {
|
||||
final var budget = budgetRepository.save(new Budget(request.name, request.description));
|
||||
var users = request.getUsers()
|
||||
|
@ -147,7 +139,6 @@ public class BudgetController {
|
|||
}
|
||||
|
||||
@PutMapping(value = "/{id}", consumes = {MediaType.APPLICATION_JSON_VALUE}, produces = {MediaType.APPLICATION_JSON_VALUE})
|
||||
@ApiOperation(value = "updateBudget", nickname = "updateBudget", tags = {"Budgets"})
|
||||
public ResponseEntity<BudgetResponse> updateBudget(@PathVariable String id, @RequestBody BudgetRequest request) {
|
||||
return getBudgetWithPermission(id, Permission.MANAGE, (budget) -> {
|
||||
if (request.name != null) {
|
||||
|
@ -179,7 +170,6 @@ public class BudgetController {
|
|||
}
|
||||
|
||||
@DeleteMapping(value = "/{id}", produces = {MediaType.TEXT_PLAIN_VALUE})
|
||||
@ApiOperation(value = "deleteBudget", nickname = "deleteBudget", tags = {"Budgets"})
|
||||
public ResponseEntity<Void> deleteBudget(@PathVariable String id) {
|
||||
return getBudgetWithPermission(id, Permission.MANAGE, (budget) -> {
|
||||
budgetRepository.delete(budget);
|
||||
|
|
|
@ -5,12 +5,6 @@ import com.wbrawner.budgetserver.permission.Permission;
|
|||
import com.wbrawner.budgetserver.permission.UserPermission;
|
||||
import com.wbrawner.budgetserver.permission.UserPermissionRepository;
|
||||
import com.wbrawner.budgetserver.transaction.TransactionRepository;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.Authorization;
|
||||
|
||||
import org.springframework.data.domain.Example;
|
||||
import org.springframework.data.domain.ExampleMatcher;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.http.HttpStatus;
|
||||
|
@ -27,7 +21,6 @@ import static com.wbrawner.budgetserver.Utils.getFirstOfMonth;
|
|||
|
||||
@RestController
|
||||
@RequestMapping(path = "/categories")
|
||||
@Api(value = "Categories", tags = {"Categories"}, authorizations = {@Authorization("basic")})
|
||||
@Transactional
|
||||
class CategoryController {
|
||||
private final CategoryRepository categoryRepository;
|
||||
|
@ -43,7 +36,6 @@ class CategoryController {
|
|||
}
|
||||
|
||||
@GetMapping(path = "", produces = {MediaType.APPLICATION_JSON_VALUE})
|
||||
@ApiOperation(value = "getCategories", nickname = "getCategories", tags = {"Categories"})
|
||||
ResponseEntity<List<CategoryResponse>> getCategories(
|
||||
@RequestParam(name = "budgetIds", required = false) List<String> budgetIds,
|
||||
@RequestParam(name = "isExpense", required = false) Boolean isExpense,
|
||||
|
@ -83,7 +75,6 @@ class CategoryController {
|
|||
}
|
||||
|
||||
@GetMapping(path = "/{id}", produces = {MediaType.APPLICATION_JSON_VALUE})
|
||||
@ApiOperation(value = "getCategory", nickname = "getCategory", tags = {"Categories"})
|
||||
ResponseEntity<CategoryResponse> getCategory(@PathVariable String id) {
|
||||
var budgets = userPermissionsRepository.findAllByUser(getCurrentUser(), null)
|
||||
.stream()
|
||||
|
@ -95,7 +86,6 @@ class CategoryController {
|
|||
}
|
||||
|
||||
@GetMapping(path = "/{id}/balance", produces = {MediaType.APPLICATION_JSON_VALUE})
|
||||
@ApiOperation(value = "getCategoryBalance", nickname = "getCategoryBalance", tags = {"Categories"})
|
||||
ResponseEntity<CategoryBalanceResponse> getCategoryBalance(@PathVariable String id) {
|
||||
var budgets = userPermissionsRepository.findAllByUser(getCurrentUser(), null)
|
||||
.stream()
|
||||
|
@ -110,7 +100,6 @@ class CategoryController {
|
|||
}
|
||||
|
||||
@PostMapping(path = "", consumes = {MediaType.APPLICATION_JSON_VALUE}, produces = {MediaType.APPLICATION_JSON_VALUE})
|
||||
@ApiOperation(value = "newCategory", nickname = "newCategory", tags = {"Categories"})
|
||||
ResponseEntity<Object> newCategory(@RequestBody NewCategoryRequest request) {
|
||||
var userResponse = userPermissionsRepository.findByUserAndBudget_Id(getCurrentUser(), request.getBudgetId())
|
||||
.orElse(null);
|
||||
|
@ -131,7 +120,6 @@ class CategoryController {
|
|||
}
|
||||
|
||||
@PutMapping(path = "/{id}", consumes = {MediaType.APPLICATION_JSON_VALUE}, produces = {MediaType.APPLICATION_JSON_VALUE})
|
||||
@ApiOperation(value = "updateCategory", nickname = "updateCategory", tags = {"Categories"})
|
||||
ResponseEntity<CategoryResponse> updateCategory(@PathVariable String id, @RequestBody UpdateCategoryRequest request) {
|
||||
var category = categoryRepository.findById(id).orElse(null);
|
||||
if (category == null) return ResponseEntity.notFound().build();
|
||||
|
@ -159,7 +147,6 @@ class CategoryController {
|
|||
}
|
||||
|
||||
@DeleteMapping(path = "/{id}", produces = {MediaType.TEXT_PLAIN_VALUE})
|
||||
@ApiOperation(value = "deleteCategory", nickname = "deleteCategory", tags = {"Categories"})
|
||||
ResponseEntity<Void> deleteCategory(@PathVariable String id) {
|
||||
var category = categoryRepository.findById(id).orElse(null);
|
||||
if (category == null) return ResponseEntity.notFound().build();
|
||||
|
|
|
@ -1,35 +0,0 @@
|
|||
package com.wbrawner.budgetserver.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
|
||||
import springfox.documentation.builders.RequestHandlerSelectors;
|
||||
import springfox.documentation.service.BasicAuth;
|
||||
import springfox.documentation.spi.DocumentationType;
|
||||
import springfox.documentation.spring.web.plugins.Docket;
|
||||
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
@Configuration
|
||||
@EnableSwagger2
|
||||
class SwaggerConfig extends WebMvcConfigurationSupport {
|
||||
@Bean
|
||||
Docket budgetApi() {
|
||||
return new Docket(DocumentationType.SWAGGER_2)
|
||||
.securitySchemes(Collections.singletonList(new BasicAuth("basic")))
|
||||
.select()
|
||||
.apis(RequestHandlerSelectors.basePackage("com.wbrawner.budgetserver"))
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||
registry.addResourceHandler("swagger-ui.html")
|
||||
.addResourceLocations("classpath:/META-INF/resources/");
|
||||
|
||||
registry.addResourceHandler("/webjars/**")
|
||||
.addResourceLocations("classpath:/META-INF/resources/webjars/");
|
||||
}
|
||||
}
|
|
@ -6,9 +6,6 @@ import com.wbrawner.budgetserver.category.CategoryRepository;
|
|||
import com.wbrawner.budgetserver.permission.Permission;
|
||||
import com.wbrawner.budgetserver.permission.UserPermission;
|
||||
import com.wbrawner.budgetserver.permission.UserPermissionRepository;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.Authorization;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
|
@ -27,7 +24,6 @@ import static com.wbrawner.budgetserver.Utils.*;
|
|||
|
||||
@RestController
|
||||
@RequestMapping(path = "/transactions")
|
||||
@Api(value = "Transactions", tags = {"Transactions"}, authorizations = {@Authorization("basic")})
|
||||
@Transactional
|
||||
public class TransactionController {
|
||||
private final CategoryRepository categoryRepository;
|
||||
|
@ -45,7 +41,6 @@ public class TransactionController {
|
|||
}
|
||||
|
||||
@GetMapping(path = "", produces = {MediaType.APPLICATION_JSON_VALUE})
|
||||
@ApiOperation(value = "getTransactions", nickname = "getTransactions", tags = {"Transactions"})
|
||||
public ResponseEntity<List<TransactionResponse>> getTransactions(
|
||||
@RequestParam(value = "categoryIds", required = false) List<String> categoryIds,
|
||||
@RequestParam(value = "budgetIds", required = false) List<String> budgetIds,
|
||||
|
@ -116,7 +111,6 @@ public class TransactionController {
|
|||
}
|
||||
|
||||
@GetMapping(path = "/{id}", produces = {MediaType.APPLICATION_JSON_VALUE})
|
||||
@ApiOperation(value = "getTransaction", nickname = "getTransaction", tags = {"Transactions"})
|
||||
public ResponseEntity<TransactionResponse> getTransaction(@PathVariable String id) {
|
||||
var budgets = userPermissionsRepository.findAllByUser(getCurrentUser(), null)
|
||||
.stream()
|
||||
|
@ -128,7 +122,6 @@ public class TransactionController {
|
|||
}
|
||||
|
||||
@PostMapping(path = "", consumes = {MediaType.APPLICATION_JSON_VALUE}, produces = {MediaType.APPLICATION_JSON_VALUE})
|
||||
@ApiOperation(value = "newTransaction", nickname = "newTransaction", tags = {"Transactions"})
|
||||
public ResponseEntity<Object> newTransaction(@RequestBody NewTransactionRequest request) {
|
||||
var userResponse = userPermissionsRepository.findByUserAndBudget_Id(getCurrentUser(), request.getBudgetId())
|
||||
.orElse(null);
|
||||
|
@ -156,7 +149,6 @@ public class TransactionController {
|
|||
}
|
||||
|
||||
@PutMapping(path = "/{id}", consumes = {MediaType.APPLICATION_JSON_VALUE}, produces = {MediaType.APPLICATION_JSON_VALUE})
|
||||
@ApiOperation(value = "updateTransaction", nickname = "updateTransaction", tags = {"Transactions"})
|
||||
public ResponseEntity<Object> updateTransaction(@PathVariable String id, @RequestBody UpdateTransactionRequest request) {
|
||||
var transaction = transactionRepository.findById(id).orElse(null);
|
||||
if (transaction == null) return ResponseEntity.notFound().build();
|
||||
|
@ -202,7 +194,6 @@ public class TransactionController {
|
|||
}
|
||||
|
||||
@DeleteMapping(path = "/{id}", produces = {MediaType.TEXT_PLAIN_VALUE})
|
||||
@ApiOperation(value = "deleteTransaction", nickname = "deleteTransaction", tags = {"Transactions"})
|
||||
public ResponseEntity<Void> deleteTransaction(@PathVariable String id) {
|
||||
var transaction = transactionRepository.findById(id).orElse(null);
|
||||
if (transaction == null) return ResponseEntity.notFound().build();
|
||||
|
|
|
@ -7,9 +7,6 @@ import com.wbrawner.budgetserver.permission.UserPermissionResponse;
|
|||
import com.wbrawner.budgetserver.session.Session;
|
||||
import com.wbrawner.budgetserver.session.SessionResponse;
|
||||
import com.wbrawner.budgetserver.session.UserSessionRepository;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.Authorization;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
@ -30,7 +27,6 @@ import static com.wbrawner.budgetserver.Utils.getCurrentUser;
|
|||
|
||||
@RestController
|
||||
@RequestMapping("/users")
|
||||
@Api(value = "Users", tags = {"Users"}, authorizations = {@Authorization("basic")})
|
||||
@Transactional
|
||||
public class UserController {
|
||||
private final BudgetRepository budgetRepository;
|
||||
|
@ -57,7 +53,6 @@ public class UserController {
|
|||
|
||||
|
||||
@GetMapping(path = "", produces = {MediaType.APPLICATION_JSON_VALUE})
|
||||
@ApiOperation(value = "getUsers", nickname = "getUsers", tags = {"Users"})
|
||||
ResponseEntity<List<UserPermissionResponse>> getUsers(String budgetId) {
|
||||
var budget = budgetRepository.findById(budgetId).orElse(null);
|
||||
if (budget == null) {
|
||||
|
@ -75,7 +70,6 @@ public class UserController {
|
|||
}
|
||||
|
||||
@PostMapping(path = "/login", produces = {MediaType.APPLICATION_JSON_VALUE})
|
||||
@ApiOperation(value = "login", nickname = "login", tags = {"Users"})
|
||||
ResponseEntity<SessionResponse> login(@RequestBody LoginRequest request) {
|
||||
var authReq = new UsernamePasswordAuthenticationToken(request.getUsername(), request.getPassword());
|
||||
Authentication auth;
|
||||
|
@ -91,7 +85,6 @@ public class UserController {
|
|||
}
|
||||
|
||||
@GetMapping(path = "/me", produces = {MediaType.APPLICATION_JSON_VALUE})
|
||||
@ApiOperation(value = "getProfile", nickname = "getProfile", tags = {"Users"})
|
||||
ResponseEntity<UserResponse> getProfile() {
|
||||
var user = getCurrentUser();
|
||||
if (user == null) return ResponseEntity.status(401).build();
|
||||
|
@ -99,7 +92,6 @@ public class UserController {
|
|||
}
|
||||
|
||||
@GetMapping(path = "/search", produces = {MediaType.APPLICATION_JSON_VALUE})
|
||||
@ApiOperation(value = "searchUsers", nickname = "searchUsers", tags = {"Users"})
|
||||
ResponseEntity<List<UserResponse>> searchUsers(String query) {
|
||||
return ResponseEntity.ok(
|
||||
userRepository.findByUsernameContains(query)
|
||||
|
@ -110,7 +102,6 @@ public class UserController {
|
|||
}
|
||||
|
||||
@GetMapping(path = "/{id}")
|
||||
@ApiOperation(value = "getUser", nickname = "getUser", tags = {"Users"})
|
||||
ResponseEntity<UserResponse> getUser(@PathVariable String id) {
|
||||
var user = userRepository.findById(id).orElse(null);
|
||||
if (user == null) {
|
||||
|
@ -120,7 +111,6 @@ public class UserController {
|
|||
}
|
||||
|
||||
@PostMapping(path = "", consumes = {MediaType.APPLICATION_JSON_VALUE}, produces = {MediaType.APPLICATION_JSON_VALUE})
|
||||
@ApiOperation(value = "newUser", nickname = "newUser", tags = {"Users"})
|
||||
ResponseEntity<Object> newUser(@RequestBody NewUserRequest request) {
|
||||
if (userRepository.findByUsername(request.getUsername()).isPresent())
|
||||
return ResponseEntity.badRequest().body(new ErrorResponse("Username taken"));
|
||||
|
@ -136,7 +126,6 @@ public class UserController {
|
|||
}
|
||||
|
||||
@PutMapping(path = "/{id}", consumes = {MediaType.APPLICATION_JSON_VALUE}, produces = {MediaType.APPLICATION_JSON_VALUE})
|
||||
@ApiOperation(value = "updateUser", nickname = "updateUser", tags = {"Users"})
|
||||
ResponseEntity<Object> updateUser(@PathVariable Long id, @RequestBody UpdateUserRequest request) {
|
||||
if (!getCurrentUser().getId().equals(id)) return ResponseEntity.status(403).build();
|
||||
var user = userRepository.findById(getCurrentUser().getId()).orElse(null);
|
||||
|
@ -160,7 +149,6 @@ public class UserController {
|
|||
}
|
||||
|
||||
@DeleteMapping(path = "/{id}", produces = {MediaType.TEXT_PLAIN_VALUE})
|
||||
@ApiOperation(value = "deleteUser", nickname = "deleteUser", tags = {"Users"})
|
||||
ResponseEntity<Void> deleteUser(@PathVariable String id) {
|
||||
if (!getCurrentUser().getId().equals(id)) return ResponseEntity.status(403).build();
|
||||
userRepository.deleteById(id);
|
||||
|
|
Loading…
Reference in a new issue