feat: support for use-httprouter-in-std-http-server in compatibility-options to allow to use github.com/julienschmidt/httprouter#2189
Conversation
…options to allow to use github.com/julienschmidt/httprouter
jamietanna
left a comment
There was a problem hiding this comment.
Thanks for this - I'd say this should be under output-options instead, after which this looks reasonable
Can we also make sure the JSON Schema is updated?
…not in compatibility-options
Thank you for output-options instead of compatibility. I updated JSON Schema (configuration-schema.json file) and I don't know about any other I should update.. I am probably missing something.. Please be more specific if it is this case. |
|
Hi, anyone can help reviewing this PR? Does anyone see more issues or have ideas for improvement? @jamietanna Are you ok with the fixed version? |
…oapi-codegen#2197) This is a prototype implementation of a future versions of oapi-codegen. It's almost a full rewrite, heavily inspired by previous code, and lessons learned. - much more flexibility in configuring generated code - move from kin-openapi to libopenapi to support 3.1 and 3.2 specs - webhook support - callback support - incompatible codegen changes to aggregate types (allOf, anyOf, oneOf) - many existing codegen bugs around schemas fixed
oapi-codegen#2198) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
* Add output filtering Fixes oapi-codegen#2200 Add output filtering like in V2, and support fetching specs via HTTP. * Fix lint issue --------- Co-authored-by: Marcin Romaszewicz <mromaszewicz@nvidia.com>
Co-authored-by: Marcin Romaszewicz <mromaszewicz@nvidia.com>
Thanks to Speakeasy and LivePeer for their support over the years!
This reverts commit 17ba42e.
This reverts commit db8abb8.
…security] (oapi-codegen#2198)" This reverts commit 98e5d1a.
…bopenapi (oapi-codegen#2197)" This reverts commit 5206145.
As a way to keep updates to the CI pipelines more straightforward, we can extract this out to a shared, versioned (and updated by Renovate) Action. We can make sure to keep our binary builds going, but only for the current versions of Go - other build failures will be caught by our shared Action.
…urity] (oapi-codegen#2207) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Yuichiro Tsuji <yui.tsuji@mbk-wellness.co.jp>
Signed-off-by: Richard Kosegi <richard.kosegi@gmail.com> Co-authored-by: Marcin Romaszewicz <mromaszewicz@users.noreply.github.com>
…api-codegen#1438) Co-authored-by: Ula <ulad@users.noreply.github.com> Co-authored-by: Marcin Romaszewicz <mromaszewicz@users.noreply.github.com>
…ers are exist in Iris strict server. (oapi-codegen#1411) Co-authored-by: Marcin Romaszewicz <mromaszewicz@users.noreply.github.com>
…gnature (oapi-codegen#1419) * hotfix: - Bump fiber version to 2.52.0 - Adopted middleware template for fiber to handle new GetReqHeader() method, that has changed signature in fiber 2.50.0 (https://github.com/gofiber/fiber/releases/tag/v2.50.0) * Use latest fiber, and fix go deps The latest Fiber requires Go 1.24, therefore, we have to increase the version in the modules which use it. This is constrained to tests and examples, so it doesn't affect the main repo. Go 1.24 can't compile the version of golang.org/x/tools which we were using, so update that as well. * fix: use valueList[0] for fiber header IsPassThrough case The merge with upstream/main resolved a conflict in the fiber middleware template's header IsPassThrough handler by taking upstream's version, which still used the old single-string `value` variable. This is incorrect because fiber 2.50.0+ changed GetReqHeaders() to return map[string][]string. Fix by using valueList[0] to match the rest of the header handling block. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Tidy up modules This seems to be about the minimal set of changes to have everything build and test cleanly. * fix: add Go 1.24 version guards to Makefiles The internal/test and examples modules now require Go 1.24+ in their go.mod files, but their Makefiles lacked version guards, causing CI failures on Go 1.22 and 1.23. Add execute-if-go-124 guards matching the pattern used by other Go 1.24+ modules. Also bump the strict-server/stdhttp Makefile guard from 1.22 to 1.24. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Alexey Boltunov <apboltunov@mts.ru> Co-authored-by: Marcin Romaszewicz <marcinr@gmail.com> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
* fixed duplicate type names * add typename dedup functions * Fixup: use full-word suffixes and add regression test for issue oapi-codegen#200 - Rename auto-dedup suffixes to use full words: Parameter, Response, RequestBody (instead of Param, Resp, ReqBody) - Add internal/test/issues/issue-200/ with spec, config, generated code, and a compile-time regression test that instantiates every expected type Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Gate duplicate type name resolution behind output-options config flag Add ResolveTypeNameCollisions bool to OutputOptions and the JSON schema. When false (the default), the codegen errors on duplicate type names as before. When true, FixDuplicateTypeNames auto-renames colliding types. Also cleans up ComponentType: removes unused constants, improves doc. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Marcin Romaszewicz <marcinr@gmail.com> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
|
Looks like there may have been an issue updating the PR as it's now showing commits from @mromaszewicz what do you think about - similar to #2211 - we make this a string parameter which is the Go import path for a Right now, this would be i.e. output-options:
std-http-server-router-override: "github.com/julienschmidt/httprouter"? |
|
I synced the latest content from the main branch and rebased to feat/httprouter branch in my fork. Not sure if it caused issues. Should I update it again? |
Co-authored-by: Yuichiro Tsuji <yui.tsuji@mbk-wellness.co.jp>
Signed-off-by: Richard Kosegi <richard.kosegi@gmail.com> Co-authored-by: Marcin Romaszewicz <mromaszewicz@users.noreply.github.com>
@jamietanna What are you going to do with std-http-server-router-override option? I can update it based on the (currently) only specific option value (and the default of course), but it can be more tricky if the other routers are introduced because every router may have different interface and instantiation. |
|
I think it's a fine change in principle, but whenever we see an issue like this, I realize that it can affect every router, every import. There could be a reason to override any import, and the question is, do we want to do it globally, or have a per-template config option. In due time, I'd like to avoid making default decisions at all, and have all the codegen assumptions be data driven, like here: Currently, we gather up the imports we need from the templates in a pretty simple way, I'm thinking that the answer might be to polish that up and create an override map in the config, eg: |
|
hmm, however, that package may not be fully http compatible, so the per-template override makes sense as well. |
I think import-overrides are not needed for this feature because github.com/julienschmidt/httprouter package does not override net/http. It is rather additional package, so can be handled as follows: The only question is how to handle "per-template" solution. If to handle it by a flag What do you recommend? |
|
Would this solve your problem today? In configuration options, we have this: You could download the template used and include alongside your config file and simply add the header and import which you want there. I have a few thoughts here:
|
I removed output-options completely. and refactored the branch to support the feature with the following configuration: The condition to select the right template I mentioned is there but the code is more polished, I think. I also fixed the issues in utils.go and utils_test.go because quite a few tests failed. Let me know if the fixes are OK. I just found that in go.mod in examples should be correct version of: |
Actually.. You are right! It works without any changes in the current release ! All I need to do is to configure this: The only hickup is that additional-imports don't work with aliases as in the main branch but it is not important. Anyway, have a look at my fixes for utils.go and utils_test.go. You have issues there: Thank you ! |
Adding support for github.com/julienschmidt/httprouter in StdHttpServer
I’d like to ask you for review of PR of the feature to add support for github.com/julienschmidt/httprouter in StdHttpServer.
It is implemented in such way that if a new flag use-httprouter-in-std-http-server in CompatibilityOptions is set to true, the updated code is generated.
The tests and examples are included.
Let me know if the way I trigger is correct and suggest a better approach if any.
Thank you,
Roman