refactor petstore example by mromaszewicz · Pull Request #2277 · oapi-codegen/oapi-codegen

@mromaszewicz @claude

Extract server setup from main() into server/setup.go for each of the 9
variants (chi, gorilla, stdhttp, strict, gin, echo, echo-v5, fiber, iris).
Each setup.go exports a factory function (NewServer, NewEchoServer,
NewFiberApp, or NewIrisApp) that loads the swagger spec, creates the
router, adds validation middleware, and registers handlers — returning
the configured server/app and an error instead of calling os.Exit().

Replace per-variant petstore_test.go files with integration/main.go
programs that start the server on a random port, exercise all CRUD
operations via the shared testclient.Run(), and shut down cleanly. During
this work we discovered that several server variants (gin, fiber, iris,
and others) had server implementations that were not actually compatible
with the generated HTTP client — the prior unit tests sidestepped this
by testing against the handler directly with testutil rather than going
through real HTTP. The shared test client exposed these gaps, which were
fixed in earlier phases of this refactoring.

Each petstore.go is now a thin wrapper: parse flags, call the factory,
set the address, and serve. The old NewGinPetServer, NewFiberPetServer,
and NewIrisPetServer factory functions that lived in the main package
(and called os.Exit on error) have been replaced by proper error-
returning functions in the server package.

Also removes the echo/pkg_codegen_petstore_test.go codegen test and
cleans up the now-unused golang.org/x/lint and testutil dependencies.
README.md updated to document the new structure.

The stdhttp server is no longer its own module, since the examples
module is already on go 1.24, so we don't need to special case it.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>