Skip to content

Example of Openapi not valid #103

@rejinka

Description

@rejinka

I tried to validate one of the examples provided in https://github.com/OAI/OpenAPI-Specification and it does not validate. The validation error doesn't seem correct to me:

Array
(
    [/webhooks/newPet/post/requestBody/content/application~1json/schema] => Array
        (
            [0] => The required properties (openapi) are missing
        )

)

Here is a small script to reproduce the error:

<?php
declare(strict_types = 1);

require_once __DIR__ . '/vendor/autoload.php';

use Opis\JsonSchema\Validator;
use Opis\JsonSchema\Errors\ErrorFormatter;

$schema = file_get_contents('https://spec.openapis.org/oas/3.1/schema/2021-09-28');
$data   = json_decode(
    file_get_contents(
        'https://raw.githubusercontent.com/OAI/OpenAPI-Specification/f1adc846131b33be72df6a0c87e5e5da59dde0ff/examples/v3.1/webhook-example.json'
    )
);

$result = (new Validator())
    ->validate($data, $schema);

print_r((new ErrorFormatter())->format($result->error()));

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions