Giter Club home page Giter Club logo

openapi-php's Introduction

openapi-php

Latest Version on Packagist Software License Build Status Coverage Status Quality Score Total Downloads

Open API 3.0 builder and validation library for PHP that helps you write valid specs.

This project is compliant with PSR-1, PSR-2 and PSR-4. If you notice compliance oversights, please send a patch via pull request.

Features

  • Fully documented object-oriented representation of the Open API 3.0+ specification with helper methods to write valid documents.
  • Supports Illuminate (Laravel) Jsonable and Arrayable.
  • Generates an specification in plain PHP arrays, plain objects, JSON or YAML.
  • Validates Open API documents against the Open API 3.0.x JSON Schema.

Install

Via Composer

$ composer require erasys/openapi-php

Via Git

$ git clone https://github.com/erasys/openapi-php.git

Usage

Basic example:

<?php

use erasys\OpenApi\Spec\v3 as OASv3;

$doc = new OASv3\Document(
    new OASv3\Info('My API', '1.0.0', 'My API description'),
    [
        '/foo/bar' => new OASv3\PathItem(
            [
                'get' => new OASv3\Operation(
                    [
                        '200' => new OASv3\Response('Successful response.'),
                        'default' => new OASv3\Response('Default error response.'),
                    ]
                ),
            ]
        ),
    ]
);

$yaml = $doc->toYaml();
$json = $doc->toJson();
$arr  = $doc->toArray();
$obj  = $doc->toObject();

Testing

$ composer test

or

$ vendor/bin/phpunit
$ vendor/bin/phpcs

Contributing

Please see CONTRIBUTING for details.

License

The MIT License (MIT). Please see License File for more information.

openapi-php's People

Contributors

frontendcoffee avatar itsjavi avatar jleeothon avatar majermi4 avatar matthiasstern avatar pjordaan avatar tiktechto avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

openapi-php's Issues

composer installation does not work

Currently there is no way to register the package in packagist.org since the "erasys" vendor name is taken by someone else.
Until we solve this, the only solution is to require this project as VCS package in your composer.json.

feature request: parse from string spec to OOP representation

Given a yaml or json string, I want to be able to have a parsed and sanitized OOP representation out of it (using the Spec classes of this project), with optional exceptions in case of invalid/unsupported schema.

The value of this is the ability to port and modify/extend that schema easily.

illuminate/contracts 7.* support

Again the array interface that is being used is not changed in version 7. Can it the composer.json be updated so we can update our application to Laravel 7?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.