Update module github.com/deepmap/oapi-codegen to v2 #214
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR contains the following updates:
v1.16.2
->v2.1.0
Release Notes
deepmap/oapi-codegen (github.com/deepmap/oapi-codegen)
v2.1.0
: : Nullable, external reference improvements, x-order, and many more!Compare Source
🔊 Notable features
Nullable
typesIt's possible that you want to be able to determine whether a field isn't sent, is sent as
null
or has a value.For instance, if you had the following OpenAPI property:
The current behaviour in oapi-codegen is to generate:
However, you lose the ability to understand the three cases, as there's no way to distinguish two of the types from each other:
S.Field == nil
)null
? (Can be checked withS.Field == nil
)S.Field != nil && *S.Field == "123"
)Therefore, as requested in #1039, this is now possible to represent with the
nullable.Nullable
type from our new library, oapi-codegen/nullable.If you configure your generator's Output Options as so:
You will now receive the following output:
Note that this is opt-in only, due to it being a break in existing signatures and behaviour.
You can find out more about how this works in a blog post with further details.
External references are now handled better
A big change has come in which handling of external references (also called import mappings) is much more resilient and predictable for generated code.
This allows cases where multiple files referencing each other (for instance if you've split your API across multiple files, and join them using
$ref
s) now correctly generate code.There are a few cases that won't be covered, that we'll complete in https://github.com/deepmap/oapi-codegen/issues/1440 but until then, it hopefully should work better.
Thank you to Ejendomstorvet for sponsoring this work.
🚀 New features and improvements
nullable.Nullable
for nullable properties (#1404) @sonasingh46IsMediaTypeJson
(#1386) @jamietanna.Required
toBindStyledParameterWithLocation
andBindStyledParameter
(#1315) @renom🐛 Bug fixes
os.Exit(1)
only frommain()
(#1398) @alexandear.Required
toBindStyledParameterWithLocation
andBindStyledParameter
(#1315) @renom📝 Documentation updates
import-mapping
with URLs (#1428) @jamietanna👻 Maintenance
📦 Dependency updates
New Contributors
v2.0.0
: : Remove deprecated packagesCompare Source
As announced in oapi-codegen v2 is coming, this is a release to perform some cleanup, drastically reducing the dependency graph for users of the library, and migrating to multi-repo middleware and utility packages that can evolve separately to the code generator itself.
There's more details in https://www.jvt.me/posts/2023/10/23/oapi-codegen-v2-decrease/ in the exact benefits ??, but the key metrics you will be interested in seeing are:
Key changes
Full Changelog: oapi-codegen/oapi-codegen@v1.16.2...v2.0.0
As a consumer, for the most part you shouldn't have much to do, as if you've been using oapi-codegen v1.15.0 or later, you should be using the new packages.
If you use this as a library or execute it as part of
go run
you will need to update module import paths:If you're installing the package via
go install
, you'll need to run the following instead:Move
pkg/testutil
to its own package + remove itSimilar to the below changes, we've moved
pkg/testutil
to its own package, and removed it from the codebase.The changes for you as a consumer can be seen here.
This is almost a drop in replacement, the key difference is that there is no longer a
RequestBuilder.Go
method, as it is replaced by theRequestBuilder.GoWithHTTPHandler.
Remove deprecated packages:
For the packages:
pkg/chi-middleware
pkg/fiber-middleware
pkg/gin-middleware
pkg/middleware
pkg/runtime
pkg/types
These have been deprecated because they are now hosted as individual modules at https://github.com/oapi-codegen/. Doing so allows for their dependencies to be separated from each other, so your transitive module dependencies decrease. Any code which you generate using v1.15.0 will already refer to these modules in their new location.
Configuration
📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR has been generated by Mend Renovate. View repository job log here.