Skip to content

Commit

Permalink
chore: ignore all billing endpoints when generating open api specs (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Anty0 authored Jan 22, 2025
1 parent 44c0da5 commit e501446
Showing 1 changed file with 20 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class OpenApiConfiguration {
fun internalV1OpenApi(): GroupedOpenApi? {
return internalGroupForPaths(
paths = arrayOf("/api/**"),
excludedPaths = arrayOf(BILLING_EXCLUSION, API_REPOSITORY_EXCLUDE),
excludedPaths = BILLING + arrayOf(API_REPOSITORY),
name = "V1 Internal - for Tolgee Web application",
)
}
Expand All @@ -43,7 +43,7 @@ class OpenApiConfiguration {
fun internalV2OpenApi(): GroupedOpenApi? {
return internalGroupForPaths(
paths = arrayOf("/v2/**"),
excludedPaths = arrayOf(BILLING_EXCLUSION, API_REPOSITORY_EXCLUDE),
excludedPaths = BILLING + arrayOf(API_REPOSITORY),
name = "V2 Internal - for Tolgee Web application",
)
}
Expand All @@ -52,7 +52,7 @@ class OpenApiConfiguration {
fun internalAllOpenApi(): GroupedOpenApi? {
return internalGroupForPaths(
paths = arrayOf("/v2/**", "/api/**"),
excludedPaths = arrayOf(BILLING_EXCLUSION, API_REPOSITORY_EXCLUDE),
excludedPaths = BILLING + arrayOf(API_REPOSITORY),
name = "All Internal - for Tolgee Web application",
)
}
Expand All @@ -61,7 +61,7 @@ class OpenApiConfiguration {
fun apiKeyAllOpenApi(): GroupedOpenApi? {
return pakGroupForPaths(
paths = arrayOf("/api/**", "/v2/**"),
excludedPaths = arrayOf(BILLING_EXCLUSION, API_REPOSITORY_EXCLUDE),
excludedPaths = BILLING + arrayOf(API_REPOSITORY),
name = "Accessible with Project API key (All)",
)
}
Expand All @@ -70,7 +70,7 @@ class OpenApiConfiguration {
fun apiKeyV1OpenApi(): GroupedOpenApi? {
return pakGroupForPaths(
paths = arrayOf("/api/**"),
excludedPaths = arrayOf(BILLING_EXCLUSION, API_REPOSITORY_EXCLUDE),
excludedPaths = BILLING + arrayOf(API_REPOSITORY),
name = "Accessible with Project API key (V1)",
)
}
Expand All @@ -79,7 +79,7 @@ class OpenApiConfiguration {
fun apiKeyV2OpenApi(): GroupedOpenApi? {
return pakGroupForPaths(
paths = arrayOf("/v2/**"),
excludedPaths = arrayOf(BILLING_EXCLUSION, API_REPOSITORY_EXCLUDE),
excludedPaths = BILLING + arrayOf(API_REPOSITORY),
name = "Accessible with Project API key (V2)",
)
}
Expand All @@ -88,15 +88,15 @@ class OpenApiConfiguration {
fun allPublicApi(): GroupedOpenApi? {
return publicApiGroupForPaths(
paths = arrayOf("/v2/**", "/api/**"),
excludedPaths = arrayOf(API_REPOSITORY_EXCLUDE),
excludedPaths = arrayOf(API_REPOSITORY),
name = "Public API (All)",
)
}

@Bean
fun billingOpenApi(): GroupedOpenApi? {
return internalGroupForPaths(
paths = arrayOf("/v2/**/billing/**"),
paths = BILLING,
excludedPaths = arrayOf("/v2/public/billing/webhook"),
name = "V2 Billing",
)
Expand Down Expand Up @@ -225,8 +225,18 @@ class OpenApiConfiguration {
method.getAnnotation(OpenApiHideFromPublicDocs::class.java)

companion object {
private const val API_REPOSITORY_EXCLUDE = "/api/repository/**"
private const val BILLING_EXCLUSION = "/v2/**/billing/**"
private const val API_REPOSITORY = "/api/repository/**"
private const val BILLING_MAIN = "/v2/**/billing/**"
private const val BILLING_LICENSING = "/v2/**/licensing/**"
private const val BILLING_TELEMETRY = "/v2/**/telemetry/**"
private const val BILLING_TRANSLATOR = "/v2/**/translator/**"
private val BILLING =
arrayOf(
BILLING_MAIN,
BILLING_LICENSING,
BILLING_TELEMETRY,
BILLING_TRANSLATOR,
)
private val PATH_WITH_PROJECT_ID_REGEX = "^/(?:api|v2)/projects?/\\{$PROJECT_ID_PARAMETER}.*".toRegex()
}
}

0 comments on commit e501446

Please sign in to comment.