Skip to content

Commit

Permalink
paths can now contain capitals underscores and dashes (#195)
Browse files Browse the repository at this point in the history
  • Loading branch information
jerrevanveluw authored Apr 20, 2024
1 parent e9a781d commit 9a29af4
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ object WirespecSpec : LanguageSpec {
Regex("^[1-5][0-9][0-9]") to StatusCode,
Regex("^[a-z][a-zA-Z]*") to CustomValue,
Regex("^[A-Z][a-zA-Z_]*") to CustomType,
Regex("^/[a-z]+") to Path,
Regex("^/[a-zA-Z-_]+") to Path,
Regex("^/") to ForwardSlash,
Regex("^.") to Invalid // Catch all regular expression if none of the above matched
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,32 @@ class ParseEndpointTest {
}
}

@Test
fun testEndpointPathParser() {
val source = """
endpoint GetTodos GET /To-Do_List -> {
200 -> Todo[]
}
""".trimIndent()

WirespecSpec.tokenize(source)
.let(parser()::parse)
.shouldBeRight()
.also { it.size shouldBe 1 }
.first()
.shouldBeInstanceOf<Endpoint>()
.run {
name shouldBe "GetTodos"
method shouldBe GET
path shouldBe listOf(Literal("To-Do_List"))
requests shouldBe listOf(
Endpoint.Request(
content = null
)
)
}
}

@Test
fun testPathParamsParser() {
val source = """
Expand Down

0 comments on commit 9a29af4

Please sign in to comment.