Adding a Kotlin DSL

56 views
Skip to first unread message

Christian Dräger

unread,
Jan 27, 2020, 4:53:08 PM1/27/20
to wiremock-user
Hey, 
As a Kotlin guy i have to say using the builder pattern to build stubs doesn't feel much kotlin-ish.
What do you think about adding a Kotlin DSL for the Kotliners?

writting stubs in kotlin could look something like this:

data class Song(val title: String)

stubFor {
    get {
        url equalTo "/my-api"
        willReturn {

            headers = mapOf("Content-Type" to "application/json")

            body jsonFromObject Song("The revenge of Vera Gemini")
        }
    }
}

Since Kotlin is interoperable with java it would be no problem to add it to the project.
I could send a pull request.

Tom Akehurst

unread,
Jan 28, 2020, 8:10:54 AM1/28/20
to wiremock-user
I love Kotlin and agree a WireMock DSL would be a great thing to have.

I don't think it belongs in the core project, however. It's possible to create other language bindings without any special privileges on the core (e.g. https://github.com/tomjankes/wiremock-groovy) so I'd recommend creating a standalone library if you're up for it. I'd be happy to link to it from http://wiremock.org.

Othman EL-KOURD

unread,
Jan 28, 2020, 8:26:38 AM1/28/20
to Tom Akehurst, wiremock-user
I'm more than happy to contribute  @Christian Dräger :)
we can start building that

--
You received this message because you are subscribed to the Google Groups "wiremock-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wiremock-use...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/wiremock-user/ffefb9bc-a191-4667-8293-056ee75e781a%40googlegroups.com.

Christian Dräger

unread,
Jan 28, 2020, 10:47:23 AM1/28/20
to wiremock-user
ok cool, i created a rapid prototype --> https://github.com/skrapeit/wiremock-kotlin
i'm looking forward to release a first beta to maven central within the next days.

@Othman EL-KOURD great, let's do this :)
shall i add some issues with next steps to the corresponding github project?

Philipp Mayer

unread,
Feb 1, 2021, 12:52:27 PM2/1/21
to wiremock-user
Would love to contribute to this. Shall we discuss ideas here or should I open an issue?
Reply all
Reply to author
Forward
0 new messages