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

chore: improve OAS functions #1362

Merged
merged 2 commits into from
Nov 30, 2020
Merged

chore: improve OAS functions #1362

merged 2 commits into from
Nov 30, 2020

Conversation

P0lip
Copy link
Contributor

@P0lip P0lip commented Sep 30, 2020

Fixes

spectral lint a.yaml
OpenAPI 3.x detected
TypeError: Cannot convert undefined or null to object
    at Function.keys (<anonymous>)
    at Object.oasOpIdUnique (eval at <anonymous> (/snapshot/spectral/dist/rulesets/evaluators.js:89:80), <anonymous>:1:352)
    at Object.lintNode (/snapshot/spectral/dist/runner/lintNode.js:30:33)
    at runRule (/snapshot/spectral/dist/runner/runner.js:27:24)
    at Runner.run (/snapshot/spectral/dist/runner/runner.js:98:17)
    at Spectral.runWithResolved (/snapshot/spectral/dist/spectral.js:101:22)
    at async Spectral.run (/snapshot/spectral/dist/spectral.js:113:17)
    at async Object.lint (/snapshot/spectral/dist/cli/services/linter/linter.js:50:26)
TypeError: Cannot convert undefined or null to object
    at Function.keys (<anonymous>)
    at Object.oasTagDefined (eval at <anonymous> (/snapshot/spectral/dist/rulesets/evaluators.js:89:80), <anonymous>:1:440)
    at Object.lintNode (/snapshot/spectral/dist/runner/lintNode.js:30:33)
    at runRule (/snapshot/spectral/dist/runner/runner.js:27:24)
    at Runner.run (/snapshot/spectral/dist/runner/runner.js:98:17)
    at Spectral.runWithResolved (/snapshot/spectral/dist/spectral.js:101:22)
    at async Spectral.run (/snapshot/spectral/dist/spectral.js:113:17)
    at async Object.lint (/snapshot/spectral/dist/cli/services/linter/linter.js:50:26)
TypeError: Cannot convert undefined or null to object
    at Function.keys (<anonymous>)
    at Object.oasOpSecurityDefined (eval at <anonymous> (/snapshot/spectral/dist/rulesets/evaluators.js:89:80), <anonymous>:1:6084)
    at Object.lintNode (/snapshot/spectral/dist/runner/lintNode.js:30:33)
    at runRule (/snapshot/spectral/dist/runner/runner.js:27:24)
    at Runner.run (/snapshot/spectral/dist/runner/runner.js:98:17)
    at Spectral.runWithResolved (/snapshot/spectral/dist/spectral.js:101:22)
    at async Spectral.run (/snapshot/spectral/dist/spectral.js:113:17)
    at async Object.lint (/snapshot/spectral/dist/cli/services/linter/linter.js:50:26)

/foo/path/a.yaml
 1:1  warning  info-contact      Info object should contain `contact` object.
 1:1  warning  info-description  OpenAPI object info `description` must be present and non-empty string.
 1:1  warning  oas3-api-servers  OpenAPI `servers` must be present and non-empty array.
 1:1    error  oas3-schema       Object should have required property `info`.
 1:1  warning  openapi-tags      OpenAPI object should have non-empty `tags` array.
 3:8    error  oas3-schema       `~1foo` property type should be object.

✖ 6 problems (2 errors, 4 warnings, 0 infos, 0 hints)

that was yield for the following document (nullish path)

openapi: 3.0.0
paths:
  /foo:

Other than that, I also assured that most of our OAS functions actually validate valid operations.
This wasn't the case for some of them.
Last but not least, oasOpIdUnique reports errors only for 2nd and all subsequent duplicate keys.
The first one is not considered an error.

Checklist

  • Tests added / updated
  • Docs added / updated

Does this PR introduce a breaking change?

  • Yes
  • No

@P0lip P0lip added the chore label Sep 30, 2020
@P0lip P0lip self-assigned this Sep 30, 2020
@P0lip P0lip added t/bug Something isn't working and removed chore labels Oct 1, 2020
@P0lip P0lip marked this pull request as ready for review November 30, 2020 13:30
@P0lip P0lip requested review from philsturgeon and a team November 30, 2020 13:31
philsturgeon
philsturgeon previously approved these changes Nov 30, 2020
@P0lip P0lip merged commit a459e54 into develop Nov 30, 2020
@P0lip P0lip deleted the feat/oas-functions branch November 30, 2020 15:07
P0lip added a commit that referenced this pull request Jan 4, 2021
* chore: improve OAS functions

* fix: check for presence of operationId
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 this pull request may close these issues.

None yet

2 participants