mirror of
https://github.com/revanced/revanced-api.git
synced 2025-04-29 22:24:31 +02:00
Use correct server url in OpenAPI spec
This commit is contained in:
parent
d9c6e521a6
commit
d4b228faa7
@ -10,4 +10,5 @@ contributors-repositories = [
|
|||||||
"revanced-manager",
|
"revanced-manager",
|
||||||
]
|
]
|
||||||
api-version = 1
|
api-version = 1
|
||||||
host = "*.revanced.app"
|
cors = { host = "*.revanced.app", sub-domains = [] }
|
||||||
|
endpoint = "https://api.revanced.app"
|
@ -10,4 +10,5 @@ contributors-repositories = [
|
|||||||
"revanced-manager",
|
"revanced-manager",
|
||||||
]
|
]
|
||||||
api-version = 1
|
api-version = 1
|
||||||
host = "*.revanced.app"
|
cors = { host = "*.127.0.0.1:8888", sub-domains = [] }
|
||||||
|
endpoint = "http://127.0.0.1:8888/"
|
@ -12,7 +12,10 @@ fun Application.configureHTTP() {
|
|||||||
val configurationRepository = get<ConfigurationRepository>()
|
val configurationRepository = get<ConfigurationRepository>()
|
||||||
|
|
||||||
install(CORS) {
|
install(CORS) {
|
||||||
allowHost(host = configurationRepository.host)
|
allowHost(
|
||||||
|
host = configurationRepository.cors.host,
|
||||||
|
subDomains = configurationRepository.cors.subDomains,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
install(RateLimit) {
|
install(RateLimit) {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package app.revanced.api.configuration
|
package app.revanced.api.configuration
|
||||||
|
|
||||||
import app.revanced.api.command.applicationVersion
|
import app.revanced.api.command.applicationVersion
|
||||||
|
import app.revanced.api.configuration.repository.ConfigurationRepository
|
||||||
import io.bkbn.kompendium.core.plugin.NotarizedApplication
|
import io.bkbn.kompendium.core.plugin.NotarizedApplication
|
||||||
import io.bkbn.kompendium.json.schema.KotlinXSchemaConfigurator
|
import io.bkbn.kompendium.json.schema.KotlinXSchemaConfigurator
|
||||||
import io.bkbn.kompendium.oas.OpenApiSpec
|
import io.bkbn.kompendium.oas.OpenApiSpec
|
||||||
@ -12,9 +13,12 @@ import io.bkbn.kompendium.oas.security.BasicAuth
|
|||||||
import io.bkbn.kompendium.oas.security.BearerAuth
|
import io.bkbn.kompendium.oas.security.BearerAuth
|
||||||
import io.bkbn.kompendium.oas.server.Server
|
import io.bkbn.kompendium.oas.server.Server
|
||||||
import io.ktor.server.application.*
|
import io.ktor.server.application.*
|
||||||
|
import org.koin.ktor.ext.get
|
||||||
import java.net.URI
|
import java.net.URI
|
||||||
|
|
||||||
internal fun Application.configureOpenAPI() {
|
internal fun Application.configureOpenAPI() {
|
||||||
|
val configurationRepository = get<ConfigurationRepository>()
|
||||||
|
|
||||||
install(NotarizedApplication()) {
|
install(NotarizedApplication()) {
|
||||||
spec = OpenApiSpec(
|
spec = OpenApiSpec(
|
||||||
info = Info(
|
info = Info(
|
||||||
@ -39,7 +43,7 @@ internal fun Application.configureOpenAPI() {
|
|||||||
),
|
),
|
||||||
).apply {
|
).apply {
|
||||||
servers += Server(
|
servers += Server(
|
||||||
url = URI("https://api.revanced.app"),
|
url = URI(configurationRepository.endpoint),
|
||||||
description = "ReVanced API server",
|
description = "ReVanced API server",
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,8 @@ import java.io.File
|
|||||||
* @property integrations The source of the integrations.
|
* @property integrations The source of the integrations.
|
||||||
* @property contributorsRepositoryNames The names of the repositories to get contributors from.
|
* @property contributorsRepositoryNames The names of the repositories to get contributors from.
|
||||||
* @property apiVersion The version to use for the API.
|
* @property apiVersion The version to use for the API.
|
||||||
* @property host The host of the API to configure CORS.
|
* @property cors The CORS configuration.
|
||||||
|
* @property endpoint The endpoint of the API.
|
||||||
*/
|
*/
|
||||||
@Serializable
|
@Serializable
|
||||||
internal class ConfigurationRepository(
|
internal class ConfigurationRepository(
|
||||||
@ -30,7 +31,8 @@ internal class ConfigurationRepository(
|
|||||||
val contributorsRepositoryNames: Set<String>,
|
val contributorsRepositoryNames: Set<String>,
|
||||||
@SerialName("api-version")
|
@SerialName("api-version")
|
||||||
val apiVersion: Int = 1,
|
val apiVersion: Int = 1,
|
||||||
val host: String,
|
val cors: Cors,
|
||||||
|
val endpoint: String,
|
||||||
) {
|
) {
|
||||||
/**
|
/**
|
||||||
* An asset configuration.
|
* An asset configuration.
|
||||||
@ -59,6 +61,19 @@ internal class ConfigurationRepository(
|
|||||||
@SerialName("public-key-file")
|
@SerialName("public-key-file")
|
||||||
val publicKeyFile: File,
|
val publicKeyFile: File,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The CORS configuration.
|
||||||
|
*
|
||||||
|
* @property host The host of the API to configure CORS.
|
||||||
|
* @property subDomains The subdomains to allow for CORS.
|
||||||
|
*/
|
||||||
|
@Serializable
|
||||||
|
internal class Cors(
|
||||||
|
val host: String,
|
||||||
|
@SerialName("sub-domains")
|
||||||
|
val subDomains: List<String>,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private object RegexSerializer : KSerializer<Regex> {
|
private object RegexSerializer : KSerializer<Regex> {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user