Redocly / Redocly/redocly-cli

Improve error output for this case, invalid rule fails

Open
#2,022 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

p3 Type: Bug
Dominant language
TypeScript
Stars
1.5k
Forks
228
Avg merge
1d 14h
Merged PRs (30d)
48

Description

https://github.com/Redocly/redocly-cli/blob/35fd19861dadc6670cfe724ed22e3944dda0b38d/packages/core/src/rules/common/assertions/utils.ts#L88

How can we improve this error output? Is there some way to reference the rule that is failing?

The extension completely fails when this error is encountered, is there a way to log the error but continue validation? The other option may be to output a notification in VS Code for those users.

I incorrectly used the property keyword with defined: true and a sibling disallowed assertion on this rule. changing it to required: ["get"] and removing property fixes the issue

rules:
  rule/paths-meta-must-only-define-get-operation:
    severity: error
    message: '"/meta" MUST only define a GET operation'
    subject:
      type: PathItem
      matchParentKeys: /\/meta$/
      property: get
    assertions:
      defined: true
      disallowed:
        - post
        - put
        - patch
        - delete
openapi: 3.0.4
info:
  title: test
  version: 1.0.0
paths:
  '/thing/meta':
     delete: 
      summary: thing meta
      responses:
        '204':
          description: No Content

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at packages/core/src/rules/common/assertions/utils.ts:88 and reproduce the failure with the rule and OpenAPI example in the issue. Trace how the invalid assertion error is reported and determine a clear completion criterion for identifying the failing rule and handling validation without the extension failing.

Written by the indexing model from the issue text.

Assessment

Tech stack
openapi, typescript
Domain
api, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.