Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example of Openapi not valid #103

Open
rejinka opened this issue Jan 21, 2022 · 2 comments
Open

Example of Openapi not valid #103

rejinka opened this issue Jan 21, 2022 · 2 comments

Comments

@rejinka
Copy link

rejinka commented Jan 21, 2022

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://github.com/raw/OAI/OpenAPI-Specification/f1adc846131b33be72df6a0c87e5e5da59dde0ff/examples/v3.1/webhook-example.json'
    )
);

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

print_r((new ErrorFormatter())->format($result->error()));
@gskema
Copy link

gskema commented May 9, 2022

I have the same problem, was playing around with changing oas3.1 schema.
Changed "schema": { "$dynamicRef": "#meta" } to "schema": { "$ref": "#/$defs/schema" } and the changed the definition to "schema": { "$ref": "https://json-schema.org/draft/2020-12/schema" }. After that there were some problem with conditional properties that have default: false, so I removed them and it works.

My use case: I have a lot of endpoints, parameters, servers which are compiled into one final OAS object JSON file which I would like to check against the OAS schema, including any sub (JSON) schemas for parameters, responses, because each bit is written manually and there might be some human mistakes.

@karenetheridge
Copy link

it sounds like your evaluator doesn't support the $dynamicRef keyword. Support for that isn't optional, as it's a core part of the specification -- so you might want to file a bug report for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants