yoanm/symfony-jsonrpc-http-server-swagger-doc
This bundle is an add-on to yoanm/symfony-jsonrpc-http-server. You need a working JSON-RPC endpoint first; the doc bundle then introspects the registered methods and exposes a Swagger 2.0 document for them.
Minimal setup:
composer require yoanm/symfony-jsonrpc-http-server yoanm/symfony-jsonrpc-http-server-swagger-doc
config/bundles.php).# config/packages/yoanm_jsonrpc_http_server_swagger_doc.yaml
yoanm_jsonrpc_http_server_swagger_doc:
base_document:
info:
title: 'Acme JSON-RPC API'
version: '1.0.0'
host: 'api.example.test'
basePath: '/'
schemes: ['https']
Confirm the exact key names with bin/console debug:config yoanm_jsonrpc_http_server_swagger_doc; the bundle's DependencyInjection/Configuration.php is the authoritative reference.bin/console debug:router | grep -i -E 'doc|swagger'
editor.swagger.io or import it into Postman.Where to look first:
vendor/yoanm/symfony-jsonrpc-http-server-swagger-doc/src/DependencyInjection/Configuration.php for config keys.bin/console debug:container --tag=... and debug:router to see what the bundle actually registered.The first real use case is almost always: expose the spec at a URL, load it into Swagger UI or Postman, and use it to agree on request/response shapes with frontend or integration teams.
Treat method metadata as the single source of truth. The doc is derived from the methods registered with the JSON-RPC server. Put parameter names, types, required flags, and result types on the method definition itself, not in hand-maintained YAML. When a method changes, the doc changes with it. Hand-editing the generated document guarantees drift.
Use the base document for global concerns only. Put info, host, basePath, schemes, securityDefinitions, shared definitions, and tags in the configured base document. Keep operation-level details with the methods.
Gate the doc route by environment. Documentation routes are frequently left open. Restrict them in production with a firewall, when@dev / when@test config, or by generating a static file during CI instead of serving dynamically. If you serve it publicly, treat the spec as part of your API surface.
Pick a serving strategy deliberately:
public/docs/swagger.json or an artifact during CI for versioned, reviewable docs.Use the spec as a CI contract. Snapshot the generated JSON, diff it on pull requests, and validate it:
swagger-cli validate docs/swagger.json
Fail the build if a newly registered JSON-RPC method is missing from the document, or if a schema change was not reviewed. This is where a low-adoption package pays for itself: it gives you an enforceable contract without writing documentation by hand.
Drive clients and mocks from the doc. Import the spec into Postman, Prism, or a mock server for frontend work. For SDK generation, note that most modern generators expect OpenAPI 3, so convert first (for example with api-spec-converter) and inspect the output. Generated REST clients will not speak the JSON-RPC envelope out of the box; wrap them or generate only the schema types.
Add a method workflow. For each new JSON-RPC method: implement the method class with explicit parameter/result metadata, register it with the server bundle, clear the cache, refresh the doc, validate it, and update any checked-in snapshot or Postman collection. Keep this in the team's definition of done.
Use extension points sparingly. Add JSON-RPC-specific behavior through base-document x- vendor extensions (for example, documenting the envelope, jsonrpc, id, and error shape). If the bundle exposes a doc-builder service, decorate it rather than forking; use debug:container to find the service ID.
nullable, oneOf, and $ref behavior differ between versions.id, need explicit handling. A missing or vague result schema is worse than a documented void.paths block after adding methods with non-trivial names.bin/console cache:clear when a method or base-document change does not appear.yoanm/symfony-jsonrpc-http-server and the underlying jsonrpc-server-common. Pin compatible versions and read the source when behavior is unclear; with zero dependents there is little community troubleshooting to lean on.definitions and securityDefinitions when combining the base document with generated content.securityDefinitions reflects the real transport-level scheme. JSON-RPC-level auth, if any, is not modeled by Swagger.How can I help you explore Laravel packages today?