File tree Expand file tree Collapse file tree 2 files changed +8
-3
lines changed
dataframe-openapi/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io Expand file tree Collapse file tree 2 files changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -72,13 +72,16 @@ public class OpenApi : SupportedCodeGenerationFormat {
72
72
override fun acceptsExtension (ext : String ): Boolean = ext in listOf (" yaml" , " yml" , " json" )
73
73
74
74
// Needed for distinguishing between JSON and OpenAPI JSON
75
- override fun acceptsSample (sample : SupportedFormatSample ): Boolean =
75
+ override fun acceptsSample (sample : SupportedFormatSample ): Boolean = try {
76
76
when (sample) {
77
77
is SupportedFormatSample .DataString -> isOpenApiStr(sample.sampleData)
78
78
is SupportedFormatSample .File -> isOpenApi(sample.sampleFile)
79
79
is SupportedFormatSample .PathString -> isOpenApi(sample.samplePath)
80
80
is SupportedFormatSample .URL -> isOpenApi(sample.sampleUrl)
81
81
}
82
+ } catch (_: Exception ) {
83
+ false
84
+ }
82
85
83
86
override val testOrder: Int = 9_000
84
87
Original file line number Diff line number Diff line change @@ -5,9 +5,11 @@ import java.io.File
5
5
import java.net.URL
6
6
7
7
/* * Needs to have any type schemas to convert. */
8
- public fun isOpenApiStr (text : String ): Boolean {
8
+ public fun isOpenApiStr (text : String ): Boolean = try {
9
9
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
11
13
}
12
14
13
15
public fun isOpenApi (path : String ): Boolean = isOpenApi(asURL(path))
You can’t perform that action at this time.
0 commit comments