Feat: Add Fiber server support#813
Feat: Add Fiber server support#813deepmap-marcinr merged 47 commits intooapi-codegen:masterfrom Jleagle:master
Conversation
|
Hello @Jleagle, how is the PR going? Can I be of any assistance? |
|
@gnirb |
Anything outstanding now before removing "draft"-status for the PR? |
|
@deepmap-marcinr Hi, any chance one of your team could take a look at this please? Thanks! |
|
Nice work, is it already usable from your branch? Or still requires testing? |
| // Code generated by github.com/deepmap/oapi-codegen version (devel) DO NOT EDIT. | ||
| package headdigitofhttpheader | ||
|
|
||
| import ( |
There was a problem hiding this comment.
Why was this removed?
There was a problem hiding this comment.
Don't know, but I'll revert it
| // | ||
| // Code generated by github.com/deepmap/oapi-codegen version (devel) DO NOT EDIT. | ||
| package head_digit_of_operation_id | ||
|
|
There was a problem hiding this comment.
Why was this removed?
| github.com/gin-gonic/gin v1.8.1 | ||
| github.com/go-chi/chi/v5 v5.0.8 | ||
| github.com/gofiber/adaptor/v2 v2.1.30 | ||
| github.com/gofiber/fiber/v2 v2.40.1 |
There was a problem hiding this comment.
This should be updated.
| @@ -0,0 +1,129 @@ | |||
| //go:generate go run github.com/deepmap/oapi-codegen/cmd/oapi-codegen --config=server.cfg.yaml ../strict-schema.yaml | |||
There was a problem hiding this comment.
Why isn't this file a 1:1 copy of internal/test/strict-server/echo/server.go?
| // Parameter object where we will unmarshal all parameters from the context | ||
| var params FindPetsParams | ||
|
|
||
| query, err := url.ParseQuery(string(c.Request().URI().QueryString())) |
There was a problem hiding this comment.
This could use fiber's func (c *Ctx) QueryParser(out interface{}) error func https://docs.gofiber.io/api/ctx/#queryparser
There was a problem hiding this comment.
After some investigation it seems like this requires all the generated request struct query fields to be tagged with query: <name>.
Gonna leave it as a future improvement, since it looks like it will require changes to the type generation potentially affecting the other server implementations too.
| // FindPets operation middleware | ||
| func (siw *ServerInterfaceWrapper) FindPets(c *fiber.Ctx) error { | ||
|
|
||
| var err error |
There was a problem hiding this comment.
This doesn't do anything.
|
Good job! 🥳 Added some comments. |
|
This looks good overall, with some cosmetics issues. Can you rearrange your imports into 3 sections - stdlib, third party imports, than oapi-codegen imports? It's what other files do. This change is isolated to Fiber mainly, but it gives us yet another router to support. I really need to think about making this modular somehow, so that we don't need to change the core oapi-codegen to provide router specific code, but this isn't anything to do with your commit. Please respond to the good questions by @leonklingele and I'm happy to merge once everything is resolved. |
Imports updated. @gnirb Would you be able to help answer leonklingele's questions? |
|
Sorry! Meant to say t.Helper()
|
Sure, I'll take a look! |
|
Opened a PR to address the comments https://github.com/Jleagle/oapi-codegen/pull/29, please take a look @Jleagle |
|
Alright @leonklingele comments addressed, please take another look if this feels good to go |
@deepmap-marcinr. I think everything has been resolved 👍 |
leonklingele
left a comment
There was a problem hiding this comment.
Last-minute review incoming 🫨
Almost perfect, just some small modifications which also make it a bit faster by removing unnecessary type conversions. Thanks for your work here, @Jleagle!
|
@Jleagle please also do one final rebase to |
Co-authored-by: leonklingele <git@leonklingele.de>
Co-authored-by: leonklingele <git@leonklingele.de>
Co-authored-by: leonklingele <git@leonklingele.de>
Co-authored-by: leonklingele <git@leonklingele.de>
leonklingele
left a comment
There was a problem hiding this comment.
lgtm! @deepmap-marcinr what do you say? :)
This is a big change and another router to maintain, but it's nicely isolated. Could you rebase and fix the conflicts, and then I'll merge it, and release it in 1.13.0, which I intend to release as soon as this commit is ready. |
|
I pulled your change to test locally, and some things are missing.
|
- Update modules - Add missing test handler - Fix variable naming in strict server wrappers
|
@Jleagle - please see the PR I sent you which fixes these problems. After you merge that, pls make lint pass. |
* Revert generated * Add to cmd * Add to codegen * Fiber * Fix imports * Templates * Split types and code * Rename aliases * Strict * tests * Validate middleware * Templates * Update petstore * Generate * Generate * Readme * Fix tests * Fix build * tweaks to get it running * fixed linter errors, even though other servers seem to just ignore these * Fix option yaml * Fix tests * Mod tidy * Remove extra space * Check errors * Update pkg/fiber-middleware/oapi_validate_test.go Co-authored-by: leonklingele <git@leonklingele.de> * Update pkg/fiber-middleware/oapi_validate_test.go Co-authored-by: leonklingele <git@leonklingele.de> * Update pkg/fiber-middleware/oapi_validate_test.go Co-authored-by: leonklingele <git@leonklingele.de> * Update pkg/fiber-middleware/oapi_validate_test.go Co-authored-by: leonklingele <git@leonklingele.de> * Update pkg/fiber-middleware/oapi_validate_test.go Co-authored-by: leonklingele <git@leonklingele.de> * Separate oapi-codegen imports * Use t.Helper() * fixing comments * Sort imports * Use WriteString * Fix imports * Mods * Generate * Add missing config * Use new adaptor * Use new adaptor * Fix compilation and test issues - Update modules - Add missing test handler - Fix variable naming in strict server wrappers --------- Co-authored-by: Carl Bring <111354161+gnirb@users.noreply.github.com> Co-authored-by: leonklingele <git@leonklingele.de> Co-authored-by: marcinromaszewicz <marcinromaszewicz@deepmap.ai>
* Revert generated * Add to cmd * Add to codegen * Fiber * Fix imports * Templates * Split types and code * Rename aliases * Strict * tests * Validate middleware * Templates * Update petstore * Generate * Generate * Readme * Fix tests * Fix build * tweaks to get it running * fixed linter errors, even though other servers seem to just ignore these * Fix option yaml * Fix tests * Mod tidy * Remove extra space * Check errors * Update pkg/fiber-middleware/oapi_validate_test.go Co-authored-by: leonklingele <git@leonklingele.de> * Update pkg/fiber-middleware/oapi_validate_test.go Co-authored-by: leonklingele <git@leonklingele.de> * Update pkg/fiber-middleware/oapi_validate_test.go Co-authored-by: leonklingele <git@leonklingele.de> * Update pkg/fiber-middleware/oapi_validate_test.go Co-authored-by: leonklingele <git@leonklingele.de> * Update pkg/fiber-middleware/oapi_validate_test.go Co-authored-by: leonklingele <git@leonklingele.de> * Separate oapi-codegen imports * Use t.Helper() * fixing comments * Sort imports * Use WriteString * Fix imports * Mods * Generate * Add missing config * Use new adaptor * Use new adaptor * Fix compilation and test issues - Update modules - Add missing test handler - Fix variable naming in strict server wrappers --------- Co-authored-by: Carl Bring <111354161+gnirb@users.noreply.github.com> Co-authored-by: leonklingele <git@leonklingele.de> Co-authored-by: marcinromaszewicz <marcinromaszewicz@deepmap.ai>
* Revert generated * Add to cmd * Add to codegen * Fiber * Fix imports * Templates * Split types and code * Rename aliases * Strict * tests * Validate middleware * Templates * Update petstore * Generate * Generate * Readme * Fix tests * Fix build * tweaks to get it running * fixed linter errors, even though other servers seem to just ignore these * Fix option yaml * Fix tests * Mod tidy * Remove extra space * Check errors * Update pkg/fiber-middleware/oapi_validate_test.go Co-authored-by: leonklingele <git@leonklingele.de> * Update pkg/fiber-middleware/oapi_validate_test.go Co-authored-by: leonklingele <git@leonklingele.de> * Update pkg/fiber-middleware/oapi_validate_test.go Co-authored-by: leonklingele <git@leonklingele.de> * Update pkg/fiber-middleware/oapi_validate_test.go Co-authored-by: leonklingele <git@leonklingele.de> * Update pkg/fiber-middleware/oapi_validate_test.go Co-authored-by: leonklingele <git@leonklingele.de> * Separate oapi-codegen imports * Use t.Helper() * fixing comments * Sort imports * Use WriteString * Fix imports * Mods * Generate * Add missing config * Use new adaptor * Use new adaptor * Fix compilation and test issues - Update modules - Add missing test handler - Fix variable naming in strict server wrappers --------- Co-authored-by: Carl Bring <111354161+gnirb@users.noreply.github.com> Co-authored-by: leonklingele <git@leonklingele.de> Co-authored-by: marcinromaszewicz <marcinromaszewicz@deepmap.ai>
Fixes #301
Massive thank you to @gnirb for already doing some of the PR.