Skip to content

Commit

Permalink
API-7065 - Adding extra logging around OAS parsing (hmrc#458)
Browse files Browse the repository at this point in the history
  • Loading branch information
peteslater-ee authored May 26, 2023
1 parent 0711062 commit efc3503
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ import uk.gov.hmrc.apidocumentation.services.{ApiDefinitionService, LoggedInUser
import uk.gov.hmrc.apidocumentation.util.ApplicationLogger
import uk.gov.hmrc.apidocumentation.views.html._

import scala.jdk.CollectionConverters._

@Singleton
class OpenApiDocumentationController @Inject() (
openApiViewRedoc: OpenApiViewRedoc,
Expand Down Expand Up @@ -143,17 +145,21 @@ class OpenApiDocumentationController @Inject() (
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.
case Some(openApi) => {
logger.info("Successfully parsed the OAS specification.")
logger.info(parserResult.getMessages().asScala.mkString)
handleSuccess(openApi)
}
// The OAS specification has been found but there was a parsing problem - return an empty specification to the caller.
case None => {
logger.info(s"There was a problem parsing the OAS specification.")
logger.info("There was a problem parsing the OAS specification.")
logger.info(parserResult.getMessages().asScala.mkString)
handleFailure
}
}
Expand Down

0 comments on commit efc3503

Please sign in to comment.