Skip to content

feat(api): generate REST models from pinned OpenAPI spec - #690

Open
Abhijeet Prasad (AbhiPrasad) wants to merge 1 commit into
mainfrom
abhi-openapi
Open

feat(api): generate REST models from pinned OpenAPI spec#690
Abhijeet Prasad (AbhiPrasad) wants to merge 1 commit into
mainfrom
abhi-openapi

Conversation

@AbhiPrasad

Copy link
Copy Markdown
Member

AI Summary

Implements step 1 of #683.

This does not add public REST methods. It adds two type namespaces:

  • braintrust.api._generated.models: private generated TypedDicts and type aliases
  • braintrust.api.types: the public REST type namespace, empty until resource APIs are added

The generated module is derived from committed inputs:

    openapi/spec.json + openapi/config.json
                    |
                    v
               validation
                    |
                    v
        datamodel-code-generator + Ruff
                    |
                    v
    braintrust/api/_generated/models.py

make generate-api-client runs that pipeline. make check-api-client-codegen runs it in a temporary directory and fails if the committed output differs, so CI catches hand edits and stale models. Builds use the committed models and do not run code generation.

Spec updates are manual for now: update the pinned upstream commit and spec SHA-256 in openapi/config.json, fetch the snapshot, regenerate, and review the spec and model diffs together. Automated update PRs are deferred to step 7.

Implements step 1 of #683.

This does not add public REST methods. It adds two type namespaces:

- `braintrust.api._generated.models`: private generated `TypedDict`s and type aliases
- `braintrust.api.types`: the public REST type namespace, empty until resource APIs are added

The generated module is derived from committed inputs:

    openapi/spec.json + openapi/config.json
                    |
                    v
               validation
                    |
                    v
        datamodel-code-generator + Ruff
                    |
                    v
    braintrust/api/_generated/models.py

`make generate-api-client` runs that pipeline. `make check-api-client-codegen`
runs it in a temporary directory and fails if the committed output differs, so
CI catches hand edits and stale models. Builds use the committed models and do
not run code generation.

Spec updates are manual for now: update the pinned upstream commit and spec
SHA-256 in `openapi/config.json`, fetch the snapshot, regenerate, and review the
spec and model diffs together. Automated update PRs are deferred to step 7.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants