Skip to content

v2.4.0: OpenAPI Overlay, improved `import-mapping` functionality, and a whole host of other great things 🚀

Choose a tag to compare

@github-actions github-actions released this 20 Sep 20:35
· 493 commits to refs/heads/main since this release

🎉 Notable changes

Modifying the input OpenAPI Specification, without needing to modify it directly

Prior to oapi-codegen v2.4.0, users wishing to override specific configuration, for instance taking advantage of extensions such as x-go-type would need to modify the OpenAPI specification they are using.

In a lot of cases, this OpenAPI specification would be produced by a different team to the consumers (or even a different company) and so asking them to make changes like this were unreasonable.

This would lead to the API consumers needing to vendor the specification from the producer (which is our recommendation anyway) and then make any number of local changes to the specification to make it generate code that looks reasonable.

However, in the case that a consumer would update their specification, they would likely end up with a number of merge conflicts.

Now, as of oapi-codegen v2.4.0, it is now possible to make changes to the input OpenAPI specification without needing to modify it directly.

This takes advantage of the OpenAPI Overlay specification, which is a stable specification.

We're very excited for y'all to be able to take advantage of this, and to be able to manipulate complex specifications you don't have control over.

Using a single package, with multiple OpenAPI spec for a given package

Since oapi-codegen v2.4.0, it is now possible to split large OpenAPI specifications into the same Go package, using the "self" mapping (denoted by a -) when using Import Mapping.

This is an improvement on the previous model, which would require splitting files across multiple packages.

This should improve the ability to use a multi-file OpenAPI specification.

Reverting a breaking change to Strict servers using text/plain

Changes in #1132 had unintended side effects, and so we have reverted this.

This will be a breaking change to anyone who had pulled in this change, since it landed in v1.13.1.

Minimum version of Go needed for oapi-codegen is now 1.21

Does what it says on the tin.

This was required for a new dependency, and given Go 1.21 is now End-of-Life, this isn't too bad a requirement, without requiring folks unnecessarily bump their minimum supported version higher.

Starting work towards the OpenSSF Best Practices badge

As a means to better understand the compliance of oapi-codegen with OpenSSF's Best Practices guide, we've started work towards the "passing" badge.

OpenSSF Best Practices

This gives us some insight into where we have gaps, and makes it known for our users, too.

PR Builds now have required status checks

Previously, PR builds did not have a required status check.

Although as maintainers we would only merge changes after the CI checks had passed, this now gives us - and you as our users - greater confidence in the stability of the project.

Previously raised PRs - before 2024-09-20 - will need to merge in the latest changes in main before these status checks will pass.

🚀 New features and improvements

🐛 Bug fixes

  • Revert "fix(template): fix strict-interface template to make sure text response content type uses string type (#1132)" (#1773) @jamietanna
  • fix: correctly generate structs and properties for anyOfs (#1178) @daleef-rahman
  • fix(cookies): wrap cookie variables in block scope (#1687) @andremarianiello
  • fix(extensions): use the x-order from next to $ref, if present (#1700) @paulmach
  • fix(oapi-codegen): add missing newline to error when swagger spec load fails (oapi-codegen#1688) (#1690) @willbuckner

📝 Documentation updates

👻 Maintenance

📦 Dependency updates

9 changes
  • chore(deps): update module github.com/golangci/golangci-lint to v1.61.0 (#1753) @renovate
  • fix(deps): update module golang.org/x/text to v0.18.0 (#1640) @renovate
  • chore(deps): update module github.com/golangci/golangci-lint to v1.60.3 (#1735) @renovate
  • chore(deps): update module github.com/golangci/golangci-lint to v1.60.2 (#1731) @renovate
  • fix(deps): update module github.com/getkin/kin-openapi to v0.127.0 (#1711) @renovate
  • chore(deps): update module github.com/golangci/golangci-lint to v1.60.1 (#1725) @renovate
  • fix(deps): update module github.com/getkin/kin-openapi to v0.126.0 (#1689) @renovate
  • fix(deps): update module github.com/getkin/kin-openapi to v0.125.0 (#1659) @renovate
  • chore(deps): update module github.com/golangci/golangci-lint to v1.59.1 (#1658) @renovate

Sponsors

We would like to thank our sponsors for their support during this release.

DevZero logo

Speakeasy logo

Elastic logo

Cybozu logo