question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Ignore errors settings

See original GitHub issue

I’m using OAS3.0.3 and heavily using JSON Schema defined external references. Each of these files indicates the $schema keyword and this is not supported in 3.0.x. My linting report is showing me over 90 thousand errors for $schema is not expected here. How can I add a specific output message to the ignore list rather than the entire “spec” error. I don’t want to ignore all spec errors, only this particular one.

2:3     error    spec  Property `$schema` is not expected here.

 Validation failed with 91051 errors and 705 warnings.

This is my ignore file but it’s not picking up the ignore request. My intention is to lint an entire folder with the * and I want to ignore all occurrences in any folder

# This file instructs Redocly's linter to ignore the rules contained for specific parts of your API.
# See https://redoc.ly/docs/cli/ for more information.
api-library-releases/*:
  spec:
    - '#/$schema'

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:14 (13 by maintainers)

github_iconTop GitHub Comments

2reactions
xavianaxwcommented, Nov 11, 2022

I’ve given this a go since I had a similar scenario. Here is the code that I’ve used.

module.exports = {
  id: 'extend-id-and-schema',
  typeExtension: {
    oas3(types) {
      return {
        ...types,
        Schema: {
          ...types.Schema,
          properties: {
            ...types.Schema.properties,
            $id: { type: 'string' },
            $schema: { type: 'string' }
          }
        }
      };
    },
  }
};

which I then added to my .redocly.yaml

plugins: 
  -  src/schemata/plugins/extend-id-and-schema.js

Bonus content. I’ve also added an example below to depict how one would make $id and $schema required in your Operation > 200 only Responses > Schema

apis:
  main@v1:
    rules:
      assert/required-id-and-schema:
        where:
          - subject: 
              type: Operation
              property: operationId
            assertions: 
              pattern: ^((?!(smoke|health)).)*$ # this are some internal endpoints that I excluded 
          - subject:
              type: Response
              filterInParentKeys:
                - '200'
            assertions: 
              defined: true
        subject: 
          type: Schema
        assertions:
          defined: true
          required: 
            - $id
            - $schema
        message: Must have $id and $schema in Schema properties
        severity: error

Hope that helps someone 😃

1reaction
adamaltmancommented, Dec 16, 2022

@bandantonio it would be great to turn this into a guide.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Manage errors in APM: Collect, ignore, or mark as expected
Go to the Server-side configuration menu for the application that has errors that you want to ignore. Under Error collection, look for Ignore...
Read more >
How to Ignore All Errors in Excel & Google Sheets
2. In the Excel Options window, (1) go to the Formulas tab, (2) uncheck Enable background error checking, and (3) click OK ...
Read more >
Ignoring Errors - PHPStan
To ignore errors by a regular expression only in a specific file, add an entry with message or messages and path or paths...
Read more >
Using ignore errors for optional steps and actions - Uptrends
Think of the ignore errors option as a way to insert a conditional statement. You can either set ignore errors at the step...
Read more >
How to Ignore All Errors in Microsoft Excel - groovyPost
Open your Excel spreadsheet. · Select the cell (or cells) containing the error messages. · Click the warning icon that appears next to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found