PHPackages                             sitegeist/schemeonyou - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. sitegeist/schemeonyou

ActiveNeos-package[API Development](/categories/api)

sitegeist/schemeonyou
=====================

JSON Schema integration for Neos.Flow

v2.1.0(3mo ago)413.0k↓57.6%1[6 issues](https://github.com/sitegeist/Sitegeist.SchemeOnYou/issues)[3 PRs](https://github.com/sitegeist/Sitegeist.SchemeOnYou/pulls)1LGPL-3.0PHPPHP ^8.2CI passing

Since Mar 26Pushed 3mo ago2 watchersCompare

[ Source](https://github.com/sitegeist/Sitegeist.SchemeOnYou)[ Packagist](https://packagist.org/packages/sitegeist/schemeonyou)[ RSS](/packages/sitegeist-schemeonyou/feed)WikiDiscussions 1.0 Synced 2d ago

READMEChangelog (10)Dependencies (10)Versions (33)Used By (1)

Sitegeist.SchemeOnYou
=====================

[](#sitegeistschemeonyou)

API Documentation that is always complete, accurate and up to date. For humans and machines
-------------------------------------------------------------------------------------------

[](#api-documentation-that-is-always-complete-accurate-and-up-to-date-for-humans-and-machines)

SchemOnYou makes the implementation of REST/JSON APIs simple and easy. It enforces strong conventions and modern type safe php code for data transfer objects (DTOs). SchemOnYou generates OpenApi-Specs directy from the controller code wich ensures that the documentation is always complete, up to date and accurate.

Since OpenApi-Specs are human and machine readable SchemeOnYou allows to integrate with tools like swagger-ui but also with code generators that allow to generate type safe client code to consume the apis.

This allows type safe and static analyzable code from the backend through JSON/Rest apis to the frontend and back. For faster development pace while maintaining high quality and end to end type safety.

TLDR:
-----

[](#tldr)

#### Sitegeist.SchemeOnYou provides:

[](#sitegeistschemeonyou-provides)

- A strong convention for PHP DataTransferObjects based on modern PHP code
- Serializers and deserializers for those DTOs
- A base class for REST/JSON endpoint controllers where each endpoint recieves and returns DTOs
- A generator for OpenAPI schemas describing the DTOs and endpoints

#### Differences:

[](#differences)

- Controllers extend `Sitegeist\SchemeOnYou\Application\OpenApiController`
- ControllerActions must accept and return supported types.
- Supported Types are scalar Values, DTOs and Collections of DTOs plus an exception for PHP Date objects.

#### Advantages:

[](#advantages)

- Simpler Controller logic!
- Controllers can be fully analyzed!
- Controllers can be tested via UnitTests!
- OpenApi Documentation is generated on the fly and cannot deviate from the facts.
- Return types and other details can be defined via Attributes.

#### Caveats:

[](#caveats)

- Everything going in an out must use named and supported types.
- You must not use plain arrays as type.

### Authors &amp; Sponsors

[](#authors--sponsors)

- Bernhard Schmitt -
- Martin Ficzel -

*The development and the public-releases of this package is generously sponsored by our employer .*

Build APIs
----------

[](#build-apis)

### Configure OpenAPI Documents

[](#configure-openapi-documents)

The package allows to specify multiple OpenAPI documents. Each class that extends `\Sitegeist\SchemeOnYou\Application\OpenApiController`and matches one of the configured `classNames` patterns will be included into the api document.

```
Sitegeist:
  SchemeOnYou:
    documents:
      example:
        name: "Example OpenApi document"
        classNames:
          - 'Vendor\Example\Controller\*'
```

The configured OpenApi Documents spec can than be rendered via cli `./flow openapidocument:render {name}`or via url-path `/openapi/document/{name}`.

### Create OpenApi Controllers

[](#create-openapi-controllers)

OpenApi endpoints that are included in the generated documents are all `*Action` methods inside controllers that extends the `Sitegeist\SchemeOnYou\Application\OpenApiController` and are reachable via Routing. Controllers must specify the type of each parameter and also the return type.

*!!! For now union-types are only allowed in return values of Action methods. !!!*

```
