Skip to content

Conversation

@dependabot
Copy link

@dependabot dependabot bot commented on behalf of github Sep 22, 2025

Bumps github.com/oapi-codegen/oapi-codegen/v2 from 2.4.1 to 2.5.0.

Release notes

Sourced from github.com/oapi-codegen/oapi-codegen/v2's releases.

v2.5.0: No more optional pointers (optionally), omitzero, better control over initialisms, and so much more!

v2.5.0: No more optional pointers (optionally)!

🎉 Notable changes

Begone optional pointers! (optionally)

One of the key things oapi-codegen does is to use an "optional pointer", following idiomatic Go practices, to indicate that a field/type is optional.

This can be tuned on a per-field basis, using the x-go-type-skip-optional-pointer extension, but it can be a bit repetitive, or can be more complex when using an OpenAPI Overlay.

As of oapi-codegen v2.5.0, this can be tuned in two specific ways, via the following Output Options:

  • prefer-skip-optional-pointer: a global default that you do not want the "optional pointer" generated. Optional fields will not have an "optional pointer", and will have an omitempty JSON tag
  • prefer-skip-optional-pointer-with-omitzero: when used in conjunction with prefer-skip-optional-pointer, any optional fields are generated with an omitzero JSON tag. Requires Go 1.24+

In both cases, there is control on a per-field level to set x-go-type-skip-optional-pointer: false or x-omitzero: false to undo these to field(s).

[!NOTE] The default is not changing.

We take care to avoid breaking changes so this is, as many changes, an opt-in.

See Globally skipping the "optional pointer" for more details.

Generating omitzero JSON tags, with x-omitzero

Related to the above functionality, it is possible to define the OpenAPI extension x-omitzero on fields to generate the omitzero JSON tag, based on the (now not-so-new) Go 1.24 release.

Thanks to @​lzap for the contribution 🚀

[!NOTE] oapi-codegen does not currently validate the Go version that the module it's generating code for.

This could lead to the omitzero JSON tag being generated, but not being actually usable.

Ensure that you're using a Go 1.24+ version, and that your go directive (for source compatibility) is go 1.24 or i.e. go 1.24.1

Using OpenAPI 3.1 with oapi-codegen

There's some promising behind-the-scenes discussions with may lead to OpenAPI 3.1 support (#373) coming in the not-too-distant future 👀

In the meantime, Jamie (one of the Core Maintainers) has written a blog post about how to use oapi-codegen with OpenAPI 3.1 specs (by downgrading them to OpenAPI 3.0).

Defining your own initialisms

As a means to define your own custom initialisms, it's possible to use the additional-initialisms Output Option.

Thanks @​micaelmalta for the contribution 🚀

... (truncated)

Commits
  • 13eea66 docs(additional-initialisms): add a usage example
  • 8e7938e docs(client): document known issue with duplicated Response models
  • f4a544e fixup! feat(output-options): allow using omitzero with `prefer-skip-optiona...
  • 22ccd05 docs(output-options): document how to skip the "optional pointer"
  • b72bb2a feat(output-options): allow using omitzero with prefer-skip-optional-pointer
  • c6493ab fix(deps): update module github.com/getkin/kin-openapi to v0.132.0
  • 364997d fix(deps): update module github.com/getkin/kin-openapi to v0.131.0 [security]
  • ac39953 chore(deps): update module github.com/golangci/golangci-lint to v2.2.2
  • 7688c8d feat(x-deprecated-reason): add default deprecation message
  • 5369d1f chore(examples): add a deprecated field without any reason
  • Additional commits viewable in compare view

Dependabot compatibility score

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


Dependabot commands and options

You can trigger Dependabot actions by commenting on this PR:

  • @dependabot rebase will rebase this PR
  • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
  • @dependabot merge will merge this PR after your CI passes on it
  • @dependabot squash and merge will squash and merge this PR after your CI passes on it
  • @dependabot cancel merge will cancel a previously requested merge and block automerging
  • @dependabot reopen will reopen this PR if it is closed
  • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
  • @dependabot show <dependency name> ignore conditions will show all of the ignore conditions of the specified dependency
  • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)

@dependabot dependabot bot added dependencies Pull requests that update a dependency file go Pull requests that update go code labels Sep 22, 2025
@openshift-ci openshift-ci bot requested review from lberk and matzew September 22, 2025 13:44
@openshift-ci
Copy link

openshift-ci bot commented Sep 22, 2025

Hi @dependabot[bot]. Thanks for your PR.

I'm waiting for a openshift-knative member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@aliok
Copy link

aliok commented Sep 26, 2025

/lgtm
/approve

@openshift-ci
Copy link

openshift-ci bot commented Sep 26, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: aliok, dependabot[bot]

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@dependabot dependabot bot force-pushed the dependabot/go_modules/release-v1.19/github.com/oapi-codegen/oapi-codegen/v2-2.5.0 branch from 16a2d82 to d67a8a8 Compare September 26, 2025 07:57
@openshift-ci openshift-ci bot removed the lgtm label Sep 26, 2025
@openshift-ci
Copy link

openshift-ci bot commented Sep 26, 2025

New changes are detected. LGTM label has been removed.

Bumps [github.com/oapi-codegen/oapi-codegen/v2](https://github.com/oapi-codegen/oapi-codegen) from 2.4.1 to 2.5.0.
- [Release notes](https://github.com/oapi-codegen/oapi-codegen/releases)
- [Commits](oapi-codegen/oapi-codegen@v2.4.1...v2.5.0)

---
updated-dependencies:
- dependency-name: github.com/oapi-codegen/oapi-codegen/v2
  dependency-version: 2.5.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
@dependabot dependabot bot force-pushed the dependabot/go_modules/release-v1.19/github.com/oapi-codegen/oapi-codegen/v2-2.5.0 branch from d67a8a8 to 9a7a7de Compare September 26, 2025 08:29
@dependabot @github
Copy link
Author

dependabot bot commented on behalf of github Nov 3, 2025

Superseded by #944.

@dependabot dependabot bot closed this Nov 3, 2025
@dependabot dependabot bot deleted the dependabot/go_modules/release-v1.19/github.com/oapi-codegen/oapi-codegen/v2-2.5.0 branch November 3, 2025 13:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved dependencies Pull requests that update a dependency file go Pull requests that update go code needs-ok-to-test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants