danielgtaylor / huma

Huma REST/HTTP API Framework for Golang with OpenAPI 3.1
https://huma.rocks/
MIT License
1.95k stars 144 forks source link

Adding openapi command still emits router config #460

Closed darrenparkinson closed 4 months ago

darrenparkinson commented 4 months ago

Hi,

Just really after some guidance on this issue. I've added the openapi command as per the docs:

https://huma.rocks/tutorial/client-sdks/

In my case I'm using the gin router.

Because the router needs to be initialised in order to add the routes and then run the openapi command, the command actually emits all the gin debug too.

Is this expected behaviour or is there a way I can prevent this?

I guess I could use a different router initially and then set up the real one in the hooks?

Any feedback greatly appreciated.

Many thanks.

danielgtaylor commented 4 months ago

@darrenparkinson you can try putting gin.SetMode(gin.ReleaseMode) into your main.go to prevent that debug output, otherwise you may have to filter it out. I think this is specific to Gin.

darrenparkinson commented 4 months ago

Cool. That’s what I was thinking. Just wasn’t sure if I was missing something. I’m thinking about switching to the new std library routing for this API tbh, so that should help.