Docs improvements (#359)

* Use Array since Javalin OpenAPI requires it to read the list generics

* Use custom Pager class for documentation
This commit is contained in:
Mitchell Syer
2022-05-21 06:12:10 -04:00
committed by GitHub
parent a6d012abd9
commit 5b0426a94c
6 changed files with 17 additions and 11 deletions

View File

@@ -30,7 +30,7 @@ object CategoryController {
ctx.json(Category.getCategoryList())
},
withResults = {
json<List<CategoryDataClass>>(HttpCode.OK)
json<Array<CategoryDataClass>>(HttpCode.OK)
}
)
@@ -107,7 +107,7 @@ object CategoryController {
ctx.json(CategoryManga.getCategoryMangaList(categoryId))
},
withResults = {
json<List<MangaDataClass>>(HttpCode.OK)
json<Array<MangaDataClass>>(HttpCode.OK)
}
)

View File

@@ -37,7 +37,7 @@ object ExtensionController {
)
},
withResults = {
json<List<ExtensionDataClass>>(HttpCode.OK)
json<Array<ExtensionDataClass>>(HttpCode.OK)
}
)

View File

@@ -128,7 +128,7 @@ object MangaController {
ctx.json(CategoryManga.getMangaCategories(mangaId))
},
withResults = {
json<List<CategoryDataClass>>(HttpCode.OK)
json<Array<CategoryDataClass>>(HttpCode.OK)
}
)
@@ -205,7 +205,7 @@ object MangaController {
ctx.future(future { Chapter.getChapterList(mangaId, onlineFetch) })
},
withResults = {
json<List<ChapterDataClass>>(HttpCode.OK)
json<Array<ChapterDataClass>>(HttpCode.OK)
httpCode(HttpCode.NOT_FOUND)
}
)

View File

@@ -39,7 +39,7 @@ object SourceController {
ctx.json(Source.getSourceList())
},
withResults = {
json<List<SourceDataClass>>(HttpCode.OK)
json<Array<SourceDataClass>>(HttpCode.OK)
}
)
@@ -118,7 +118,7 @@ object SourceController {
ctx.json(Source.getSourcePreferences(sourceId))
},
withResults = {
json<List<Source.PreferenceObject>>(HttpCode.OK)
json<Array<Source.PreferenceObject>>(HttpCode.OK)
}
)
@@ -154,7 +154,7 @@ object SourceController {
ctx.json(Search.getFilterList(sourceId, reset))
},
withResults = {
json<List<Search.FilterObject>>(HttpCode.OK)
json<Array<Search.FilterObject>>(HttpCode.OK)
}
)

View File

@@ -14,7 +14,7 @@ import suwayomi.tachidesk.manga.impl.update.IUpdater
import suwayomi.tachidesk.manga.impl.update.UpdateStatus
import suwayomi.tachidesk.manga.impl.update.UpdaterSocket
import suwayomi.tachidesk.manga.model.dataclass.CategoryDataClass
import suwayomi.tachidesk.manga.model.dataclass.MangaDataClass
import suwayomi.tachidesk.manga.model.dataclass.MangaChapterDataClass
import suwayomi.tachidesk.manga.model.dataclass.PaginatedList
import suwayomi.tachidesk.server.JavalinSetup.future
import suwayomi.tachidesk.server.util.formParam
@@ -49,10 +49,16 @@ object UpdateController {
)
},
withResults = {
json<PaginatedList<MangaDataClass>>(HttpCode.OK)
json<PagedMangaChapterListDataClass>(HttpCode.OK)
}
)
/**
* Class made for handling return type in the documentation for [recentChapters],
* since OpenApi cannot handle runtime generics.
*/
private class PagedMangaChapterListDataClass : PaginatedList<MangaChapterDataClass>(emptyList(), false)
val categoryUpdate = handler(
formParam<Int?>("categoryId"),
documentWith = {

View File

@@ -9,7 +9,7 @@ package suwayomi.tachidesk.manga.model.dataclass
import kotlin.math.min
data class PaginatedList<T>(
open class PaginatedList<T>(
val page: List<T>,
val hasNextPage: Boolean,
)