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

heisenbug with openapi 3.1.* schema #272

Open
vividsnow opened this issue Feb 13, 2024 · 0 comments
Open

heisenbug with openapi 3.1.* schema #272

vividsnow opened this issue Feb 13, 2024 · 0 comments

Comments

@vividsnow
Copy link

  • JSON::Validator version: 5.14
  • Perl version: 5.36, 5.38 (non-system)
  • Operating system: debian stable/unstable

Steps to reproduce the behavior

Given script:

use strict;
use JSON::Validator::Schema::OpenAPIv3;

my $yaml = <<~\in;
openapi: 3.1.0

info:
  version: 1.0
  title: whatever

components:
  parameters:
    Id:
      in: path
      name: id
      schema:
        $ref: '#/components/schemas/IdType'
      required: true

  schemas:
    IdType:
      type: integer
in

my ($ok, $nok) = (0, 0);
for (1..100) {
    my $js = JSON::Validator::Schema::OpenAPIv3->new(
        $yaml,
        specification => 'https://spec.openapis.org/oas/3.1/schema/2021-05-20'
    );
    $ok++, next unless $js->is_invalid;
    $nok++;
    print "$_\n" for @{$js->errors};
}
print "ok: $ok, nok: $nok\n";

running as perl -E 'system q(perl json-validator.pl) for 1..10'

Expected behavior

Expecting having valid schema every run:

...
ok: 100, nok: 0
...

Actual behavior

Getting random fails:

ok: 100, nok: 0
/components/parameters/Id/$ref: Missing property.
...
ok: 95, nok: 5
/components/parameters/Id/$ref: Missing property.
...
ok: 97, nok: 3
ok: 100, nok: 0
ok: 100, nok: 0
/components/parameters/Id/$ref: Missing property.
...
ok: 97, nok: 3
/components/parameters/Id/$ref: Missing property.
...
ok: 95, nok: 5
/components/parameters/Id/$ref: Missing property.
...
ok: 86, nok: 14
/components/parameters/Id/$ref: Missing property.
...
ok: 97, nok: 3
/components/parameters/Id/$ref: Missing property.
...
ok: 96, nok: 4
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

1 participant