Skip to content

Feat: Add Fiber server support - #813

Merged
47 commits merged into
oapi-codegen:masterfrom
Jleagle:master
Jun 2, 2023
Merged

Feat: Add Fiber server support#813
47 commits merged into
oapi-codegen:masterfrom
Jleagle:master

Conversation

@Jleagle

@Jleagle Jleagle commented Oct 24, 2022

Copy link
Copy Markdown
Contributor

Fixes #301

Massive thank you to @gnirb for already doing some of the PR.

@gnirb

gnirb commented Feb 8, 2023

Copy link
Copy Markdown
Contributor

Hello @Jleagle, how is the PR going? Can I be of any assistance?

@Jleagle

Jleagle commented Feb 9, 2023

Copy link
Copy Markdown
Contributor Author

@gnirb
Hi, i made a start and merged in most of your work. Last time i tested it, it didn't actually generate anything 🤷. Not had much time to find out why recently. Any help would be appreciated.

@gnirb

gnirb commented Feb 16, 2023

Copy link
Copy Markdown
Contributor

@gnirb Hi, i made a start and merged in most of your work. Last time i tested it, it didn't actually generate anything 🤷. Not had much time to find out why recently. Any help would be appreciated.

Anything outstanding now before removing "draft"-status for the PR?

@Jleagle
Jleagle marked this pull request as ready for review February 16, 2023 21:10
@Jleagle

Jleagle commented Feb 20, 2023

Copy link
Copy Markdown
Contributor Author

@deepmap-marcinr Hi, any chance one of your team could take a look at this please? Thanks!

@mfiumara

Copy link
Copy Markdown

Nice work, is it already usable from your branch? Or still requires testing?

@Jleagle

Jleagle commented Feb 27, 2023

Copy link
Copy Markdown
Contributor Author

@mfiumara
I have not started using it in production yet but so far everything works, lots of the code comes from @gnirb's branch who uses it internally too. More testing can only be a good thing though.

Comment thread README.md Outdated
// Code generated by github.com/deepmap/oapi-codegen version (devel) DO NOT EDIT.
package headdigitofhttpheader

import (

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this removed?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this removed?

Comment thread go.mod Outdated
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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why isn't this file a 1:1 copy of internal/test/strict-server/echo/server.go?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure, changing..

Comment thread pkg/fiber-middleware/oapi_validate_test.go Outdated
// Parameter object where we will unmarshal all parameters from the context
var params FindPetsParams

query, err := url.ParseQuery(string(c.Request().URI().QueryString()))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could use fiber's func (c *Ctx) QueryParser(out interface{}) error func https://docs.gofiber.io/api/ctx/#queryparser

@gnirb gnirb Apr 11, 2023

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't do anything.

@leonklingele

Copy link
Copy Markdown
Contributor

Good job! 🥳 Added some comments.

Comment thread pkg/fiber-middleware/oapi_validate_test.go
Comment thread pkg/fiber-middleware/oapi_validate_test.go Outdated
Comment thread pkg/fiber-middleware/oapi_validate_test.go
Comment thread pkg/fiber-middleware/oapi_validate_test.go Outdated
Comment thread pkg/fiber-middleware/oapi_validate_test.go Outdated
Comment thread pkg/fiber-middleware/oapi_validate_test.go Outdated
Comment thread pkg/fiber-middleware/oapi_validate_test.go
Comment thread pkg/fiber-middleware/oapi_validate_test.go Outdated
@ghost

ghost commented Mar 6, 2023

Copy link
Copy Markdown

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.

@Jleagle

Jleagle commented Apr 10, 2023

Copy link
Copy Markdown
Contributor Author

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?

@leonklingele

leonklingele commented Apr 10, 2023 via email

Copy link
Copy Markdown
Contributor

@gnirb

gnirb commented Apr 11, 2023

Copy link
Copy Markdown
Contributor

@gnirb Would you be able to help answer leonklingele's questions?

Sure, I'll take a look!

@gnirb

gnirb commented Apr 11, 2023

Copy link
Copy Markdown
Contributor

Opened a PR to address the comments https://github.com/Jleagle/oapi-codegen/pull/29, please take a look @Jleagle

@gnirb

gnirb commented Apr 11, 2023

Copy link
Copy Markdown
Contributor

Alright @leonklingele comments addressed, please take another look if this feels good to go

@Jleagle

Jleagle commented Apr 27, 2023

Copy link
Copy Markdown
Contributor Author

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.

@deepmap-marcinr. I think everything has been resolved 👍

@leonklingele leonklingele left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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!

Comment thread go.mod Outdated
Comment thread go.mod Outdated
Comment thread go.mod Outdated
Comment thread pkg/codegen/templates/imports.tmpl
Comment thread internal/test/strict-server/fiber/server.gen.go Outdated
Comment thread internal/test/strict-server/fiber/server.gen.go
Comment thread internal/test/strict-server/fiber/server.gen.go
Comment thread internal/test/strict-server/fiber/server.gen.go
Comment thread internal/test/strict-server/fiber/server.gen.go Outdated
@leonklingele

Copy link
Copy Markdown
Contributor

@Jleagle please also do one final rebase to master :)

Comment thread pkg/fiber-middleware/oapi_validate.go Outdated
@leonklingele leonklingele mentioned this pull request May 13, 2023

@leonklingele leonklingele left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm! @deepmap-marcinr what do you say? :)

@ghost

ghost commented Jun 2, 2023

Copy link
Copy Markdown

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.

@ghost

ghost commented Jun 2, 2023

Copy link
Copy Markdown

I pulled your change to test locally, and some things are missing.

  1. run go mod tidy
  2. regenerate all your fiber boilerplate
  3. Tests fail:
# github.com/deepmap/oapi-codegen/internal/test/strict-server/fiber
internal/test/strict-server/fiber/server.gen.go:810:10: request.PType undefined (type ReservedGoKeywordParametersRequestObject has no field or method PType)

- Update modules
- Add missing test handler
- Fix variable naming in strict server wrappers
Comment thread pkg/codegen/templates/strict/strict-fiber.tmpl Outdated
Comment thread internal/test/strict-server/fiber/server.go
@ghost

ghost commented Jun 2, 2023

Copy link
Copy Markdown

@Jleagle - please see the PR I sent you which fixes these problems.
https://github.com/Jleagle/oapi-codegen/pull/31

After you merge that, pls make lint pass.

@ghost
ghost merged commit 7aa85bb into oapi-codegen:master Jun 2, 2023
adrianpk pushed a commit to foorester/oapi-codegen that referenced this pull request Jan 16, 2024
* 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>
adrianpk added a commit to foorester/oapi-codegen that referenced this pull request May 31, 2024
* 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>
danicc097 pushed a commit to danicc097/oapi-codegen that referenced this pull request Aug 31, 2024
* 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>
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Open to new routers?

5 participants