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

oas3-valid-...-example: Only checks example, but not examples #901

Closed
m-mohr opened this issue Jan 10, 2020 · 0 comments · Fixed by #1284
Closed

oas3-valid-...-example: Only checks example, but not examples #901

m-mohr opened this issue Jan 10, 2020 · 0 comments · Fixed by #1284
Assignees
Labels
t/bug Something isn't working

Comments

@m-mohr
Copy link
Contributor

m-mohr commented Jan 10, 2020

Describe the bug

This is somewhat related to #882: All the oas-valid-...-example rules only check the examples in example, but not the examples in examples.*.value.

To Reproduce

OAS3 file adapted from the second test in src/rulesets/tests/templates/_oas-examples.ts:

    {
      openapi: '3.0.0',
      headers: {
        xoxo: {
          schema: {
            type: 'string',
          },
          examples: {
            test1: {
              value: 123
            },
          },
        },
      },
    }

If I add to the test:

  test('will fail when simple example is invalid (examples)', async () => {
    const results = await s.run({
      openapi: '3.0.0',
      [path]: {
        xoxo: {
          schema: {
            type: 'string',
          },
          examples: {
            test1: {
              value: 123
            },
          },
        },
      },
    });
    expect(results).toEqual([
      expect.objectContaining({
        severity: DiagnosticSeverity.Error,
        code: ruleName,
        message: '`examples.*.value` property type should be string',
      }),
    ]);
  });

and run: npm test "oas3-valid-oas-header", it doesn't check the examples.test.value value.

Expected behavior

All examples should be checked.

Environment (remove any that are not applicable):

  • Library version: 5.0.0
  • OS: Windows 10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
t/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants