Skip to content

Commit

Permalink
Merge pull request #490 from Kotlin/isOpenApi-error-fix
Browse files Browse the repository at this point in the history
Catching Error too in `isOpenApiStr`
  • Loading branch information
Jolanrensen authored Nov 6, 2023
2 parents 10fc58c + 808e3d8 commit 6489a54
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions dataframe-openapi/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ repositories {
dependencies {
api(project(":core"))

implementation(libs.kotlinLogging)
implementation(libs.kotlin.reflect)
implementation(libs.kotlinpoet)
api(libs.swagger) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
package org.jetbrains.kotlinx.dataframe.io

import io.github.oshai.kotlinlogging.KotlinLogging
import io.swagger.parser.OpenAPIParser
import java.io.File
import java.net.URL

private val logger = KotlinLogging.logger {}

/** Needs to have any type schemas to convert. */
public fun isOpenApiStr(text: String): Boolean = try {
val parsed = OpenAPIParser().readContents(text, null, null)
parsed.openAPI?.components?.schemas != null
} catch (_: Exception) {
} catch (e: Throwable) {
logger.debug(e) { "Attempt to read input as YAML/JSON OpenAPI specification failed." }
false
}

Expand Down

0 comments on commit 6489a54

Please sign in to comment.