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

Overview

php-openapi

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

It also provides a CLI tool for validating and converting OpenAPI 3.0.x Description files.

Latest Stable Version Total Downloads Build Status

Install

composer require cebe/php-openapi

Requirements

  • PHP 7.1 or higher (works fine with PHP 8)

Used by

This library provides a low level API for reading and writing OpenAPI files. It is used by higher level tools to do awesome work:

Usage

CLI Tool

$ vendor/bin/php-openapi help
PHP OpenAPI 3 tool
------------------
by Carsten Brandt 
   
    

Usage:
  php-openapi 
     [
    
     ] [input.yml|input.json] [output.yml|output.json]

  The following commands are available:

    validate   Validate the API Description in the specified input file against the OpenAPI v3.0 schema.
               Note: the validation is performed in two steps. The results are composed of
                (1) structural errors found while reading the API Description file, and
                (2) violations of the OpenAPI v3.0 schema.

               If no input file is specified input will be read from STDIN.
               The tool will try to auto-detect the content type of the input, but may fail
               to do so. You may specify --read-yaml or --read-json to force the file type.

               Exits with code 2 on validation errors, 1 on other errors and 0 on success.

    convert    Convert a JSON or YAML input file to JSON or YAML output file.

               If no input file is specified input will be read from STDIN.
               If no output file is specified output will be written to STDOUT.
               The tool will try to auto-detect the content type of the input and output file, but may fail
               to do so. You may specify --read-yaml or --read-json to force the input file type.
               and --write-yaml or --write-json to force the output file type.

               By default all references are resolved (replaced with the object referred to). You can control
               handling of references with the following arguments:

               --resolve-none      Do not resolve references.
               --resolve-external  Only resolve references that point to external files.
                                   This process is often referred to as "inlining".
               --resolve-all       Resolve all references (default).
                                   Recursive pointers will stay references.

    inline     Convert a JSON or YAML input file to JSON or YAML output file and
               resolve all external references. The output will be a single API Description file.
               This is a shortcut for calling convert --resolve-external.

    help       Shows this usage information.

  Options:

    --read-json   force reading input as JSON. Auto-detect if not specified.
    --read-yaml   force reading input as YAML. Auto-detect if not specified.
    --write-json  force writing output as JSON. Auto-detect if not specified.
    --write-yaml  force writing output as YAML. Auto-detect if not specified.
    -s, --silent  silent mode. Will hide all success/information messages and only print errors.

    
   

Reading API Description Files

Read OpenAPI Description from JSON file:

use cebe\openapi\Reader;

// realpath is needed for resolving references with relative Paths or URLs
$openapi = Reader::readFromJsonFile(realpath('openapi.json'));

Read OpenAPI Description from YAML:

use cebe\openapi\Reader;

// realpath is needed for resolving references with relative Paths or URLs
$openapi = Reader::readFromYamlFile(realpath('openapi.yaml'));
// you may also specify the URL to your API Description file
$openapi = Reader::readFromYamlFile('https://raw.githubusercontent.com/OAI/OpenAPI-Specification/3.0.2/examples/v3.0/petstore-expanded.yaml');

Access API Description 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.

Writing API Description Files

use cebe\openapi\spec\OpenApi;
use cebe\openapi\spec\PathItem;

// create base API Description
$openapi = new OpenApi([
    'openapi' => '3.0.2',
    'info' => [
        'title' => 'Test API',
        'version' => '1.0.0',
    ],
    'paths' => [],
]);
// manipulate description as needed
$openapi->paths['/test'] = new PathItem([
    'description' => 'something'
]);
// ...

$json = \cebe\openapi\Writer::writeToJson($openapi);

results in the following JSON data:

{
    "openapi": "3.0.0",
    "info": {
        "title": "Test API",
        "version": "1.0.0"
    },
    "paths": {
        "/test": {
            "description": "something"
        }
    }
}

Writing API Description Files using prepared Objects

Since version 1.2.0, the above example can also be written like this (passing objects instead of arrays):

use cebe\openapi\spec\OpenApi;
use cebe\openapi\spec\PathItem;
use cebe\openapi\spec\Info;


// create base API Description
$openapi = new OpenApi([
    'openapi' => '3.0.2',
    'info' => new Info([
        'title' => 'Test API',
        'version' => '1.0.0',
    ]),
    'paths' => [
        '/test' => new PathItem([
            'description' => 'something'
        ]),
    ],
]);
$json = \cebe\openapi\Writer::writeToJson($openapi);

Reading API Description Files and Resolving References

In the above we have passed the raw JSON or YAML data to the Reader. In order to be able to resolve references to structures in external files, we must provide the full context.

use cebe\openapi\Reader;
use cebe\openapi\spec\OpenAPI;
use cebe\openapi\ReferenceContext;

// there are two different modes for resolving references:
// ALL: resolve all references, which will result in a large description with a lot of repetition
// but no references (except if there are recursive references, these will stop at some level)
$mode = ReferenceContext::RESOLVE_MODE_ALL;
// INLINE: only references to external files are resolved, references to places in the current file
// are still Reference objects.
$mode = ReferenceContext::RESOLVE_MODE_INLINE;

// an absolute URL or file path is needed to allow resolving external references
$openapi = Reader::readFromJsonFile('https://www.example.com/api/openapi.json', OpenAPI::class, $mode);
$openapi = Reader::readFromYamlFile('https://www.example.com/api/openapi.yaml', OpenAPI::class, $mode);

If data has been loaded in a different way you can manually resolve references like this by giving a context:

$openapi->resolveReferences(
    new \cebe\openapi\ReferenceContext($openapi, 'https://www.example.com/api/openapi.yaml')
);

Validation

The library provides simple validation operations, that check basic OpenAPI spec requirements. This is the same as "structural errors found while reading the API Description file" from the CLI tool. This validation does not include checking against the OpenAPI v3.0 JSON schema, this is only implemented in the CLI.

// return `true` in case no errors have been found, `false` in case of errors.
$specValid = $openapi->validate();
// after validation getErrors() can be used to retrieve the list of errors found.
$errors = $openapi->getErrors();

Note: Validation is done on a very basic level and is not complete. So a failing validation will show some errors, but the list of errors given may not be complete. Also a passing validation does not necessarily indicate a completely valid spec.

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
      • validation
    • Discriminator Object
    • XML Object
    • Security Scheme Object
    • OAuth Flows Object
    • OAuth Flow Object
    • Security Requirement Object

Support

Need help with your API project?

Professional support, consulting as well as software development services are available:

https://www.cebe.cc/en/contact

Development of this library is sponsored by cebe. ☁️ "Your Professional Deployment Platform".

Comments
  • Make implementations of built-in interfaces PHP 8.1 friendly

    Make implementations of built-in interfaces PHP 8.1 friendly

    Problem

    Unfortunately, PHP 8.1 throws Fatal Error if the built-in interface implementation is incompatible with the new, type enhanced interfaces.

    Example error:

    Fatal error: During inheritance of ArrayAccess: Uncaught Return type of cebe\openapi\spec\Responses::offsetExists($offset) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[ReturnTypeWillChange] attribute should be used to temporarily suppress the notice
    

    Example differences:

    -public function offsetExists($offset);
    +public function offsetExists(mixed $offset):bool;
    

    Solution

    As the above error messages also refer to it, the solution is relatively straightforward. The implementation needs to be updated with type information, or the #[ReturnTypeWillChange] attribute must be added to the affected methods.

    This pull implements a the later, to maintain the current PHP compatibility: PHP >= 7.1.0.

    Fortunately, attributes syntax just comments on PHP 7.x, the added lines may look weird but ignored by PHP.

    Note: Attributes are "references" to classes, so namespace rules apply. That's why the attributes incorporate the backslash as well, i.e.: #[\ReturnTypeWillChange].

    Test

    To successfully run PHPUnit tests under PHP 8.1, I used the following commands:

    composer config minimum-stability dev
    composer require phpunit/phpunit:dev-master --dev
    composer update --prefer-stable
    vendor/bin/phpunit
    

    I tested these changes on 7.1.33, 7.2.34, 7.3.30, 7.4.23, 8.0.10 and 8.1.0beta3

    References

    Affected built-in interfaces:

    • https://www.php.net/manual/en/class.jsonserializable.php
    • https://www.php.net/manual/en/class.arrayaccess.php
    • https://www.php.net/manual/en/class.countable

    ReturnTypeWillChange attribute introduced in this rfc: https://wiki.php.net/rfc/internal_method_return_types

    Attributes in general: https://www.php.net/manual/en/language.attributes.php

    overhead php8 
    opened by om4csaba 12
  • PHP 8.1 deprecation warnings

    PHP 8.1 deprecation warnings

    Hey!

    I just came across this lib, and it's very nice. However, it throws a couple of deprecation warnings when using it with PHP 8.1

    Deprecated: Return type of cebe\openapi\spec\Paths::offsetExists($offset) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /app/vendor/cebe/php-openapi/src/spec/Paths.php on line 186
    Deprecated: Return type of cebe\openapi\spec\Paths::offsetGet($offset) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /app/vendor/cebe/php-openapi/src/spec/Paths.php on line 197
    Deprecated: Return type of cebe\openapi\spec\Paths::offsetSet($offset, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /app/vendor/cebe/php-openapi/src/spec/Paths.php on line 208
    Deprecated: Return type of cebe\openapi\spec\Paths::offsetUnset($offset) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /app/vendor/cebe/php-openapi/src/spec/Paths.php on line 218
    Deprecated: Return type of cebe\openapi\spec\Paths::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /app/vendor/cebe/php-openapi/src/spec/Paths.php on line 229
    Deprecated: Return type of cebe\openapi\spec\Paths::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /app/vendor/cebe/php-openapi/src/spec/Paths.php on line 239
    Deprecated: Return type of cebe\openapi\json\JsonReference::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /app/vendor/cebe/php-openapi/src/json/JsonReference.php on line 129
    Deprecated: Return type of cebe\openapi\spec\Responses::offsetExists($offset) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /app/vendor/cebe/php-openapi/src/spec/Responses.php on line 176
    Deprecated: Return type of cebe\openapi\spec\Responses::offsetGet($offset) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /app/vendor/cebe/php-openapi/src/spec/Responses.php on line 187
    Deprecated: Return type of cebe\openapi\spec\Responses::offsetSet($offset, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /app/vendor/cebe/php-openapi/src/spec/Responses.php on line 198
    Deprecated: Return type of cebe\openapi\spec\Responses::offsetUnset($offset) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /app/vendor/cebe/php-openapi/src/spec/Responses.php on line 208
    Deprecated: Return type of cebe\openapi\spec\Responses::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /app/vendor/cebe/php-openapi/src/spec/Responses.php on line 219
    Deprecated: Return type of cebe\openapi\spec\Responses::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /app/vendor/cebe/php-openapi/src/spec/Responses.php on line 229
    

    If you are interested in supporting PHP 8.1, I can contribute a fix for these.

    overhead php8 
    opened by acelaya 7
  • Rework CI

    Rework CI

    • Use ramsey/composer-install action

    • ~Drop testing on multiple OSes as it's not relevant~

    • Move timezone setting to bootstrap file

    • Run standalone PHPStan and Code Style checks

    • Bump justinrainbow/json-schema to v5.2 as it supports PHP 8.0

    • Conflict with symfony/yaml 3.4.0 - 3.4.4 || 4.0.0 - 4.4.17 || 5.0.0 - 5.1.9 || 5.2.0 in order to prevent installing broken versions (especially this issue https://github.com/symfony/symfony/issues/39521)

    • Run speccy through yarn

    • [ ] I'don't know windows and not sure how to force it to understand composer require symfony/yaml:"^5"

    image

    opened by simPod 5
  • Feature Request: Access component schemas by name

    Feature Request: Access component schemas by name

    In OAS, I can reference schemas by name: #/components/schemas/MySchema. While playing with cebe/php-openapi, I attempted to access a schema through a similar path, like this:

    $openapi->components->schemas->MySchema
    // or
    $openapi->components->schemas['MySchema']
    

    Unfortunately, neither approach works because schemas is a 0-indexed array and not a hash or object with named properties.

    Consider modifying $openapi->components->schemas so that it is an object with properties named according to the named schemas in the path #/components/schemas.

    bug 
    opened by ramsey 5
  • Inline references are not resolved when creating schema from JSON\YAML string

    Inline references are not resolved when creating schema from JSON\YAML string

    Original issue https://github.com/thephpleague/openapi-psr7-validator/issues/107

    If a spec has header parameters with references, and references are not solved when creating the schema, findHeaderSpecs will fail with error Undefined property: cebe\openapi\spec\Reference::$in

    Failing test case
    <?php
    
    declare(strict_types=1);
    
    namespace Tests;
    
    use cebe\openapi\Reader;
    use PHPUnit\Framework\TestCase;
    
    final class HeaderParametersReferenceResolution extends TestCase
    {
        public function testHeaderParametersWithReference(): void
        {
            $yaml = <<<'YAML'
    openapi: 3.0.0
    info:
      title: Product import API
      version: '1.0'
    servers:
      - url: 'http://localhost:8000/api/v1'
    paths:
      /products.create:
        post:
          parameters:
            - $ref: '#/components/parameters/appIdHeader'
          requestBody:
            required: true
            content:
              application/json:
                schema:
                  properties:
                    url:
                      type: string
          responses:
            '200':
              description: OK
              content:
                application/json:
                  schema:
                    properties:
                      result: 
                        type: string
    components:
      parameters:
        appIdHeader:
          schema:
            type: integer
          in: header
          required: true
          name: X-APP-ID
          description: App id used to identify request.
    YAML;
    
            $schema = Reader::readFromYaml($yaml);
    
            $operation = $schema->paths->getPath('/products.create')->getOperations()['post'];
    
            foreach ($operation->parameters as $parameter) {
                if ($parameter->in !== 'header') {
                    continue;
                }
    
                $this->addToAssertionCount(1);
            }
        }
    }
    

    Fails with

    Undefined property: cebe\openapi\spec\Reference::$in
    HeaderParametersReferenceResolution.php:59
    
    wontfix 
    opened by scaytrase 4
  • Viability to add typed setters

    Viability to add typed setters

    Hello! I was messing with an implementation of this package and came across this situation. I wonder if it would be possible to add typed setters for some properties, like Paths have with addPath. Just to have more fluid and intuitive implementation. If yes, would be willing to accept pull request with these kind of modifications?

    Something like:

    $pathItem = new PathItem();
    $post = new Operation();
    $pathItem->setPost($post);
    

    I used a typescript documentation package that made a little bit easier to write. That's where my idea comes from.

    enhancement under discussion 
    opened by ryok90 4
  • Inline references in referenced files are not resolved

    Inline references in referenced files are not resolved

    It seems that since version 1.5 , references in referenced files are not resolved. An error like "Cannot find component with name ..." is throwed. It worked fine in previous version.

    bug 
    opened by damiendiels 4
  • Cache ref files

    Cache ref files

    We have relatively big API specification with all objects extracted to separate file. This update reduced spec load time from ~15 min to several seconds.

    enhancement 
    opened by Shkryob 4
  • Add option to inline only external references

    Add option to inline only external references

    Currently resolving references resolves all references unless they are recursive.

    There should be more options to support cases where only external references should be inlined. See also: https://stoplight.io/blog/keeping-openapi-dry-and-portable/

    enhancement 
    opened by cebe 4
  • Cannot use reference to component referenced from external file.

    Cannot use reference to component referenced from external file.

    If I have defined a component externally, like this:

    components:
      schemas:
        Pet:
          $ref: definitions.yaml#/Pet
    

    Then I expect to be able to use it like this:

    paths:
      '/pet':
        get:
          responses:
            200:
              description: return a pet
              content:
                'application/json':
                  schema:
                    $ref: "#/components/schemas/Pet"
    

    However, when I do so, I get an error: cebe\openapi\exceptions\UnresolvableReferenceException : Cyclic reference detected, setReferenceContext() called on a Reference Object.

    bug needs investigation 
    opened by liquorvicar 4
  • Empty security array incorrectly converted to empty object (YAML)

    Empty security array incorrectly converted to empty object (YAML)

    When using $schema = Reader::readFromYaml($content) followed by Writer::writeToYaml($schema) any instances of security: [] are incorrectly converted to security: { }. This is invalid (it should remain as an empty array) and causes any tooling that reads the newly written spec to fall over.

    bug 
    opened by coatesap 4
  • Bump json-pointer from 0.6.1 to 0.6.2

    Bump json-pointer from 0.6.1 to 0.6.2

    Bumps json-pointer from 0.6.1 to 0.6.2.

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
  • Unable to reference other local json file

    Unable to reference other local json file

    Hi!

    I'm trying to build an OAPI definition where I split shared data into separate files. I'm only using json format as of now. One example would be doing something like this:

    {
      "openapi": "3.0.0",
      "info": {
        "title": "My API",
        "version": "1, 2"
      },
      "paths": {
        "/v1/users/profile": {
          "get": {
            "operationId": "V1GetUserProfile",
            "summary": "Returns the user profile",
            "responses": {
              "401": {
                "$ref": "./401.json"
              }
            }
          }
        }
      }
    }
    

    and the 401 file would contain the actual details:

    "description": "401 response",
    "content": {
      "application/json": {
        "schema": {
          "properties": {
            "message": {
              "type": "string"
            }
          },
          "required": [
            "message"
          ]
        },
        "example": {
          "message": "Unauthenticated."
        }
      }
    }
    

    When attempting to do this, it seems this package formats the URI to become file://401.json. This causes the parser to fail. The stack trace looks like this:

    cebe\openapi\exceptions\UnresolvableReferenceException : Failed to resolve Reference './401.json' to cebe\openapi\spec\Response Object: file_get_contents(file:///401.json): Failed to open stream: No such file or directory
     vendor/cebe/php-openapi/src/spec/Reference.php:220
     vendor/cebe/php-openapi/src/spec/Responses.php:244
     vendor/cebe/php-openapi/src/SpecBaseObject.php:410
     vendor/cebe/php-openapi/src/SpecBaseObject.php:410
     vendor/cebe/php-openapi/src/spec/PathItem.php:200
    

    I'm on a Mac. Any ideas?

    opened by mattias-persson 0
  • Bump express from 4.17.2 to 4.18.2

    Bump express from 4.17.2 to 4.18.2

    Bumps express from 4.17.2 to 4.18.2.

    Release notes

    Sourced from express's releases.

    4.18.2

    4.18.1

    • Fix hanging on large stack of sync routes

    4.18.0

    ... (truncated)

    Changelog

    Sourced from express's changelog.

    4.18.2 / 2022-10-08

    4.18.1 / 2022-04-29

    • Fix hanging on large stack of sync routes

    4.18.0 / 2022-04-25

    ... (truncated)

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
  • Bump loader-utils from 1.4.0 to 1.4.2

    Bump loader-utils from 1.4.0 to 1.4.2

    Bumps loader-utils from 1.4.0 to 1.4.2.

    Release notes

    Sourced from loader-utils's releases.

    v1.4.2

    1.4.2 (2022-11-11)

    Bug Fixes

    v1.4.1

    1.4.1 (2022-11-07)

    Bug Fixes

    Changelog

    Sourced from loader-utils's changelog.

    1.4.2 (2022-11-11)

    Bug Fixes

    1.4.1 (2022-11-07)

    Bug Fixes

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
  • openApi->validate returns true with invalid response $ref

    openApi->validate returns true with invalid response $ref

    Example:

    $api = Reader::readFromJson(<<<JSON
    {
      "openapi": "3.0.0",
      "info": {
        "title": "Test API",
        "version": "1.0.0"
      },
      "paths": {
        "/path": {
          "get": {
            "responses": {
              "200": {
                "\$ref": "#/components/schemas/notAResponse"
              }
            }
          }
        }
      },
      "components": {
        "schemas": {
          "notAResponse": {
            "type": "integer"
          }
        }
      }
    }
    JSON);
    
    var_dump($api->validate());
    

    The above code will output bool(true)

    However putting it in an OpenAPI validator will return the following

    image

    opened by charjr 1
Releases(1.7.0)
  • 1.7.0(Apr 20, 2022)

    Improvements:

    • Support for PHP 8.1, thanks @om4csaba, @shadowhand, @simPod
    • #160 Flags for json_encode() in Writer::writeToJson(), thanks @ValikoDorodnov
    Source code(tar.gz)
    Source code(zip)
  • 1.6.0(Feb 10, 2022)

    Bugfixes:

    • #100 Fixed a bug with merging PathItems where extension properties (x-*) were not present in the merge result (thanks @marcelthole)
    • #131 Adjust default value for Schema::$nullable when no type is specified. nullable will be false by default when a type is specified but null when no type is specified.
    • #77 Fixes default value for exclusiveMinimum and exclusiveMaximum only return false when minimum or maximum is specified, defaults to null otherwise.
    • #125 Fix OpenAPI v3.0 Schema Violation: Array value found, but an object is required (thanks @om4james)
    • #119 Stricter type checking when resolving references, avoid trying to call methods on array
    • #144 Catch recursion when resolving inside included file

    Dependencies:

    • #151, #134 Add Symfony 6 support (thanks @om4csaba)

    Other changes:

    • Reworked CI (thanks @simPod)
    • Added Docker environment for local development
    Source code(tar.gz)
    Source code(zip)
  • 1.5.2(May 24, 2021)

    Bugfixes:

    • #87, #102 Fix PathItem::resolveReferences() for array fields, a PHP Notice had been thrown (thanks @iZucken and @rv1971)
    • #107 Inline references does not resolve relative references (thanks @marcelthole)
    • #95 Adjust relative URLs for externalValue fields in Example Objects when inlining references.

    Documentation:

    • Fixed typos in README and CLI help (thanks @ssfinney)
    Source code(tar.gz)
    Source code(zip)
  • 1.5.1(Feb 16, 2021)

    Bugs

    • #94 Fixed resolving relative paths with multiple ../ (thanks @il-m-yamagishi)

    Documentation

    • #98 Added PHPStan Template annotations (thanks @marcelthole)
    • #96 Added missing exeption annotation to readFromJsonFile() (thanks @yorickgirard)
    Source code(tar.gz)
    Source code(zip)
  • 1.5.0(Dec 31, 2020)

    Improvements:

    • Overall performance improvements and other optimization for loading references
    • #63 Added option to only resolve external references (inlining)

    Bugfixes:

    • #74 Fix PHPDoc for exclusiveMinimum and exclusiveMaximum to boolean (thanks @canvural)
    • #92 Resolving references to external files did not work correctly on windows (thanks @Insolita)

    Other changes:

    • #80 Changed minimum Symfony YAML version from 3.0 to 3.4 (thanks @marcelthole)
    • #83 Tests are green on PHP 8 (thanks @canvural)
    Source code(tar.gz)
    Source code(zip)
  • 1.4.2(May 27, 2020)

  • 1.4.1(Apr 7, 2020)

  • 1.4.0(Mar 6, 2020)

    • #56 Added compatibility with symfony/yaml:^5.0
    • #49 Static Analysis using phpstan (@lookyman)
    • #53 Added extra validation messages for parameters (@lezhnev74)
    • #43 Improved command-line-tool output of bin/php-openapi validate (@mfrischbutter)
    • #42 Added --silent parameter to command-line-tool (@mfrischbutter)
    • #46, #52 Fix writing empty arrays to YAML file (@coatesap)
    Source code(tar.gz)
    Source code(zip)
  • 1.3.4(Feb 28, 2020)

  • 1.3.3(Dec 16, 2019)

  • 1.3.2(Dec 4, 2019)

  • 1.3.1(Oct 29, 2019)

  • 1.3.0(Oct 25, 2019)

    • #35 Symfony YAML is not limited to version 4 anymore, you can now install php-openapi in your symfony 3 project.

    • #32 References failed to resolve in directory structures when referencing other files from file in subdirectories. These references where resolved in the context of the main OpenAPI file instead of the sub-directories.

      Before this change it was necessary to manually call resolveReferences() after loading a file. Now a single call will resolve all references regardless how many levels deep.

    Source code(tar.gz)
    Source code(zip)
  • 1.2.1(Oct 24, 2019)

    • #33 Ensure semantics of empty array and null are correctly presented for security objects.
    • #37 Fixes the problem that undefined properties did throw errors when they are accessed, now their default values are returned.
    • Improved error messages when reading or writing files fails.
    Source code(tar.gz)
    Source code(zip)
  • 1.2.0(Jun 28, 2019)

  • 1.1.0(Jun 21, 2019)

    This release brings the following changes:

    • #30 Added separate classes to implement JSON Reference and JSON pointer
    • #30 Improve error handling and document navigation by providing each object with context information. Context information contains the base document and the JSON pointer to the objects position in the document. This can be used to navigate to parent and sibling elements easily. Such navigation was not possible before. It also allows for more convenient error reporting as the errors are annotated with their position in the document.
    • #29 Fixed handling of recursive structures in Schema definitions.
    • correct PHPDoc for properties @property-read was used even though properties are writeable now.
    Source code(tar.gz)
    Source code(zip)
  • 1.0.1(May 20, 2019)

    This release brings the following changes:

    • #24 Added array type to the list of constants in Type class (thanks, @scaytrase)
    • #22 Fixed normalisation of URIs on windows (thanks, @scaytrase)
    • #27 Improved overall Windows support and added tests for Windows
    Source code(tar.gz)
    Source code(zip)
  • 1.0.0(Apr 19, 2019)

    OpenAPI v3 got a JSON Schema for validating OpenAPI 3 documents (https://github.com/OAI/OpenAPI-Specification/pull/1270 and https://github.com/OAI/OpenAPI-Specification/pull/1897).

    This release adds a CLI tool for validating OpenAPI 3 documents against the JSON schema.

    Bildschirmfoto von »2019-04-19 15-46-13«

    Other improvements:

    • #19 improves handling of default values
    • #18 enables modifying and writing the schema
    Source code(tar.gz)
    Source code(zip)
  • 0.9.3-beta(Mar 22, 2019)

    • Bug 03c5e82 fix resolving references to a file without jsonPointer
    • Enh 2f1f736 allow settings context on references without resolving these (lazy resolving of references)
    Source code(tar.gz)
    Source code(zip)
  • 0.9.2-beta(Jan 3, 2019)

  • 0.9.1-beta(Dec 3, 2018)

  • 0.9.0-beta(Nov 22, 2018)

    First release. Ready for testing. This implements full coverage of the OpenAPI 3 Spec. The following functionality is available:

    • reading openapi YAML and JSON files
    • inspecting the API specification data through PHP object
    • basic validation against OpenAPI 3 spec
    • resolving of references (in the same file, as well as external files)

    Please try it on your OpenAPI spec files and report any issues you see!

    Source code(tar.gz)
    Source code(zip)
Owner
Carsten Brandt
PGP: 1DEEEED0
Carsten Brandt
Generates OpenApi specification for Laravel, Lumen or Dingo using a configuration array and cebe/php-openapi

OpenApi Generator for Laravel, Lumen and Dingo. About The openapi-gen package provides a convenient way to create OpenApi specifications for Laravel,

Jean Dormehl 5 Jan 25, 2022
OpenAPI(v3) Validators for Symfony http-foundation, using `league/openapi-psr7-validator` and `symfony/psr-http-message-bridge`.

openapi-http-foundation-validator OpenAPI(v3) Validators for Symfony http-foundation, using league/openapi-psr7-validator and symfony/psr-http-message

n1215 2 Nov 19, 2021
Quickly and easily expose Doctrine entities as REST resource endpoints with the use of simple configuration with annotations, yaml, json or a PHP array.

Drest Dress up doctrine entities and expose them as REST resources This library allows you to quickly annotate your doctrine entities into restful res

Lee Davis 88 Nov 5, 2022
Jane is a set of libraries to generate Models & API Clients based on JsonSchema / OpenAPI specs

Jane is a set of libraries to generate Models & API Clients based on JsonSchema / OpenAPI specs Documentation Documentation is available at http://jan

Jane 438 Dec 18, 2022
It validates PSR-7 messages (HTTP request/response) against OpenAPI specifications

OpenAPI PSR-7 Message (HTTP Request/Response) Validator This package can validate PSR-7 messages against OpenAPI (3.0.x) specifications expressed in Y

The League of Extraordinary Packages 421 Jan 3, 2023
Behat extension for those who want to write acceptances tests for apis

Behapi Behat extension to help write describe features related to HTTP APIs. PHP 7.3, Behat 3.7 and a discoverable php-http client are required to mak

Baptiste Clavié 32 Nov 25, 2022
This is an attempt to re-write the official TRA VFD's API in a developer friendly way.

TRA VFD API Documentation This is an attempt to re-write the official TRA VFD's API in a developer friendly way. The current documentation is written

Alpha Olomi 15 Jan 7, 2022
Collection of value objects that represent the PHP code units

sebastian/code-unit Collection of value objects that represent the PHP code units. Installation You can add this library as a local, per-project depen

Sebastian Bergmann 740 Dec 29, 2022
ObjectHydrator - Object Hydration library to create Command and Query objects.

Object Hydrator This is a utility that converts structured request data (for example: decoded JSON) into a complex object structure. The intended use

EventSauce 264 Dec 14, 2022
Content Negotiation tools for PHP.

Negotiation Negotiation is a standalone library without any dependencies that allows you to implement content negotiation in your application, whateve

William Durand 1.3k Dec 22, 2022
A simple PHP project to make API requests on your cPanel installation

A simple PHP project to make API requests on your cPanel installation. This allows you to call modules inside the installation and interact with them to add, show or list data such as domains, e-mail accounts, databases and so on.

Elias Häußler 0 Sep 15, 2022
The efficient and elegant JSON:API 1.1 server library for PHP

Woohoo Labs. Yin Woohoo Labs. Yin is a PHP framework which helps you to build beautifully crafted JSON:APIs. Table of Contents Introduction Features W

Woohoo Labs. 237 Nov 28, 2022
The efficient and elegant, PSR-7 compliant JSON:API 1.1 client library for PHP

Woohoo Labs. Yang Woohoo Labs. Yang is a PHP framework which helps you to communicate with JSON:API servers more easily. Table of Contents Introductio

Woohoo Labs. 160 Oct 16, 2022
JSON:API serializer for PHP resources

kwai-jsonapi A JSON:API serializer for PHP classes using PHP attributes. Currently, this library has no support for links. Installation composer requi

Franky Braem 1 Jan 19, 2022
PHP implementation of JSON schema. Fork of the http://jsonschemaphpv.sourceforge.net/ project

JSON Schema for PHP A PHP Implementation for validating JSON Structures against a given Schema with support for Schemas of Draft-3 or Draft-4. Feature

Justin Rainbow 3.4k Dec 26, 2022
The maker bundle allows you to generate content elements, front end modules

Contao 4 maker bundle The maker bundle allows you to generate content elements, front end modules, event listener, callbacks and hooks using interacti

Contao 7 Aug 3, 2022
A PSR-15 middleware to handle content negotiation

Content negotiation middleware Motivation Packages like middlewares/negotiation do a very good job to detect the correct content type based on the Acc

Luís Cobucci 47 Nov 16, 2022
A lightweight middleware to make api routing session capable.

Laravel stateless session A lightweight middleware to make api routing session capable. Installing $ composer require overtrue/laravel-stateless-sessi

安正超 17 Jul 6, 2022
Laravel API 文档生成器,可以将基于 Laravel 项目的项目代码,自动生成 json 或 md 格式的描述文件。

Thresh Laravel API 文档生成器,可以将基于 Laravel 项目的项目代码,自动生成 json 或 md 格式的描述文件。 安装 $ composer require telstatic/thresh -vvv 功能 生成 Markdown 文档 生成 Postman 配置文件 生

静止 5 Jul 12, 2021