Skip to content

v2.0.0: Remove deprecated packages

Compare
Choose a tag to compare
@jamietanna jamietanna released this 31 Oct 20:13

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:

Before (v1.13.0) After (v2.0.0)
Vendored dependency size (MB) 40 6
Direct dependencies 15 6
Indirect dependencies 95 34

Key changes

Full Changelog: 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:

-//go:generate go run github.com/deepmap/oapi-codegen/cmd/oapi-codegen --config=config.yaml spec.yaml
+//go:generate go run github.com/deepmap/oapi-codegen/v2/cmd/oapi-codegen --config=config.yaml spec.yaml

If you're installing the package via go install, you'll need to run the following instead:

-go install github.com/deepmap/oapi-codegen/cmd/oapi-codegen@latest
+go install github.com/deepmap/oapi-codegen/v2/cmd/oapi-codegen@latest

Move pkg/testutil to its own package + remove it

Similar 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 the RequestBuilder.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.