Compare commits

...

2 Commits

Author SHA1 Message Date
semantic-release-bot
6c8153ba98 chore: Release v1.5.0-dev.1 [skip ci]
# [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](e871b23210))
2024-11-06 04:32:10 +00:00
oSumAtrIX
e871b23210 feat: Move spec url to versioned path 2024-11-06 05:30:09 +01:00
5 changed files with 26 additions and 8 deletions

View File

@@ -1,3 +1,10 @@
# [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)

View File

@@ -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.1

View File

@@ -11,7 +11,7 @@ import org.koin.ktor.ext.get
import kotlin.time.Duration.Companion.minutes
fun Application.configureHTTP() {
val configurationRepository = get<ConfigurationRepository>()
val configuration = get<ConfigurationRepository>()
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"))
}
}

View File

@@ -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<ConfigurationRepository>()
val configuration = koinGet<ConfigurationRepository>()
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",
)
}

View File

@@ -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)
}