You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(ci): validate OpenAPI spec by generating and building Go client (#2078)
This PR follows up on #2000.
**What**
Adds automated validation of our OpenAPI specification by generating a
Go client from the spec and verifying that the generated code compiles
successfully.
**Why**
- Fast feedback loop: Catch OpenAPI spec issues immediately by
validating that client generation and compilation succeed.
- Spec compliance: Ensure our OpenAPI spec adheres to the standard by
using it in a real-world scenario (client generation + build).
- Foundation for multi-language clients: While the generated code is
currently discarded after validation, this establishes the
infrastructure to generate and publish clients for multiple languages
(e.g., TypeScript, Python) in the future.
This approach provides validation beyond just schema checking - if the
generated Go client builds successfully, we can be confident the spec is
both valid and practical to use.
**Folder structure**
The repository structure follows these conventions:
- `codegen/` - Contains only generated code (files, folders, etc.) and
should never be modified manually.
- `oapi-codegen-go/` - Follows the naming pattern [tool-name]-[language]
where:
- `oapi-codegen` is the code generation tool.
- `go` is the target language.
This convention makes it straightforward to add support for additional
tools and languages in the future (e.g., openapi-generator-typescript,
oapi-codegen-python).
**Examples**
- This is an
[example](https://github.com/apify/apify-docs/actions/runs/19227338449/job/54957493226?pr=2078)
of successfull action.
- This is an
[example](https://github.com/apify/apify-docs/actions/runs/19227226704/job/54957143384?pr=2078)
of failed action (can generate Go client but compilation failed due to
invalid OpenAPI spec).
**Refs**
- #1996
- #2057
<!-- CURSOR_SUMMARY -->
> [!NOTE]
> Adds a CI job that builds the OpenAPI spec, generates a Go client via
oapi-codegen, and compiles it, with accompanying codegen config and
ignores.
>
> - **CI/CD (`.github/workflows/openapi.yaml`)**:
> - **New job `validate-go-codegen`**: Builds OpenAPI YAML, installs
`oapi-codegen`, generates Go client, and builds it with Go 1.25.
> - Update existing build to Node.js `24` and run `redoc:test`.
> - **Go client codegen setup**:
> - Add `codegen/oapi-codegen-go/go.mod` declaring tool and deps.
> - Add `codegen/oapi-codegen-go/oapi-codegen.yaml` configuring
client/model generation to `generated/client.gen.go`.
> - **Repo housekeeping**:
> - Update `.gitignore` to exclude `codegen/*/generated/` and
`codegen/*/go.sum`.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
e657bac. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
0 commit comments