Download the PHP package wapmorgan/openapi-generator without Composer

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

What is it?

It is OpenApi configuration generator that works with origin source code + phpdoc.

Latest Stable Version Latest Unstable Version License

Main purpose of this library is to automatize generation of OpenApi-specification for existing JSON-API with a lot of methods. Idea by @maxonrock.

  1. Open Api generator
    • Laravel Example
    • How it works
    • How to use
    • Integrations
  2. Extending
    • New scraper
    • Settings
    • Limitations
    • ToDo

OpenApiGenerator

What it does?

It generates OpenApi 3.0 specification files for your REST JSON-based API written in PHP from source code directly. You do not need to write OpenApi-specification manually.

Laravel Example

  1. Routes:

  2. One controller:

  3. One request and two responses:

  4. Result of generation from code: two endpoints with description and arguments for select.

How it works

  1. Scraper collects info about API (tags, security schemes and servers, all endpoints) and contains settings for Generator. Scraper is framework-dependent.
  2. Generator fulfills openapi-specification with endpoints information by analyzing source code:
    • summary and description of actions
    • parameters and result of actions Generator is common. It just receives information from Scraper and analyzes code by Scraper rules.

More detailed process description is in How it works document.

How to use

Invoke console script to generate openapi for your project (with help of integrations):

For example, for yii2-project:

  1. Run parser on project to analyze files and retrieve info about endpoints

  2. Generate specification(s) into yaml-files in api_docs folder by specification_name.yml

  3. Deploy swagger with specification (e.g. _apidocs/main.yml on port 8091)

More detailed description is in How to use document.

Integrations

There's few integrations: Yii2, Laravel, Slim. Details is in Integrations document. You can write your own integration for framework or your project.

Extending

New scraper

You use (or extend) a predefined scraper (see Integrations) or create your own scraper from scratch (extend DefaultScraper), which should return a result with list of your API endpoints. Also, your scraper should provide tags, security schemes and so on.

Scraper should return list of specifications (for example, list of api versions) with:

Detailed information about Scraper result: in another document.

Settings

DefaultGenerator provides list of settings to tune generator.

Parameter type default description
CHANGE_GET_TO_POST_FOR_COMPLEX_PARAMETERS bool false if callback has arguments with object , array , stdclass , mixed type or class-typed, method of argument will be changed to POST and these arguments will be placed as body data in json-format
TREAT_COMPLEX_ARGUMENTS_AS_BODY bool false move complex arguments to request body
PARSE_PARAMETERS_FROM_ENDPOINT bool false if callback id has macroses (users/{id}), these arguments will be parsed as normal callback arguments
PARSE_PARAMETERS_FORMAT_FORMAT_DESCRIPTION bool false if php-doc for callback argument in first word after argument variable has one of predefined sub-types (@param string $arg SUBTYPE Full parameter description), this will change sub-type in resulting specification. For example, for string format there are subtypes: date, date-time, password, byte, binary, for integer there are: float, double, int32, int64. Also, you can defined custom format with DefaultGenerator::setCustomFormat($format, $formatConfig)

Usage:

By default, they all are disabled.

Limitations

Tests

Type-to-schema regression tests run in a Docker Composer container. Only Docker and Make are required on the host:

When the library is inside the AG project, the target reuses its installed dependencies but runs PHPUnit in a container. For a standalone checkout, the target installs dependencies with Composer inside the container. See the development roadmap for planned parser, schema, diagnostics, and integration improvements.

Input parameter location

Use a location-specific tag to describe where a method argument comes from:

Use @pathParam, @queryParam, @headerParam, @cookieParam, and @bodyParam. For a tag referring to a method argument, $name alone is enough; its type is taken from @param or the PHP signature. For an external value that is not a method argument, include its type in the location tag. Set the wire name with name= and the format with format=. Requiredness for bound arguments is inferred from the PHP signature; external parameters are optional by default, while path parameters are always required.

Use the same tags for values read directly from the Request that are not run() arguments:

Syntax: @<location>Param [<type>] $<name> [name=<wire-name>] [format=<format>] [required|optional] <description>, where <location> is query, path, header, cookie, or body. Path parameters are always required. Each @bodyParam describes a property in a JSON object; use @requestBody <type> required|optional <description> to describe the entire request body schema. Do not combine @requestBody with @bodyParam fields. Request bodies currently use application/json only. The legacy @apiParameter tag remains supported for compatibility, but new PHPDoc should use the location-specific tags.

If no location is specified, the backward-compatible behavior is retained: primitive types are treated as query parameters, while complex types go into the JSON body when the corresponding scraper setting is enabled. Route placeholders such as {id} are treated as path parameters when PARSE_PARAMETERS_FROM_ENDPOINT is enabled. When CHANGE_GET_TO_POST_FOR_COMPLEX_PARAMETERS is enabled, an endpoint declared as GET is generated as POST if it has a request body. Explicit locations document the contract but do not change runtime parameter binding: the application must still read header and cookie values from the appropriate request source.

ToDo


All versions of openapi-generator with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4
zircote/swagger-php Version ^3.0
doctrine/annotations Version ^1.6
phpdocumentor/reflection-docblock Version ^4.3|^5.1
symfony/console Version ^5.0|^6.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 wapmorgan/openapi-generator contains the following files

Loading the files please wait ...