mirror of
https://github.com/gotson/komga.git
synced 2026-05-09 05:10:19 +02:00
docs(openapi): expose 404 not found
This commit is contained in:
parent
43f4f6f8b2
commit
3a352534c0
5 changed files with 20 additions and 2 deletions
|
|
@ -1061,6 +1061,9 @@
|
|||
}
|
||||
},
|
||||
"description": "Bad Request"
|
||||
},
|
||||
"404": {
|
||||
"description": "Not Found"
|
||||
}
|
||||
},
|
||||
"summary": "Get book details",
|
||||
|
|
@ -6731,6 +6734,9 @@
|
|||
}
|
||||
},
|
||||
"description": "Bad Request"
|
||||
},
|
||||
"404": {
|
||||
"description": "Not Found"
|
||||
}
|
||||
},
|
||||
"summary": "Get series details",
|
||||
|
|
|
|||
|
|
@ -64,3 +64,5 @@ class EntryNotFoundException(
|
|||
class ConfigurationException(
|
||||
message: String,
|
||||
) : Exception(message)
|
||||
|
||||
class EntityNotFoundException : Exception()
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ import org.gotson.komga.application.tasks.TaskEmitter
|
|||
import org.gotson.komga.domain.model.BookSearch
|
||||
import org.gotson.komga.domain.model.Dimension
|
||||
import org.gotson.komga.domain.model.DomainEvent
|
||||
import org.gotson.komga.domain.model.EntityNotFoundException
|
||||
import org.gotson.komga.domain.model.ImageConversionException
|
||||
import org.gotson.komga.domain.model.MarkSelectedPreference
|
||||
import org.gotson.komga.domain.model.Media
|
||||
|
|
@ -273,6 +274,7 @@ class BookController(
|
|||
|
||||
@Operation(summary = "Get book details", tags = [OpenApiConfiguration.TagNames.BOOKS])
|
||||
@GetMapping("api/v1/books/{bookId}")
|
||||
@Throws(EntityNotFoundException::class)
|
||||
fun getBookById(
|
||||
@AuthenticationPrincipal principal: KomgaPrincipal,
|
||||
@PathVariable bookId: String,
|
||||
|
|
@ -281,7 +283,7 @@ class BookController(
|
|||
contentRestrictionChecker.checkContentRestriction(principal.user, it)
|
||||
|
||||
it.restrictUrl(!principal.user.isAdmin)
|
||||
} ?: throw ResponseStatusException(HttpStatus.NOT_FOUND)
|
||||
} ?: throw EntityNotFoundException()
|
||||
|
||||
@Operation(summary = "Get previous book in series", tags = [OpenApiConfiguration.TagNames.BOOKS])
|
||||
@GetMapping("api/v1/books/{bookId}/previous")
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package org.gotson.komga.interfaces.api.rest
|
||||
|
||||
import jakarta.validation.ConstraintViolationException
|
||||
import org.gotson.komga.domain.model.EntityNotFoundException
|
||||
import org.springframework.http.HttpStatus
|
||||
import org.springframework.web.bind.MethodArgumentNotValidException
|
||||
import org.springframework.web.bind.annotation.ControllerAdvice
|
||||
|
|
@ -29,6 +30,11 @@ class ErrorHandlingControllerAdvice {
|
|||
ValidationErrorResponse(
|
||||
e.bindingResult.fieldErrors.map { Violation(it.field, it.defaultMessage) },
|
||||
)
|
||||
|
||||
@ExceptionHandler(EntityNotFoundException::class)
|
||||
@ResponseStatus(HttpStatus.NOT_FOUND)
|
||||
fun handleEntityNotFound() {
|
||||
}
|
||||
}
|
||||
|
||||
data class ValidationErrorResponse(
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ import org.gotson.komga.domain.model.Author
|
|||
import org.gotson.komga.domain.model.BookSearch
|
||||
import org.gotson.komga.domain.model.Dimension
|
||||
import org.gotson.komga.domain.model.DomainEvent
|
||||
import org.gotson.komga.domain.model.EntityNotFoundException
|
||||
import org.gotson.komga.domain.model.KomgaUser
|
||||
import org.gotson.komga.domain.model.MarkSelectedPreference
|
||||
import org.gotson.komga.domain.model.Media
|
||||
|
|
@ -462,6 +463,7 @@ class SeriesController(
|
|||
|
||||
@Operation(summary = "Get series details", tags = [OpenApiConfiguration.TagNames.SERIES])
|
||||
@GetMapping("v1/series/{seriesId}")
|
||||
@Throws(EntityNotFoundException::class)
|
||||
fun getSeriesById(
|
||||
@AuthenticationPrincipal principal: KomgaPrincipal,
|
||||
@PathVariable(name = "seriesId") id: String,
|
||||
|
|
@ -469,7 +471,7 @@ class SeriesController(
|
|||
seriesDtoRepository.findByIdOrNull(id, principal.user.id)?.let {
|
||||
contentRestrictionChecker.checkContentRestriction(principal.user, it)
|
||||
it.restrictUrl(!principal.user.isAdmin)
|
||||
} ?: throw ResponseStatusException(HttpStatus.NOT_FOUND)
|
||||
} ?: throw EntityNotFoundException()
|
||||
|
||||
@Operation(summary = "Get series' poster image", tags = [OpenApiConfiguration.TagNames.SERIES_POSTER])
|
||||
@ApiResponse(content = [Content(schema = Schema(type = "string", format = "binary"))])
|
||||
|
|
|
|||
Loading…
Reference in a new issue