ashkarpetin / php-openapi

READ OpenAPI yaml files and make the content accessable in PHP objects.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

php-openapi

READ OpenAPI 3.0.x YAML and JSON files and make the content accessible in PHP objects.

Latest Stable Version Build Status License

Install

composer require cebe/php-openapi

Requirements

  • PHP 7.0 or higher

Usage

Read OpenAPI spec from JSON:

use cebe\openapi\Reader;

$openapi = Reader::readFromJson(file_get_contents('openapi.json'));

Read OpenAPI spec from YAML:

use cebe\openapi\Reader;

$openapi = Reader::readFromYaml(file_get_contents('openapi.yaml'));

Access specification data:

echo $openapi->openapi; // openAPI version, e.g. 3.0.0
echo $openapi->info->title; // API title
foreach($openapi->paths as $path => $definition) {
    // iterate path definitions
}

Object properties are exactly like in the OpenAPI specification. You may also access additional properties added by specification extensions.

Completeness

This library is currently work in progress, the following list tracks completeness:

  • read OpenAPI 3.0 JSON
  • read OpenAPI 3.0 YAML
  • OpenAPI 3.0 Schema
    • OpenAPI Object
    • Info Object
    • Contact Object
    • License Object
    • Server Object
    • Server Variable Object
    • Components Object
    • Paths Object
    • Path Item Object
    • Operation Object
    • External Documentation Object
    • Parameter Object
    • Request Body Object
    • Media Type Object
    • Encoding Object
    • Responses Object
    • Response Object
    • Callback Object
    • Example Object
    • Link Object
    • Header Object
    • Tag Object
    • Reference Object
    • Schema Object
      • load/read
        • additionalProperties field
      • validation
    • Discriminator Object
    • XML Object
    • Security Scheme Object
    • OAuth Flows Object
    • OAuth Flow Object
    • Security Requirement Object

About

READ OpenAPI yaml files and make the content accessable in PHP objects.

License:MIT License


Languages

Language:PHP 99.5%Language:Makefile 0.5%