oapi-codegen icon indicating copy to clipboard operation
oapi-codegen copied to clipboard

Feat: register multiple specs

Open drev74 opened this issue 1 year ago • 2 comments

Hello thanks for building and supporting this incredibly useful software :hugs:

I'm able to generate OAPI3 specs into a server for a single spec. However, when I add 2+ specs and try to register their routes, only the first pack of routes gets registered. I tried this for Echo and Iris.

// trying to register servers foo and bar

app := iris.Default()

apiv1.RegisterHandlers(app, foo) <--- these routes are registered
apiv1.RegisterHandlers(app, bar) <--- these routes are skipped

This approach works well for GRPC, when you can separately register multiple services with own API for a common GRPC server

drev74 avatar Apr 09 '24 12:04 drev74

UPD: I was able to work around this by implementing a partial route registration with Iris:

// *** Foo API
fooAPI := app.Party("/v1/foo")
fooAPI.Post("/", fooRest.Create)

// *** Bar API
barAPI := app.Party("/v1/bar")
barAPI.Post("/", barRest.Create)

drev74 avatar Apr 09 '24 14:04 drev74