Download the PHP package nijens/openapi-bundle without Composer

On this page you can find all versions of the php package nijens/openapi-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package openapi-bundle

OpenAPI bundle

Latest version on Packagist Build Status Code Quality

Helps you create a REST API from your OpenAPI specification.

This bundle supports a design-first methodology for creating an API with Symfony by providing the following tools:

Installation

Applications that use Symfony Flex

Open a command console, enter your project directory and execute:

Applications that don't use Symfony Flex

Step 1: Download the Bundle

Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:

This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.

Step 2: Enable the Bundle

Then, enable the bundle by adding it to the list of registered bundles in the src/Kernel.php file of your project:

Usage

Before starting with the implementation of the bundle, you should take the time to design your API according to the OpenAPI specification.

The following resources can help you with designing the specification:

Routing

This bundle provides a route loader that loads path items and operations from your OpenAPI document.

You load your OpenAPI document by configuring it in the routing of your application:

Within the OpenAPI document we will use the x-openapi-bundle specification extension to add additional configuration to the operations defined in the document.

Configuring a controller for a route

A Symfony controller for a route is configured by adding the controller property to the x-openapi-bundle specification extension within an operation within your OpenAPI document.

Example of an OpenAPI document in JSON format

The value of the controller property is the same as you would normally add to a Symfony route.

Using the operationId of an operation as the name of the Symfony route

Within an OpenAPI document, you can give each operation an operationId to better identify it. To use the operationId as the name for a loaded Symfony route, add the following bundle configuration:

Using the operationId for your routes gives you more control over the API route names and allows you to better use them with a UrlGenerator.

Validation of the request

By default, the deprecated validation component is enabled. To enable the improved validation component, add the following YAML configuration.

It is strongly advised to also enable the improved exception handling component, as it will convert the details of the validation exceptions into proper JSON responses.

The validation component comes with validation for the following parts of a request:

Learn more

Deserialize a JSON request body

Adding the deserializationObject property to the x-openapi-bundle specification extension of an operation activates the request body deserialization.

When the request body is successfully validated against the JSON schema within your OpenAPI document, it will deserialize the request body into the configured deserialization object.

The deserialized object is injected into the controller based on:

  1. The type hint of the argument in the controller method.

  2. The #[DeserializedObject] parameter attribute. (supported since PHP 8.0)

    This method is the recommended way, as it supports argument resolving for both array deserialization and mixed argument types.

  3. The deserializationObjectArgumentName property that can be added to the x-openapi-bundle specification extension.

Learn more

OpenAPI-based serialization context for the Symfony Serializer

Please note: This feature is still experimental. The API might change in a future minor version.

The SerializationContextBuilder helps you with creating a serialization context for the Symfony Serializer. It allows you to easily create a JSON response from an object or entity based on your OpenAPI specification.

The following example shows how to use the serialization context builder by leveraging the request attributes added by the routing.

Exception handling

By default, the previous exception handling component is enabled. To enable the new exception handling component, add the following YAML configuration.

The new exception handling component uses the Problem Details JSON Object format to turn an exception (or Throwable) into a clear error response.

If you want to implement your own exception handling? Change enabled to false. It will disable the exception handling component of the bundle.

Customizing the Problem Details JSON Object response of an exception

Through the exception handling configuration of the bundle, you can modify the response status code and problem JSON response body of any Throwable. See the following example for more information.

To help you include the Problem Details JSON object in your OpenAPI document, we provide an OpenAPI template with schemas for the specific Problem Details JSON objects this bundle creates.

Credits and acknowledgements

Also, see the list of contributors who participated in this project.

License

The OpenAPI bundle is licensed under the MIT License. Please see the LICENSE file for details.


All versions of openapi-bundle with dependencies

PHP Build Version
Package Version
Requires php Version ^7.4 || ^8.0
ext-json Version *
justinrainbow/json-schema Version ^5.2
league/uri Version ^6.3
seld/jsonlint Version ^1.7
symfony/config Version ^5.4 || ^6.0 || ^7.0
symfony/dependency-injection Version ^5.4 || ^6.0 || ^7.0
symfony/deprecation-contracts Version ^2.5 || ^3.0
symfony/event-dispatcher Version ^5.4 || ^6.0 || ^7.0
symfony/framework-bundle Version ^5.4 || ^6.0 || ^7.0
symfony/http-foundation Version ^5.4 || ^6.0 || ^7.0
symfony/http-kernel Version ^5.4 || ^6.0 || ^7.0
symfony/property-access Version ^5.4 || ^6.0 || ^7.0
symfony/routing Version ^5.4 || ^6.0 || ^7.0
symfony/serializer Version ^5.4 || ^6.0 || ^7.0
symfony/yaml Version ^5.4 || ^6.0 || ^7.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package nijens/openapi-bundle contains the following files

Loading the files please wait ....