I have been able to find a lot of information abou...
# http4k
s
I have been able to find a lot of information about generating an OpenAPI spec from http4k, but what about generating server stubs/routes/schema verification from the Spec. I haven't really been able to see that, or am I just looking in the wrong places?
a
You should be able to verify the generated spec using the approval testing module. Will find examples when I'm not on mobile.
d
You can use the http4k toolbox to read a spec and generate a zip with a server, models and client code in it. Note that is is quite picky - lots of people actually hand roll their own (invalid) specs which the toolbox will reject.
a
Here's an example approval test. Just update your request to point to the OpenAPI spec. The test will save an
.actual
file to the test resources directory, and to approve it, you rename the extension to
.approved
. You'll need to add the
http4k-testing-approval
module to gradle. https://github.com/http4k/http4k/blob/master/http4k-testing/approval/src/test/kotlin/org/http4k/testing/ExampleJsonApprovalTest.kt#L29-L32
👍 1
s
Thanks, very helpful