otezvikentiy/json-rpc-api

Symfony Json RPC API bundle

1.34 2025-01-13 11:43 UTC

This package is auto-updated.

Last update: 2025-01-13 11:44:23 UTC


README

The bundle allows you to quickly and conveniently create JSON RPC API applications based on the Symfony framework.

Features

  • easy api versioning
  • easy bundle installation
  • compatible with attributes
  • compatible with POST, GET, PUT, PATCH, DELETE requests
  • fully compatible with https://www.jsonrpc.org/specification
  • swagger openapi out of the box
  • callbacks

github: https://github.com/OtezVikentiy/symfony-jsonrpc-api-bundle

Bundle installation

see how to easily install bundle.

Examples

During the installation process, we defined the src/RPC/V1/{*Method.php} directory in the services and marked with tags in it all the classes ending in *Method.php - these will be our API endpoints.

Swagger

If you wish to generate openapi swagger yaml file - then run this command:

bin/console ov:swagger:generate

It would generate a swagger file public/openapi/api_v1.yaml which you can use in your swagger instance.

see example of how to combine multiple endpoints with tags

see example how to define default, format and example for scalar properties of response

see example how to describe array properties of response

Security

Initially, two implementation options are provided and tested, described below, but you are free to connect any other software solutions to your taste and color.

Auth via lexik jwt token bundle

Auth via self-written system

You may need to add a role model to restrict user access. You always have the option to implement your own version, but there is also a built-in implementation based on the simplest Symfony Security version.

Built-in roles usage example