Hi All, How can I easily configure OpenAPI or swag...
# http4k
m
Hi All, How can I easily configure OpenAPI or swagger for my existing routes? I checked the codes and discussions here, open API contract is totally confusing me to be honest🙂
Copy code
fun routes(): RoutingHttpHandler {
return org.http4k.routing.routes(
                "/ping" bind Method.GET to pingHandler,
                "foo" bind <http://Method.POST|Method.POST> t fooHandler,
              
        )
}
d
Hey. You can't use the standard routing system to generate swagger - you'd need to use the contract routing system instead. There is a full example of building using this system here - so please check it out: https://github.com/http4k/http4k-by-example/tree/master/src/main/kotlin/verysecuresystems/api
m
Ok, now I got what is the point, I am trying to do the same thing, I am facing this error:
Copy code
Receiver class org.http4k.contract.ContractRoutingHttpHandler does not define or inherit an implementation of the resolved method abstract match(Lorg/http4k/core/Request;)Lorg/http4k/routing/RouterMatch; of interface org.http4k.routing.Router.
d
that seems like you've got something strange going on on your classpath
can you ensure you've only got a single version available?
and post a Gist recreating it so we can take a look at the code if it's still a problem
m
thanks let me check