Download the PHP package wwwision/types-openapi without Composer

On this page you can find all versions of the php package wwwision/types-openapi. 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 types-openapi

The easiest way to generate type-safe APIs with PHP...

...possibly... ;)

Integration for the wwwision/types package that allows for generation of OpenAPI schemas and APIs from PHP code

Usage

This package can be installed via composer:

Simple Example

This is all that is required to generate an OpenAPI schema for a simple HTTP endpoint:

Serve HTTP Requests

This package comes with a RequestHandler that allows for serving HTTP requests using the generated OpenAPI schema. The RequestHandler is PSR-7 compatible such that it can easily be integrated with a corresponding psr/http-factory/psr/http-message provider, e.g. guzzlehttp/psr7:

Parameters

Arguments of the endpoint methods are automatically mapped to OpenAPI parameters. All OpenAPI parameter types are supported (query, path, header, cookie).

Query parameters

By default, the parameter type is query:

will accept requests like

and

and will map the values to the corresponding method arguments.

Path parameters

Operations can also make use of Path Templating in order to map method arguments from the query path:

Path params cannot be optional and must be defined in the path template.

Header parameters

To define a header parameter, the #[Parameter] attribute can be used:

Cookie parameters

Likewise, to define a cookie parameter, the #[Parameter] attribute can be used:

Complex types

Complex parameter types are supported as well as long as they follow the wwwision/types best practices:

This will validate and map the parameter and fail if it does not satisfy the constraints:

Example

The following example makes use of all parameter types:

This will lead to an OpenAPI definition like this:

And an HTTP request like:

...will result in the following response:

Security

To implement custom authentication schemes, you can implement the AuthenticationContextProvider interface and return an instance of your custom AuthenticationContext class:

The AuthenticationContext is passed to the endpoint method as an additional argument, if the security option of the Operation attribute is set. The RequestHandler will automatically call the getAuthenticationContext() method of your provider and pass the result to the endpoint method. Security schemes can be defined using the #[OpenApi] attribute:

More Examples

More complex example

Contribution

Contributions in the form of issues or pull requests are highly appreciated

License

See LICENSE


All versions of types-openapi with dependencies

PHP Build Version
Package Version
Requires php Version >=8.3
wwwision/types Version ^1.4
webmozart/assert Version ^1.11
wwwision/types-jsonschema Version ^2
psr/http-server-handler Version ^1
psr/http-server-middleware Version ^1
psr/http-factory Version ^1
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 wwwision/types-openapi contains the following files

Loading the files please wait ....