diff --git a/CHANGELOG.md b/CHANGELOG.md index 79aec4e..10cffff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,26 @@ +# [1.5.0-dev.2](https://github.com/ReVanced/revanced-api/compare/v1.5.0-dev.1...v1.5.0-dev.2) (2024-11-06) + + +### Features + +* Allow updating `createdAt` field for announcements ([58ba4cb](https://github.com/ReVanced/revanced-api/commit/58ba4cb11c789507826cd70ac548943a94da4223)) +* Simplify log pattern ([d5d9e04](https://github.com/ReVanced/revanced-api/commit/d5d9e04325fa93540be0438e7b51243e2aeeab3d)) + +# [1.5.0-dev.1](https://github.com/ReVanced/revanced-api/compare/v1.4.0...v1.5.0-dev.1) (2024-11-06) + + +### Features + +* Move spec url to versioned path ([e871b23](https://github.com/ReVanced/revanced-api/commit/e871b23210798723c34bce93c7567d8fbcf4e060)) +* Simplify log pattern ([d5d9e04](https://github.com/ReVanced/revanced-api/commit/d5d9e04325fa93540be0438e7b51243e2aeeab3d)) + +# [1.5.0-dev.1](https://github.com/ReVanced/revanced-api/compare/v1.4.0...v1.5.0-dev.1) (2024-11-06) + + +### Features + +* Move spec url to versioned path ([e871b23](https://github.com/ReVanced/revanced-api/commit/e871b23210798723c34bce93c7567d8fbcf4e060)) + # [1.4.0](https://github.com/ReVanced/revanced-api/compare/v1.3.0...v1.4.0) (2024-11-06) diff --git a/gradle.properties b/gradle.properties index 70d1281..67fc117 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ org.gradle.parallel = true org.gradle.caching = true kotlin.code.style = official -version = 1.4.0 +version = 1.5.0-dev.2 diff --git a/src/main/kotlin/app/revanced/api/configuration/APISchema.kt b/src/main/kotlin/app/revanced/api/configuration/APISchema.kt index c4432ae..2fa588a 100644 --- a/src/main/kotlin/app/revanced/api/configuration/APISchema.kt +++ b/src/main/kotlin/app/revanced/api/configuration/APISchema.kt @@ -63,6 +63,7 @@ class ApiAnnouncement( val attachments: List = emptyList(), // Using a list instead of a set because set semantics are unnecessary here. val tags: List = emptyList(), + val createdAt: LocalDateTime, val archivedAt: LocalDateTime? = null, val level: Int = 0, ) diff --git a/src/main/kotlin/app/revanced/api/configuration/HTTP.kt b/src/main/kotlin/app/revanced/api/configuration/HTTP.kt index 523ea8e..27b3bbf 100644 --- a/src/main/kotlin/app/revanced/api/configuration/HTTP.kt +++ b/src/main/kotlin/app/revanced/api/configuration/HTTP.kt @@ -11,7 +11,7 @@ import org.koin.ktor.ext.get import kotlin.time.Duration.Companion.minutes fun Application.configureHTTP() { - val configurationRepository = get() + val configuration = get() install(CORS) { HttpMethod.DefaultMethods.minus(HttpMethod.Options).forEach(::allowMethod) @@ -22,7 +22,7 @@ fun Application.configureHTTP() { allowCredentials = true - configurationRepository.corsAllowedHosts.forEach { host -> + configuration.corsAllowedHosts.forEach { host -> allowHost(host = host, schemes = listOf("https")) } } diff --git a/src/main/kotlin/app/revanced/api/configuration/OpenAPI.kt b/src/main/kotlin/app/revanced/api/configuration/OpenAPI.kt index 3c90321..7aacc49 100644 --- a/src/main/kotlin/app/revanced/api/configuration/OpenAPI.kt +++ b/src/main/kotlin/app/revanced/api/configuration/OpenAPI.kt @@ -2,6 +2,7 @@ package app.revanced.api.configuration import app.revanced.api.command.applicationVersion import app.revanced.api.configuration.repository.ConfigurationRepository +import io.bkbn.kompendium.core.attribute.KompendiumAttributes import io.bkbn.kompendium.core.plugin.NotarizedApplication import io.bkbn.kompendium.json.schema.KotlinXSchemaConfigurator import io.bkbn.kompendium.oas.OpenApiSpec @@ -12,13 +13,22 @@ import io.bkbn.kompendium.oas.info.License import io.bkbn.kompendium.oas.security.BearerAuth import io.bkbn.kompendium.oas.server.Server import io.ktor.server.application.* -import org.koin.ktor.ext.get +import io.ktor.server.response.* +import io.ktor.server.routing.* import java.net.URI +import org.koin.ktor.ext.get as koinGet internal fun Application.configureOpenAPI() { - val configurationRepository = get() + val configuration = koinGet() install(NotarizedApplication()) { + openApiJson = { + route("/${configuration.apiVersion}/openapi.json") { + get { + call.respond(application.attributes[KompendiumAttributes.openApiSpec]) + } + } + } spec = OpenApiSpec( info = Info( title = "ReVanced API", @@ -41,7 +51,7 @@ internal fun Application.configureOpenAPI() { ), ).apply { servers += Server( - url = URI(configurationRepository.endpoint), + url = URI(configuration.endpoint), description = "ReVanced API server", ) } diff --git a/src/main/kotlin/app/revanced/api/configuration/Routing.kt b/src/main/kotlin/app/revanced/api/configuration/Routing.kt index da1af7c..0b61529 100644 --- a/src/main/kotlin/app/revanced/api/configuration/Routing.kt +++ b/src/main/kotlin/app/revanced/api/configuration/Routing.kt @@ -52,6 +52,7 @@ internal fun Application.configureRouting() = routing { extensions("json", "asc") } - swagger(pageTitle = "ReVanced API", path = "/") - redoc(pageTitle = "ReVanced API", path = "/redoc") + val specUrl = "/${configuration.apiVersion}/openapi.json" + swagger(pageTitle = "ReVanced API", path = "/", specUrl = specUrl) + redoc(pageTitle = "ReVanced API", path = "/redoc", specUrl = specUrl) } diff --git a/src/main/kotlin/app/revanced/api/configuration/repository/AnnouncementRepository.kt b/src/main/kotlin/app/revanced/api/configuration/repository/AnnouncementRepository.kt index 01d74e2..6acfa29 100644 --- a/src/main/kotlin/app/revanced/api/configuration/repository/AnnouncementRepository.kt +++ b/src/main/kotlin/app/revanced/api/configuration/repository/AnnouncementRepository.kt @@ -120,6 +120,7 @@ internal class AnnouncementRepository(private val database: Database) { it.author = new.author it.title = new.title it.content = new.content + it.createdAt = new.createdAt it.archivedAt = new.archivedAt it.level = new.level diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml index 2d304de..02a4423 100644 --- a/src/main/resources/logback.xml +++ b/src/main/resources/logback.xml @@ -1,7 +1,7 @@ - %d{YYYY-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + %d{YYYY-MM-dd HH:mm:ss.SSS} %-5level %msg%n