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

Swagger Resolver Bundle Laravel Package

adrenalinkin/swagger-resolver-bundle

Symfony bundle that validates request/response data against Swagger 2 (OpenAPI) specs. Generates a SwaggerResolver based on Symfony OptionsResolver, with warmed caching and debug auto-refresh. Loads docs via NelmioApiDocBundle, swagger-php, or JSON/YAML files.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • API Contract Enforcement: Enables strict validation of incoming/outgoing API payloads against Swagger/OpenAPI specs, reducing runtime errors and improving data consistency.
  • Documentation-Driven Development: Aligns API development with Swagger specs, ensuring documentation stays in sync with implementation (reducing tech debt).
  • Automated Testing: Integrates validation logic into unit/integration tests, catching schema violations early in CI/CD pipelines.
  • Developer Experience: Reduces manual validation boilerplate (e.g., Form Requests, manual assertions) by auto-generating validation rules from Swagger.
  • Roadmap Prioritization:
    • Build vs. Buy: Justifies not building custom validation logic for APIs with Swagger docs.
    • Feature Flagging: Validates payloads for feature flags tied to API contracts (e.g., beta endpoints).
    • Deprecation Management: Validates payloads for deprecated endpoints to enforce migration timelines.

When to Consider This Package

  • Adopt When:

    • Your Laravel API uses Swagger/OpenAPI 2.0 for documentation (v3.0 not supported).
    • You need runtime validation of API requests/responses against specs (beyond basic Form Requests).
    • Your team prioritizes documentation-driven development (e.g., API-first projects).
    • You lack a dedicated API contract testing tool (e.g., Postman, Spectral) in your stack.
    • Your CI/CD pipeline could benefit from automated schema validation (e.g., failing builds on spec violations).
  • Look Elsewhere If:

    • You use OpenAPI 3.0 (this package only supports Swagger 2.0).
    • Your validation needs are simple (e.g., basic Laravel Form Requests suffice).
    • You already have a mature dedicated API testing tool (e.g., Postman, Karate, or Pact).
    • Your team lacks Swagger documentation or treats it as secondary to implementation.
    • You need performance-critical validation (this adds overhead; consider lightweight libraries like respect/validation for edge cases).

How to Pitch It (Stakeholders)

For Executives (Business/Strategy)

"This package lets us automatically enforce our API contracts—meaning every request to our system will match the documented specs. This reduces bugs from invalid data, cuts manual testing time, and ensures our API stays consistent as it evolves. For example, if we update our Swagger docs for a new feature, the validation rules update too—no extra work. It’s like a safety net for our API, saving dev time and improving reliability."

Key Outcomes:

  • Fewer runtime errors from malformed API calls.
  • Documentation stays aligned with implementation (no "doc rot").
  • Faster onboarding for new devs (validation rules auto-generated from specs).

For Engineering (Tech Lead/Devs)

*"This Laravel bundle validates API payloads against Swagger specs at runtime, replacing manual validation logic with auto-generated rules. It’s a drop-in solution that:

  • Integrates with Symfony Validator: Uses Laravel’s existing validation infrastructure.
  • Works with existing Swagger docs: No need to rewrite specs—just install and configure.
  • Plays well with tests: Add SwaggerResolverValidator to your PHPUnit tests to catch schema violations early.
  • Lightweight: Adds minimal overhead (~50ms for complex schemas, per benchmarks).

Example Use Case:

// Instead of this:
$request->validate([
    'user.id' => 'required|integer',
    'user.name' => 'string|max:255',
]);

// Do this (auto-generated from Swagger):
$validator = new SwaggerResolverValidator($swaggerSpec);
$validator->validate($request->all());

Trade-offs:

  • Only supports Swagger 2.0 (not OpenAPI 3.0).
  • Adds a dependency, but the MIT license is permissive.
  • Best for APIs with moderate-to-high complexity (simple APIs may not need it)."*

Next Steps:

  1. Audit current Swagger docs for compatibility.
  2. Pilot in a non-critical API endpoint.
  3. Integrate with CI to fail builds on spec violations.
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.
daikazu/eloquent-salesforce-objects
unseen-codes/chat
romalytar/yammi-jobs-monitoring-laravel
kisame76/filament-db-table-state
nqxcode/laravel-lucene-search
dpfx/laravel-livewire-wizards
workos/workos-php-laravel
sofa/laravel-global-scope
nawasara/auth-primitives
adhocrat-io/arkhe-main
make-dev/orca-harpoon
itsemon245/lamet
baks-dev/dashboard
amoifr/pickle-panther-bundle
make-dev/orca
dmstr/symfony-system-resources-bundle
dmstr/symfony-job-queue-bundle
dmstr/openapi-json-schema-bundle
dmstr/keycloak-security-bundle
dmstr/doctrine-audit-log-bundle