Skip to content

Commit f219cc6

Browse files
committed
attempt to stop openApi parsing attempts cluttering the console
1 parent 23afc79 commit f219cc6

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

dataframe-openapi/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/OpenApi.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,16 @@ public class OpenApi : SupportedCodeGenerationFormat {
7272
override fun acceptsExtension(ext: String): Boolean = ext in listOf("yaml", "yml", "json")
7373

7474
// Needed for distinguishing between JSON and OpenAPI JSON
75-
override fun acceptsSample(sample: SupportedFormatSample): Boolean =
75+
override fun acceptsSample(sample: SupportedFormatSample): Boolean = try {
7676
when (sample) {
7777
is SupportedFormatSample.DataString -> isOpenApiStr(sample.sampleData)
7878
is SupportedFormatSample.File -> isOpenApi(sample.sampleFile)
7979
is SupportedFormatSample.PathString -> isOpenApi(sample.samplePath)
8080
is SupportedFormatSample.URL -> isOpenApi(sample.sampleUrl)
8181
}
82+
} catch (_: Exception) {
83+
false
84+
}
8285

8386
override val testOrder: Int = 9_000
8487

dataframe-openapi/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/isOpenApi.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ import java.io.File
55
import java.net.URL
66

77
/** Needs to have any type schemas to convert. */
8-
public fun isOpenApiStr(text: String): Boolean {
8+
public fun isOpenApiStr(text: String): Boolean = try {
99
val parsed = OpenAPIParser().readContents(text, null, null)
10-
return parsed.openAPI?.components?.schemas != null
10+
parsed.openAPI?.components?.schemas != null
11+
} catch (_: Exception) {
12+
false
1113
}
1214

1315
public fun isOpenApi(path: String): Boolean = isOpenApi(asURL(path))

0 commit comments

Comments
 (0)