-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add access key parameter to /sample/info and remove downloadAsFile
- Loading branch information
1 parent
1402019
commit 340f2ac
Showing
4 changed files
with
60 additions
and
8 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
lapis2/src/main/kotlin/org/genspectrum/lapis/openApi/AccessKeyParameterCustomizer.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package org.genspectrum.lapis.openApi | ||
|
||
import io.swagger.v3.oas.models.OpenAPI | ||
import io.swagger.v3.oas.models.parameters.Parameter | ||
import org.genspectrum.lapis.config.DatabaseConfig | ||
import org.genspectrum.lapis.config.OpennessLevel | ||
import org.genspectrum.lapis.controller.ACCESS_KEY_PROPERTY | ||
import org.genspectrum.lapis.controller.INFO_ROUTE | ||
import org.springdoc.core.customizers.OpenApiCustomizer | ||
import org.springframework.stereotype.Component | ||
|
||
@Component | ||
class AccessKeyParameterCustomizer( | ||
private val databaseConfig: DatabaseConfig, | ||
) : OpenApiCustomizer { | ||
companion object { | ||
private val PATH_WITH_ACCESS_KEY_PARAMETER = listOf( | ||
"/sample$INFO_ROUTE", | ||
) | ||
} | ||
|
||
override fun customise(openApi: OpenAPI) { | ||
if (databaseConfig.schema.opennessLevel == OpennessLevel.OPEN) { | ||
return | ||
} | ||
|
||
for ((_, path) in openApi.paths.filter { (url, _) -> | ||
PATH_WITH_ACCESS_KEY_PARAMETER.any { | ||
url.startsWith(it) | ||
} | ||
}) { | ||
path.get.addParametersItem( | ||
Parameter() | ||
.`in`("query") | ||
.name(ACCESS_KEY_PROPERTY) | ||
.description(ACCESS_KEY_DESCRIPTION) | ||
.schema(accessKeySchema()), | ||
) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters