Skip to content

fix(api): propagate flat-schema hoisting option across spec output APIs - #382

Merged
yeongseon merged 2 commits into
mainfrom
fix/378-propagate-hoist-flat-schemas
Aug 10, 2026
Merged

fix(api): propagate flat-schema hoisting option across spec output APIs#382
yeongseon merged 2 commits into
mainfrom
fix/378-propagate-hoist-flat-schemas

Conversation

@yeongseon

Copy link
Copy Markdown
Owner

Summary

  • Adds hoist_flat_schemas: bool = False to get_openapi_json, get_openapi_yaml, and generate_openapi_report, forwarding it to generate_openapi_spec so the opt-in flat-schema hoisting from feat(spec): opt-in hoisting of flat schemas into components (#375) #377 is reachable through every public output API (previously only generate_openapi_spec accepted it).
  • Documents the new parameter on each wrapper; generate_openapi_report's "Parameters mirror generate_openapi_spec" docstring is accurate again.
  • Tests: each wrapper hoists into components.schemas when True and preserves the current inline shape when False; updates existing call-assertion mocks to include the new forwarded kwarg.

Acceptance

  • Option added + forwarded on json/yaml/report
  • Docstrings accurate
  • Tests for each wrapper (opt-in + default)
  • make check-all green (coverage 96.26%)

Closes #378

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR exposes the opt-in hoist_flat_schemas flag (added in #377) through all public spec-output wrapper APIs (get_openapi_json, get_openapi_yaml, generate_openapi_report) by adding the parameter, forwarding it into generate_openapi_spec, and extending tests to cover both default and opted-in behavior.

Changes:

  • Add hoist_flat_schemas: bool = False to JSON/YAML/report wrapper APIs and forward it to generate_openapi_spec.
  • Update wrapper docstrings to mention the new option.
  • Extend tests to assert wrapper behavior for both hoist_flat_schemas=False (default) and True, and update existing mock call assertions.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
src/azure_functions_openapi/spec.py Adds and forwards hoist_flat_schemas through the wrapper APIs and updates wrapper docs.
tests/test_openapi_enhanced.py Updates wrapper call-assertion mocks to include the newly forwarded kwarg.
tests/test_hoist_flat.py Adds wrapper-level tests to ensure the hoist flag propagates through JSON/YAML/report outputs.
Suppressed comments (2)

src/azure_functions_openapi/spec.py:739

  • Same positional-argument compatibility issue as get_openapi_json: inserting hoist_flat_schemas before registry shifts the last positional argument away from the registry parameter and can break existing positional callers.
    security_schemes: dict[str, dict[str, Any]] | None = None,
    route_prefix: str = DEFAULT_ROUTE_PREFIX,
    strict: bool = False,
    hoist_flat_schemas: bool = False,
    registry: OpenAPIRegistry | None = None,
) -> str:

src/azure_functions_openapi/spec.py:755

  • This docstring also omits the registry parameter even though it is part of the public signature, which makes it unclear how to generate YAML from an injected registry.
        description: Description for the OpenAPI info object
        security_schemes: Security scheme definitions for components.securitySchemes.
        route_prefix: HTTP route prefix from ``host.json``
            (``extensions.http.routePrefix``). Defaults to ``"/api"``. Pass
            ``""`` for hosts that disable the prefix or a custom value such
            as ``"/v1"``.
        strict: When ``True``, raise on any registry entry processing failure.
        hoist_flat_schemas: When ``True`` (opt-in, #375), structured flat
            schemas are promoted into ``components.schemas``. Defaults to
            ``False`` to preserve the existing generated spec shape.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines 683 to 688
security_schemes: dict[str, dict[str, Any]] | None = None,
route_prefix: str = DEFAULT_ROUTE_PREFIX,
strict: bool = False,
hoist_flat_schemas: bool = False,
registry: OpenAPIRegistry | None = None,
) -> str:
Comment on lines 696 to +704
security_schemes: Security scheme definitions for components.securitySchemes.
route_prefix: HTTP route prefix from ``host.json``
(``extensions.http.routePrefix``). Defaults to ``"/api"``. Pass
``""`` for hosts that disable the prefix or a custom value such
as ``"/v1"``.
strict: When ``True``, raise on any registry entry processing failure.
hoist_flat_schemas: When ``True`` (opt-in, #375), structured flat
schemas are promoted into ``components.schemas``. Defaults to
``False`` to preserve the existing generated spec shape.
Comment thread src/azure_functions_openapi/spec.py Outdated
Comment on lines 917 to 922
security_schemes: dict[str, dict[str, Any]] | None = None,
route_prefix: str = DEFAULT_ROUTE_PREFIX,
strict: bool = False,
hoist_flat_schemas: bool = False,
registry: OpenAPIRegistry | None = None,
) -> SpecReport:
Keep hoist_flat_schemas as the trailing parameter (after registry) in
get_openapi_json/get_openapi_yaml/generate_openapi_report so positional
callers passing a registry are unaffected and the signatures match
generate_openapi_spec. Document the registry parameter.
@yeongseon

Copy link
Copy Markdown
Owner Author

Addressed Copilot review: reordered hoist_flat_schemas to trail registry in get_openapi_json/get_openapi_yaml/generate_openapi_report so positional registry callers are unaffected and the wrappers match generate_openapi_spec's parameter order. Also documented the registry parameter in the JSON/YAML docstrings. make check-all green.

@yeongseon
yeongseon merged commit a1644d4 into main Aug 10, 2026
14 checks passed
@yeongseon
yeongseon deleted the fix/378-propagate-hoist-flat-schemas branch August 10, 2026 10:58
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.

fix(api): propagate flat-schema hoisting option across spec output APIs

3 participants