Download the PHP package goldspecdigital/oooas without Composer

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

Object Oriented OpenAPI Specification

GitHub stars

GitHub tag (latest SemVer) Build status Packagist PHP from Packagist Dependency count Packagist

Introduction

An object oriented approach to generating OpenAPI specs, implemented in PHP.

You can build up your API spec using immutable PHP classes, and then export the spec to JSON (or YAML with the help of another package).

This package is dependency free and makes heavy use of PHP 7 features, mainly being type hints and enabling strict types. This should make your life a lot easier when working with a good IDE that can use this information.

Installing

You can install the package via composer:

Example

See the code sample below for the most basic usage:

YAML output

Using the same code above will output the following YAML:

In this example, the YAML may seem simpler to look at, however once the spec starts to increase in size - the ability to reuse objects and split them into separate files easily will be a massive help.

Outputting as JSON or YAML

Built in output to YAML has been omitted on purpose to keep this package dependency free. However, you can easily convert the array to a YAML string using several open source packages. See below for an example of outputting to both JSON and YAML:

Guidance

If you want to learn more about the OpenAPI schema, then have a look at the official OpenAPI Specification.

Alternatively, if you would like a quick reference, then check out the OpenAPI Map project created by Arnaud Lauret.

You can use this interactive tool to figure out what objects go where and how they relate to one another.

Usage

Setting and unsetting properties

Each object has setter methods for it's supported properties. Most of these methods allow null values which will need to be explicitly passed (see the next example for how to unset using variadic setter methods). This will have the effect of unsetting the property:

For variadic setter methods, if you call the method and don't supply any parameters, then this will have the effect of unsetting the property:

Retrieving properties

You can easily retrieve a property using a magic getter. These have been implemented for all properties for every object. DocBlocks have been provided to give better auto-completion in IDEs:

Object ID

Every object has an optional $objectId property which is a string and can either be set in the class constructor or the preferred create() method. This property is used when a parent object needs to use a name for the children.

An example of this in use is when a schema object is composed of other schema properties:

If an object contains any helper creation methods, then these methods also allow you to specify the $objectId property as a parameter. The code sample below is functionally identical to the one above:

$ref

The use of $ref has been applied to every single object to use as you wish. You may substitute any object for a $ref by invoking the ref() static method on the object class:

Specification extensions

You can add specification extensions to all objects:

You can also unset specification extensions by invoking the x() method and only providing the key:

To retrieve an array of all the specification extensions you can call the $x property:

Validation

In order to perform schema validation you must first install the justinrainbow/json-schema package:

Once installed, you may now make use of the validate() method on the OpenApi object:

If you haven't installed the justinrainbow/json-schema package and attempt to use the validate() method, then a RuntimeException will be thrown.

If validation fails for the schema, then a GoldSpecDigital\ObjectOrientedOAS\Exceptions\ValidationException will be thrown. You can use the getErrors() method on this exception to retrieve all of the validation errors.

Running the tests

To run the test suite you can use the following commands:

If you receive any errors from the style tests, you can automatically fix most, if not all of the issues with the following command:

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

See also the list of contributors who participated in this project.

License

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


All versions of oooas with dependencies

PHP Build Version
Package Version
Requires php Version >=7.1.0
ext-json Version *
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 goldspecdigital/oooas contains the following files

Loading the files please wait ....