splash/openapi

A Collection of tools for OpenAPI Connectors

Maintainers

Package info

gitlab.com/SplashTools/OpenApi

Type:symfony-bundle

pkg:composer/splash/openapi

Transparency log

Statistics

Installs: 11 859

Dependents: 8

Suggesters: 0

Stars: 0

2.0.0 2024-02-13 17:37 UTC

This package is auto-updated.

Last update: 2026-07-29 12:58:19 UTC


README

N|Solid

Splash OpenApi

A flexible PHP library for building REST API clients with support for multiple formats: JSON, JSON-LD (API Platform), and HAL+JSON.

Latest Stable Version License

Features

  • Multi-format support: JSON, JSON-LD (Hydra), HAL+JSON
  • Visitor pattern: Clean abstraction for different API formats
  • Action-based architecture: Configurable CRUD operations with OptionsResolver
  • Metadata integration: Works with Splash Metadata for automatic field parsing
  • Extensible: Easy to add custom actions, visitors, and transformers

Architecture Overview

┌─────────────────────────────────────────────────────────────┐
│                      CONNECTOR                               │
└─────────────────────────┬───────────────────────────────────┘
                          │ uses
                          ▼
┌─────────────────────────────────────────────────────────────┐
│              VISITOR (implements VisitorInterface)           │
│  ┌─────────────┐  ┌─────────────┐  ┌─────────────┐         │
│  │ JsonVisitor │  │JsonLdVisitor│  │ HalVisitor  │         │
│  └─────────────┘  └─────────────┘  └─────────────┘         │
└─────────────────────────┬───────────────────────────────────┘
                          │ delegates to
                          ▼
┌─────────────────────────────────────────────────────────────┐
│               ACTIONS (implement ActionInterface)            │
│  ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐       │
│  │   List   │ │   Load   │ │  Create  │ │  Update  │       │
│  └──────────┘ └──────────┘ └──────────┘ └──────────┘       │
└─────────────────────────────────────────────────────────────┘

Supported API Formats

FormatContent-TypeCollection KeyPagination
JSONapplication/jsonRoot arraypage, itemsPerPage
JSON-LDapplication/ld+jsonmemberview (Hydra)
HALapplication/hal+json_embedded_links
GraphQLapplication/jsonedges[].nodeCursor (first/after)

Note: GraphQL support is planned.

Installation

composer require splash/openapi

Quick Example

Create a Splash Object that syncs data via REST API:

namespace App\Objects;

use App\Connector\MyConnector;
use App\Models\Api\Product;
use Splash\OpenApi\Models\Objects\AbstractRestAndMetadataObject;

class ProductObject extends AbstractRestAndMetadataObject
{
    /**
     * @var Product
     */
    protected object $object;

    public function __construct(MyConnector $connector)
    {
        parent::__construct(
            $connector->getVisitor(Product::class),
            $connector->getMetadataAdapter(),
            Product::class
        );
    }
}

The AbstractRestAndMetadataObject provides all CRUD operations automatically via the MetadataActionsTrait.

Documentation

Full documentation is available in the docs/ folder:

SectionDescription
Getting StartedInstallation and quick start guide
ModelsAPI models and serializer groups
VisitorsJSON, JSON-LD, and HAL visitor guides
ActionsAction configuration and transformers
Migration GuideMigrating from v2 to v3

Requirements

  • PHP 8.3+
  • Symfony Components (OptionsResolver, Serializer, PropertyAccess)

Contributing

Any Pull requests are welcome!

This module is part of SplashSync project.

License

This project is licensed under the MIT License - see the LICENSE file for details.