Skip to content

Conversation

@leseb
Copy link
Collaborator

@leseb leseb commented Oct 28, 2025

What does this PR do?

This replaces the legacy "pyopenapi + strong_typing" pipeline with a FastAPI-backed generator that has an explicit schema registry inside llama_stack_api. The key changes:

  1. New generator architecture. FastAPI now builds the OpenAPI schema directly from the real routes, while helper modules (schema_collection, endpoints, schema_transforms, etc.) post-process the result. The old pyopenapi stack and its strong_typing helpers are removed entirely, so we no longer rely on fragile AST analysis or top-level import side effects.

  2. Schema registry in llama_stack_api. schema_utils.py keeps a SchemaInfo record for every @json_schema_type, register_schema, and dynamically created request model. The OpenAPI generator and other tooling query this registry instead of scanning the package tree, producing deterministic names (e.g., {MethodName}Request), capturing all optional/nullable fields, and making schema discovery testable. A new unit test covers the registry behavior.

  3. Regenerated specs + CI alignment. All docs/Stainless specs are regenerated from the new pipeline, so optional/nullable fields now match reality (expect the API Conformance workflow to report breaking changes—this PR establishes the new baseline). The workflow itself is back to the stock oasdiff invocation so future regressions surface normally.

Conformance will be RED on this PR; we choose to accept the deviations.

Test Plan

  • uv run pytest tests/unit/server/test_schema_registry.py
  • uv run python -m scripts.openapi_generator.main docs/static

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 28, 2025
@ashwinb
Copy link
Contributor

ashwinb commented Oct 28, 2025

This is amazing, thanks for it. It will reduce a lot of random complexity in the openapi generator.

@ashwinb
Copy link
Contributor

ashwinb commented Oct 28, 2025

The only comment I have is the removal of json_schema_type and not keeping some equivalent marker annotation.

In the current implementation, we use this annotations implicitly to generate a top-level "component schema" in the YAML. If we make every BaseModel be a top-level component schema, the yaml becomes harder to consume in a few places due to annoying indirection. Simple things which are just used once in the API are often best situated as inline objects
(so no $ref pointing to something else but just an inline type: object)

@leseb leseb force-pushed the rm-strong-typing-openapi-gen branch 4 times, most recently from cdbce6c to e339650 Compare October 30, 2025 13:14
leseb added a commit to leseb/llama-stack that referenced this pull request Oct 30, 2025
While working on llamastack#3944 I
realized that the batches API wasn't generated.

Signed-off-by: Sébastien Han <[email protected]>
ashwinb pushed a commit that referenced this pull request Oct 30, 2025
# What does this PR do?

While working on #3944 I
realized that the batches API wasn't generated.

Signed-off-by: Sébastien Han <[email protected]>
@leseb leseb force-pushed the rm-strong-typing-openapi-gen branch from e339650 to dd67339 Compare October 30, 2025 14:27
cdoern pushed a commit to cdoern/llama-stack that referenced this pull request Oct 30, 2025
While working on llamastack#3944 I
realized that the batches API wasn't generated.

Signed-off-by: Sébastien Han <[email protected]>
Signed-off-by: Charlie Doern <[email protected]>
@leseb leseb marked this pull request as draft October 30, 2025 16:56
@leseb leseb force-pushed the rm-strong-typing-openapi-gen branch from fe54754 to f59b570 Compare October 31, 2025 08:41
@leseb leseb force-pushed the rm-strong-typing-openapi-gen branch 3 times, most recently from a13512a to b80fdf1 Compare November 5, 2025 16:20
@leseb leseb force-pushed the rm-strong-typing-openapi-gen branch from c6d7196 to 2785819 Compare November 14, 2025 09:42
leseb and others added 14 commits November 14, 2025 11:01
Signed-off-by: Sébastien Han <[email protected]>
This reverts commit 8427798.

Signed-off-by: Sébastien Han <[email protected]>
Signed-off-by: Sébastien Han <[email protected]>
use paginated endpoint for example and mark input_items.list as
non-paginated

Signed-off-by: Sébastien Han <[email protected]>
delete /v1/scoring-functions/{scoring_fn_id} exists in the OpenAPI spec,
       but isn't specified in the Stainless config, so code will not be
       generated for it.
delete /v1alpha/eval/benchmarks/{benchmark_id} exists in the OpenAPI
spec, but isn't specified in the Stainless config, so code will not be
generated for it

Signed-off-by: Sébastien Han <[email protected]>
This reverts commit 9a36669.

Signed-off-by: Sébastien Han <[email protected]>
Signed-off-by: Sébastien Han <[email protected]>
@ashwinb ashwinb changed the title chore: use Pydantic to generate OpenAPI schema feat(openapi): switch to fastapi-based generator Nov 14, 2025
@ashwinb
Copy link
Contributor

ashwinb commented Nov 14, 2025

This is the Stainless diff (after I resolved some modify-delete conflicts)

https://github.com/stainless-sdks/llama-stack-client-python/compare/next...preview/rm-strong-typing-openapi-gen

It appears to be clean and nice, still reviewing.

@ashwinb
Copy link
Contributor

ashwinb commented Nov 14, 2025

It is looking quite good. Sadly we really cannot run an e2e test because the preview branches are not mirrored into the destination (production) repository (llamastack/llama-stack-client-python); they are only in the staging repositories (cc @dgellow). As a result, we cannot use our CI on the production repository to test.

I am landing this now, will check build status once Stainless updates the production repository.

CI on llamastack/llama-stack-client-python#302 is green!

@ashwinb ashwinb merged commit 97f535c into llamastack:main Nov 14, 2025
81 of 82 checks passed
@leseb leseb deleted the rm-strong-typing-openapi-gen branch November 17, 2025 07:54
leseb added a commit to leseb/llama-stack that referenced this pull request Nov 17, 2025
It was referencing strong_typing which was removed in
llamastack#3944

Signed-off-by: Sébastien Han <[email protected]>
@leseb leseb mentioned this pull request Nov 17, 2025
leseb added a commit that referenced this pull request Nov 17, 2025
# What does this PR do?

It was referencing strong_typing which was removed in
#3944

## Test Plan

New CI build test.

Signed-off-by: Sébastien Han <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants