Skip to content

Unable to get custom functions and rules working #665

Open
@erunion

Description

@erunion

I am running 0.17.0 and am having difficulty getting custom functions and rulesets with those working. I have followed the tutorial on https://quobix.com/vacuum/api/custom-javascript-functions/#tutorial and here's my ruleset YAML:

extends: [[vacuum:oas, off]]
rules:
  sample-paths-rule:
    description: Load a custom function that checks for a single path
    severity: error
    recommended: true
    formats: [oas2, oas3]
    given: $.paths
    then:
      function: checkSinglePath
    howToFix: use a spec with only a single path defined.

I have placed checkSinglePath.js into a ./vacuum directory and am running Vacuum with the following:

npx vacuum lint --no-clip --ruleset vacuum.yaml -d -f ./vacuum openapi-v2-public.json --show-rules --no-style


██╗   ██╗ █████╗  ██████╗██╗   ██╗██╗   ██╗███╗   ███╗
██║   ██║██╔══██╗██╔════╝██║   ██║██║   ██║████╗ ████║
██║   ██║███████║██║     ██║   ██║██║   ██║██╔████╔██║
╚██╗ ██╔╝██╔══██║██║     ██║   ██║██║   ██║██║╚██╔╝██║
 ╚████╔╝ ██║  ██║╚██████╗╚██████╔╝╚██████╔╝██║ ╚═╝ ██║
  ╚═══╝  ╚═╝  ╚═╝ ╚═════╝ ╚═════╝  ╚═════╝ ╚═╝     ╚═╝


version: 0.17.0 | compiled: Sun, 08 Jun 2025 18:08:07 UTC
🔗 https://quobix.com/vacuum | https://github.com/daveshanley/vacuum


INFO: Located custom javascript function: 'checkSinglePath'
INFO: Loaded 1 custom function(s) successfully.
The following rules are being used:

►   [1] oas3-missing-example: (Check schemas, headers, parameters and media types all have examples present.)
►   [2] oas3-api-servers: (Validate API server definitions)
►   [3] duplicated-entry-in-enum: (Check for duplicate enum entries)
►   [4] oas3-schema: (Check spec is valid OpenAPI 3)
►   [5] oas2-discriminator: (Discriminator check)
►   [6] oas-schema-check: (schemas must have a valid type defined)
►   [7] operation-operationId-unique: (Check operations for unique operationId)
►   [8] no-$ref-siblings: (Check for siblings to $ref values)
►   [9] path-item-refs: (Check path items have not used references)
►  [10] operation-tag-defined: (Check operation tags exist globally)
►  [11] oas2-parameter-description: (Check parameter description)
►  [12] path-declarations-must-exist: (Check path parameter declarations)
►  [13] operation-operationId-valid-in-url: (Check operationId is URL friendly)
►  [14] paths-kebab-case: (Path segments must be kebab-case only)
►  [15] component-description: (Check component description)
►  [16] no-ambiguous-paths: (No ambiguous paths, each path must resolve unambiguously)
►  [17] info-license-spdx: (Check license object for URL or identifier, but not both)
►  [18] path-keys-no-trailing-slash: (Check path for any trailing slashes)
►  [19] oas3-operation-security-defined: (Check operation security)
►  [20] typed-enum: (Check enum types)
►  [21] oas2-host-not-example: (Check server URLs for example.com)
►  [22] oas3-unused-component: (Check for unused components)
►  [23] no-script-tags-in-markdown: (Check descriptions for '<script>' tags)
►  [24] path-params: (Check path validity and definition)
►  [25] oas2-oneOf: (Check for invalid use of 'oneOf')
►  [26] description-duplication: (Check descriptions for duplicates)
►  [27] oas3-example-external-check: (Check schemas, headers, parameters and media types use either 'example' or 'externalValue' but not both.)
►  [28] oas3-valid-schema-example: (Check all example schemas are valid)
►  [29] operation-description: (Check operation description)
►  [30] operation-parameters: (Check operation parameters)
►  [31] operation-tags: (Check operation tags are used)
►  [32] operation-operationId: (Check operations for an operationId)
►  [33] oas2-schema: (Check schema is valid OpenAPI 2)
►  [34] oas2-api-schemes: (Check host schemes are defined)
►  [35] oas2-anyOf: (Check for invalid use of 'anyOf')
►  [36] oas2-api-host: (Check spec for 'host' value)
►  [37] no-http-verbs-in-path: (Paths cannot contain HTTP verbs as segments)
►  [38] oas2-operation-security-defined: (Check operation security)
►  [39] info-description: (Check for a specification description)
►  [40] operation-success-response: (Check operations for success response)
►  [41] oas3-parameter-description: (Check parameter description)
►  [42] no-request-body: (Check GET and DELETE methods do not accept request bodies)
►  [43] no-eval-in-markdown: (Check descriptions for  'eval()' statements)
►  [44] oas2-unused-definition: (Check for unused definitions)
►  [45] oas2-operation-formData-consume-check: (Check operation parameter 'formData' definition)
►  [46] oas2-host-trailing-slash: (Check host for trailing slash)
►  [47] path-not-include-query: (Check path excludes query string)
►  [48] oas3-no-$ref-siblings: (Check for siblings to $ref values)


INFO: Linting file 'openapi-v2-public.json' against 1 rules: https://quobix.com/vacuum/rulesets/no-rules

Have I screwed something up in the way I am configuring this custom rule?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions