Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Openapi Doc Bundle Laravel Package

chamber-orchestra/openapi-doc-bundle

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • ADR Pattern Alignment: The bundle is purpose-built for Action-Domain-Responder (ADR) architectures, where endpoints are invokable classes (e.g., #[Route] + #[Operation]). This aligns well with modern Symfony/Doctrine-based APIs but may require refactoring for traditional controller-based apps.
  • OpenAPI-Centric: Generates OpenAPI 3.0.1 dynamically, reducing manual documentation drift. Ideal for teams prioritizing API-first design or Swagger UI integration.
  • Parser Extensibility: Modular parser system (OperationParserInterface, ComponentParserInterface) allows customization for niche use cases (e.g., GraphQL-like schemas, custom DTOs).
  • Symfony Native: Leverages Symfony’s Dependency Injection, Console, and Attribute systems, minimizing integration friction.

Integration Feasibility

  • Low-Coupling: Bundle operates via attribute scanning and console commands, avoiding runtime hooks or middleware. No core Symfony modifications required.
  • PHP 8.5+ Constraint: May block legacy projects but is reasonable for new greenfield initiatives.
  • Symfony 8.x Dependency: Requires Symfony 8.x components (e.g., symfony/attribute, symfony/console). Compatible with Symfony 8+ or standalone Symfony apps.

Technical Risk

Risk Area Severity Mitigation Strategy
Parser Gaps Medium Extend parsers for unsupported types (e.g., custom validators, nested forms).
Performance Low Recursive scanning of src/ may slow CI/CD; cache OperationRegistry in production.
Attribute Conflicts Medium Ensure #[Operation]/#[Route] are exclusive to ADR actions (avoid mixing with controllers).
Schema Merging Low proto.yaml conflicts require manual resolution; document merge precedence rules.
PHP 8.5+ Dependency High Blocking for older stacks; evaluate polyfills or fork.

Key Questions

  1. ADR Adoption:
    • Is the team already using ADR (e.g., #[Route] on invokable classes)? If not, what’s the migration effort?
  2. Parser Coverage:
    • Does the existing parser set (FormParser, ViewParser, etc.) cover all DTOs/responses in the codebase? If not, what’s the backlog for custom parsers?
  3. CI/CD Impact:
    • How will OpenAPI generation be triggered (e.g., post-deploy, pre-release)? Will it block builds on failures?
  4. Tooling Ecosystem:
    • Is OpenAPI used for contract testing (e.g., Pact), client SDKs, or Swagger UI? If so, how will this bundle integrate with those workflows?
  5. Schema Evolution:
    • How are breaking changes to the API documented and versioned? Will doc-version in the CLI suffice, or is a more robust strategy (e.g., semantic versioning in proto.yaml) needed?

Integration Approach

Stack Fit

  • Symfony 8+: Native integration via bundles, attributes, and console commands.
  • PHP 8.5+: Required for attribute syntax (#[Route]) and type system features.
  • ADR Pattern: Optimized for Symfony UX or API Platform-style architectures. Less ideal for:
    • Traditional controller-based apps (would need refactoring).
    • Non-Symfony PHP apps (would require porting the scanner/parser logic).
  • OpenAPI Tools:
    • Swagger UI: Directly consume generated doc.yaml.
    • OpenAPI Generator: Use doc.yaml to generate SDKs/docs.
    • Pact/Contract Testing: Validate API contracts against the generated spec.

Migration Path

  1. Phase 1: Pilot Scope

    • Select 1–2 ADR modules to annotate with #[Operation]/#[Route].
    • Test generation with php bin/console openapi-doc:generate.
    • Validate output against manual specs (e.g., Swagger Editor).
  2. Phase 2: Parser Customization

    • Extend parsers for unsupported types (e.g., custom DTOs, GraphQL inputs).
    • Example: Implement a GraphQLParser for #[GraphQLType] classes.
  3. Phase 3: CI/CD Integration

    • Add generation to post-build or pre-release pipelines.
    • Example GitHub Actions snippet:
      - name: Generate OpenAPI
        run: php bin/console openapi-doc:generate --output=public/api-doc.yaml
      
    • Optionally, fail builds on OpenAPI linting (e.g., spectral lint).
  4. Phase 4: Tooling Hooks

    • Integrate with API testing (e.g., Pact, Postman).
    • Generate client SDKs from doc.yaml (e.g., OpenAPI Generator).

Compatibility

Component Compatibility Notes
Symfony Controllers ❌ Not supported; requires ADR refactor.
API Platform ✅ Partial support; may need #[Operation] overrides for custom logic.
Doctrine Entities ✅ Supported via ObjectParser (public properties).
Symfony Forms ✅ Supported via FormParser (maps FormTypeInterface to OpenAPI schemas).
Custom DTOs ⚠️ Requires custom ComponentParser (e.g., for @Assert constraints).
GraphQL ❌ No native support; would need custom parser.
Legacy PHP (<8.5) ❌ Blocking; consider polyfills or fork.

Sequencing

  1. Pre-Integration:
    • Audit codebase for #[Route]/#[Operation] usage.
    • Identify gaps in parser coverage (e.g., unsupported DTOs).
  2. Initial Rollout:
    • Start with non-critical endpoints to validate generation quality.
    • Gradually expand to core API modules.
  3. Post-Integration:
    • Automate OpenAPI in CI/CD (e.g., publish to S3, validate with Spectral).
    • Train team on attribute conventions (#[Property], #[Security]).

Operational Impact

Maintenance

  • Bundle Updates:
    • Monitor for Symfony 8.x compatibility changes.
    • Extend parsers as new PHP attributes or Symfony features emerge (e.g., #[IsGranted] support).
  • Schema Drift:
    • Automated checks: Use spectral or openapi-linter to catch breaking changes.
    • Versioning: Leverage doc-version CLI flag or embed version in proto.yaml.
  • Parser Debugging:
    • Add logging for failed parses (e.g., DescriberException).
    • Example: Log unsupported types to a missing-parsers.log.

Support

  • Troubleshooting:
    • Common Issues:
      • Missing #[Operation] → No OpenAPI entry for the route.
      • Unparsed DTOs → Extend ObjectParser or add a custom parser.
      • Schema conflicts → Review proto.yaml merge precedence.
    • Debugging Commands:
      # Dry-run with verbose output
      php bin/console openapi-doc:generate --verbose
      # Inspect registries
      php bin/console debug:container ChamberOrchestra\OpenApiDocBundle\Registry\OperationRegistry
      
  • Documentation:
    • Add internal runbook for:
      • Parser extension workflow.
      • Handling DescriberException cases.
      • Customizing proto.yaml.

Scaling

  • Performance:
    • Registry Caching: Cache OperationRegistry/ComponentRegistry in production (e.g., Redis) to avoid rescanning on every request.
    • Incremental Generation: Scan only modified files (e.g., via Git diff hooks).
  • Large Codebases:
    • Exclude Paths: Use --src CLI flag to limit scanning (e.g., exclude tests/).
    • Parallel Parsing: Extend Locator to use parallel file scanning (PHP 8.1+ SplFileInfo + pthreads).
  • Multi-Environment:
    • Environment-Specific Docs: Use proto.yaml to override paths/responses per environment (e.g., dev.proto.yaml).

Failure Modes

Failure Scenario Impact Mitigation
Parser Crashes Broken OpenAPI output Add @try-catch in parsers; log errors.
Attribute Misconfiguration Missing endpoints in docs L
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle