Add some more Swagger annotations

This commit is contained in:
Billy Brawner 2019-05-22 21:53:58 -07:00
parent e2a35ec249
commit b63874167a
6 changed files with 10 additions and 9 deletions

View file

@ -4,6 +4,7 @@ import com.wbrawner.budgetserver.getCurrentUser
import com.wbrawner.budgetserver.user.UserRepository
import io.swagger.annotations.Api
import io.swagger.annotations.ApiOperation
import io.swagger.annotations.Authorization
import org.hibernate.Hibernate
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.http.MediaType
@ -13,7 +14,7 @@ import javax.transaction.Transactional
@RestController
@RequestMapping("/accounts")
@Api(value = "Accounts", tags = ["Accounts"])
@Api(value = "Accounts", tags = ["Accounts"], authorizations = [Authorization("basic")])
class AccountController @Autowired constructor(private val accountRepository: AccountRepository, private val userRepository: UserRepository) {
@Transactional
@GetMapping("", produces = [MediaType.APPLICATION_JSON_VALUE])

View file

@ -6,19 +6,19 @@ import com.wbrawner.budgetserver.getCurrentUser
import com.wbrawner.budgetserver.transaction.TransactionRepository
import io.swagger.annotations.Api
import io.swagger.annotations.ApiOperation
import io.swagger.annotations.Authorization
import org.hibernate.Hibernate
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.data.domain.PageRequest
import org.springframework.http.MediaType
import org.springframework.http.ResponseEntity
import org.springframework.security.access.prepost.PreAuthorize
import org.springframework.web.bind.annotation.*
import java.lang.Integer.min
import javax.transaction.Transactional
@RestController
@RequestMapping("/categories")
@Api(value = "Categories", tags = ["Categories"])
@Api(value = "Categories", tags = ["Categories"], authorizations = [Authorization("basic")])
class CategoryController @Autowired constructor(
private val accountRepository: AccountRepository,
private val categoryRepository: CategoryRepository,

View file

@ -5,6 +5,7 @@ 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
@ -14,6 +15,7 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2
class SwaggerConfig : WebMvcConfigurationSupport() {
@Bean
fun budgetApi(): Docket = Docket(DocumentationType.SWAGGER_2)
.securitySchemes(mutableListOf(BasicAuth("basic")))
.select()
.apis(RequestHandlerSelectors.basePackage("com.wbrawner.budgetserver"))
.build()

View file

@ -7,22 +7,20 @@ import com.wbrawner.budgetserver.category.CategoryRepository
import com.wbrawner.budgetserver.getCurrentUser
import io.swagger.annotations.Api
import io.swagger.annotations.ApiOperation
import io.swagger.annotations.Authorization
import org.hibernate.Hibernate
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.data.domain.PageRequest
import org.springframework.http.MediaType
import org.springframework.http.ResponseEntity
import org.springframework.security.access.prepost.PreAuthorize
import org.springframework.web.bind.annotation.*
import java.lang.Integer.min
import java.lang.RuntimeException
import java.time.Instant
import java.util.*
import javax.transaction.Transactional
@RestController
@RequestMapping("/transactions")
@Api(value = "Transactions", tags = ["Transactions"])
@Api(value = "Transactions", tags = ["Transactions"], authorizations = [Authorization("basic")])
class TransactionController @Autowired constructor(
private val accountRepository: AccountRepository,
private val categoryRepository: CategoryRepository,

View file

@ -5,18 +5,18 @@ import com.wbrawner.budgetserver.account.AccountRepository
import com.wbrawner.budgetserver.getCurrentUser
import io.swagger.annotations.Api
import io.swagger.annotations.ApiOperation
import io.swagger.annotations.Authorization
import org.hibernate.Hibernate
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.http.MediaType
import org.springframework.http.ResponseEntity
import org.springframework.security.access.prepost.PreAuthorize
import org.springframework.security.crypto.password.PasswordEncoder
import org.springframework.web.bind.annotation.*
import javax.transaction.Transactional
@RestController
@RequestMapping("/users")
@Api(value = "Users", tags = ["Users"])
@Api(value = "Users", tags = ["Users"], authorizations = [Authorization("basic")])
class UserController @Autowired constructor(private val accountRepository: AccountRepository, private val userRepository: UserRepository, private val passwordEncoder: PasswordEncoder) {
@Transactional
@GetMapping("", produces = [MediaType.APPLICATION_JSON_VALUE])