Skip to content

refactor(registry): isolate scanned metadata to the selected application #381

Description

@yeongseon

Context

Architecture follow-up (not a P1; no failure in the common single-app layout).

@openapi registers into a process-wide registry at import time, and scan_endpoint_metadata() still writes into that global registry. So:

azure-functions-openapi generate --app my_module:app_a

imports my_module (registering @openapi metadata from every app defined there) and then scans app_a. The effective spec is closer to "all @openapi imported from module + metadata discovered from app_a" than to "spec for app_a". For a module defining both app_a and app_b, selecting app_a can still leak app_b's decorator metadata into the output.

#324 already introduced registry injection (registry= on generate_openapi_spec / collect_spec_warnings, with _collect_* falling back to _default_registry), so the plumbing exists to finish per-app isolation.

Acceptance Checklist

  • Support scan_endpoint_metadata(app, registry=...) writing discovered operations into an injected/isolated registry rather than the global one.
  • Provide a path for the CLI --app module:app_x to build a spec scoped to operations belonging to the selected app.
  • Tests: a module with two apps, each with @openapi handlers, yields a spec containing only the selected app's operations.
  • Preserve backward compatibility for the common single-app function_app.py layout (global registry default).
  • Coverage stays >= 95%.

Out of scope

  • Removing the global registry entirely.
  • The empty-discovery warning wording (tracked separately).

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions