Skip to content

Commit

Permalink
API-7065 - Tidy up logging and code. Adding config for oas fetch over…
Browse files Browse the repository at this point in the history
… https
  • Loading branch information
peteslater-ee committed May 30, 2023
1 parent 4216cf6 commit 64b4681
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ trait ApplicationConfig {
def thirdPartyDeveloperUrl: String
def apiPlatformMicroserviceBaseUrl: String
def ramlPreviewMicroserviceBaseUrl: String
def apiDocumentationBaseUrl: String

def securedCookie: Boolean
def ramlPreviewEnabled: Boolean
Expand Down Expand Up @@ -58,6 +57,7 @@ trait ApplicationConfig {
def cookieSettingsUrl: String

def oasFetchResolvedMaxDuration: Long
def oasFetchResolvedUsingHttps: Boolean
}

@Singleton
Expand All @@ -80,8 +80,6 @@ class ApplicationConfigImpl @Inject() (config: Configuration)
lazy val apiPlatformMicroserviceBaseUrl = baseUrl("api-platform-microservice")
lazy val ramlPreviewMicroserviceBaseUrl = baseUrl("raml-preview-microservice")

lazy val apiDocumentationBaseUrl = getString("apidocumentation.base.url")

val securedCookie = getBoolean("cookie.secure")
val ramlPreviewEnabled = getBoolean("features.ramlPreview")
val openApiPreviewEnabled = getBoolean("features.openApiPreview")
Expand Down Expand Up @@ -109,6 +107,7 @@ class ApplicationConfigImpl @Inject() (config: Configuration)
val cookieSettingsUrl: String = s"/${getString("tracking-consent-frontend.cookie-settings-path")}"

val oasFetchResolvedMaxDuration: Long = config.getMillis("oasFetchResolvedMaxDurationMilliseconds")
val oasFetchResolvedUsingHttps: Boolean = getBoolean("oasFetchResolvedUsingHttps")

private def platformBaseUrl(key: String) = {
(getConfigDefaulted(s"$key.protocol", ""), getConfigDefaulted(s"$key.host", "")) match {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,17 +139,13 @@ class OpenApiDocumentationController @Inject() (
parseOptions.setResolveFully(true)

val emptyAuthList = java.util.Collections.emptyList[io.swagger.v3.parser.core.models.AuthorizationValue]()

val oasFileLocation = routes.OpenApiDocumentationController.fetchOas(service, version).absoluteURL(true)

logger.info(s"OAS File Location: $oasFileLocation")
val fetchUsingHttps = appConfig.oasFetchResolvedUsingHttps
val oasFileLocation = routes.OpenApiDocumentationController.fetchOas(service, version).absoluteURL(fetchUsingHttps)

val futureParsing = Future {
blocking {
try {
logger.info("Starting reading OAS specification")
val parserResult = openAPIV3Parser.readLocation(oasFileLocation, emptyAuthList, parseOptions)
logger.info("Finished reading OAS specification")

Option(parserResult.getOpenAPI()) match {
// The OAS specification has been found and parsed by Swagger - return the fully resolved specification to the caller.
Expand Down
1 change: 1 addition & 0 deletions conf/application.conf
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ play.filters.csp.directives.script-src = ${play.filters.csp.nonce.pattern} "'str
retryCount = 3
retryDelayMilliseconds = 500
oasFetchResolvedMaxDurationMilliseconds = 20000
oasFetchResolvedUsingHttps = false

apidocumentation.base.url = "http://localhost:9680"

Expand Down

0 comments on commit 64b4681

Please sign in to comment.