Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import kotlinx.serialization.json.encodeToJsonElement
open class OpenAPIV2(
val json: Json = Json { prettyPrint = true },
) : OpenAPISpecification {

fun decodeFromString(string: String): OpenAPIV2Model = json
.decodeFromString<JsonObject>(string)
.decode(V2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ open class OpenAPIV3(
val json: Json = Json { prettyPrint = true },
) : OpenAPISpecification {

fun decodeFromJsonString(string: String): OpenAPIV3Model = json
fun decodeFromString(string: String): OpenAPIV3Model = json
.decodeFromString<JsonObject>(string)
.decode(V3)
.let(json::decodeFromJsonElement)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ class OpenAPIV3Tests {
fun `openapi v2 is not valid`() {
val input = readFile("petstore.json", V2)
shouldThrow<IllegalStateException> {
OpenAPIV3.decodeFromJsonString(input)
OpenAPIV3.decodeFromString(input)
}.message shouldBe "No valid openapi v3 element 'openapi' is missing"
}

private fun openAPIv3(fileName: String) {
readFile(fileName, V3).let {
it shouldEqualJson it
.let(OpenAPIV3::decodeFromJsonString)
.let(OpenAPIV3::decodeFromString)
.let(OpenAPIV3::encodeToString)
}
}
Expand Down
Loading