diff options
Diffstat (limited to 'server/core/src')
-rw-r--r-- | server/core/src/main/kotlin/moe/nea/ledger/server/core/Application.kt | 19 | ||||
-rw-r--r-- | server/core/src/main/kotlin/moe/nea/ledger/server/core/api/BaseApi.kt | 5 |
2 files changed, 22 insertions, 2 deletions
diff --git a/server/core/src/main/kotlin/moe/nea/ledger/server/core/Application.kt b/server/core/src/main/kotlin/moe/nea/ledger/server/core/Application.kt index 0ea6ed3..f00f26d 100644 --- a/server/core/src/main/kotlin/moe/nea/ledger/server/core/Application.kt +++ b/server/core/src/main/kotlin/moe/nea/ledger/server/core/Application.kt @@ -8,8 +8,12 @@ import io.ktor.server.plugins.compression.Compression import io.ktor.server.plugins.contentnegotiation.ContentNegotiation import io.ktor.server.routing.route import io.ktor.server.routing.routing +import kotlinx.serialization.json.Json import moe.nea.ledger.database.Database +import moe.nea.ledger.server.core.api.Documentation +import moe.nea.ledger.server.core.api.Info import moe.nea.ledger.server.core.api.apiRouting +import moe.nea.ledger.server.core.api.openApiDocsJson import java.io.File fun main(args: Array<String>) { @@ -19,8 +23,18 @@ fun main(args: Array<String>) { fun Application.module() { install(Compression) + install(Documentation) { + info = Info( + "Ledger Analysis Server", + "Your local API for loading ledger data", + "TODO: buildconfig" + ) + } install(ContentNegotiation) { - json() + json(Json { + this.explicitNulls = false + this.encodeDefaults = true + }) // cbor() } val database = Database(File(System.getProperty("ledger.databasefolder"))) @@ -29,6 +43,9 @@ fun Application.module() { route("/api") { this.apiRouting(database) } + route("/api.json") { + openApiDocsJson() + } } } diff --git a/server/core/src/main/kotlin/moe/nea/ledger/server/core/api/BaseApi.kt b/server/core/src/main/kotlin/moe/nea/ledger/server/core/api/BaseApi.kt index 264f74b..ad05118 100644 --- a/server/core/src/main/kotlin/moe/nea/ledger/server/core/api/BaseApi.kt +++ b/server/core/src/main/kotlin/moe/nea/ledger/server/core/api/BaseApi.kt @@ -3,7 +3,6 @@ package moe.nea.ledger.server.core.api import io.ktor.server.response.respond import io.ktor.server.response.respondText import io.ktor.server.routing.Route -import io.ktor.server.routing.Routing import io.ktor.server.routing.get import moe.nea.ledger.database.DBLogEntry import moe.nea.ledger.database.Database @@ -21,5 +20,9 @@ fun Route.apiRouting(database: Database) { Profile(it[DBLogEntry.playerId], it[DBLogEntry.profileId]) } call.respond(profiles) + }.docs { + respondsOk { + schema<List<Profile>>() + } } } |