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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extending with distributed rulesets #254

Closed
50rayn opened this issue Mar 30, 2023 · 8 comments
Closed

Extending with distributed rulesets #254

50rayn opened this issue Mar 30, 2023 · 8 comments
Assignees
Labels
enhancement New feature or request

Comments

@50rayn
Copy link

50rayn commented Mar 30, 2023

Hello @daveshanley , it's me again 馃槃. Having some unclear things about Rulesets, especially Extending Rulesets. I have read whole documentation on vacuum website, but I didn't find any information about extending with a shared ruleset, in my case File System option.

For example, I have openapi.yaml, main.ruleset.yaml and a folder rules with custom rulesets separated by "category". The question is, how can I include the rulesets from rules folder in main.ruleset.yaml ? I have 71 additional custom rules which a are with the original Spectral, it would be sad to miss them 馃槙

Folder structure

|-- api
|---- rules
|---- stringTypeConstraints.yaml
|---- integerAndNumberTypeConstraints
|-- main.ruleset.yaml
|-- openapi.yaml

main.ruleset.yaml

extends:
  - 'spectral:oas'
  - ./rules/stringTypeConstraints.yaml
  - ./rules/integerAndNumberTypeConstraints.yaml
  - ...

stringTypeConstraints.yaml

rules:
  string-constraints:
    description: String constraints
    message: '{{error}}'
    severity: error
    type: style
    given: $..*[?(@.type === 'string')]
    then:
      function: schema
      functionOptions:
        schema:
          anyOf:
            - type: object
              required:
                - enum
              properties:
                enum:
                  type: array
            - type: object
              required:
                - maxLength
              properties:
                maxLength:
                  type: integer
            - type: object
              required:
                - minLength
              properties:
                minLength:
                  type: integer
            - type: object
              required:
                - pattern
              properties:
                pattern:
                  type: string
...

integerAndNumberTypeConstraints.yaml

rules:
  integer-and-number-constraints:
    description: Integer and Number  constraints
    message: '{{error}}'
    severity: error
    type: style
    given: $..*[?(@.type === 'integer' || @.type === 'number')]
    then:
      function: schema
      functionOptions:
        schema:
          anyOf:
            - type: object
              required:
                - enum
              properties:
                enum:
                  type: array
            - type: object
              required:
                - maximum
              properties:
                maxLength:
                  type: integer
            - type: object
              required:
                - minimum
              properties:
                minLength:
                  type: integer
            - type: object
              required:
                - format
              properties:
                format:
                  type: string
...
@daveshanley
Copy link
Owner

Hi there,

So this feature does not yet exist in vacuum, the ability to include references to other configs.

It can be added, for sure - but there is just no code in the tool to handle this capability right now. I'll add this as a feature and add it to the backlog.

@daveshanley daveshanley added the enhancement New feature or request label Mar 30, 2023
@50rayn
Copy link
Author

50rayn commented Mar 30, 2023

Thanks in advance @daveshanley .
Will wait for news.

@ntotten
Copy link
Contributor

ntotten commented Jul 23, 2023

I'd love to see this feature as well. While we can accomplish much of this by writing custom functions, the bar of doing that is a lot higher bar as you need to build a new .so for different Go versions with vacuum releases, etc. golang/go#31354

@ankorstore-haddowg
Copy link

I have a shared ruleset distributed as an npm package i would love to be able to use with this, however that ruleset also itself extends from local js and yaml ruleset definitions any chance we could get vacuum to parse and use the js rulesets correctly too 馃ズ

@daveshanley
Copy link
Owner

I don't know what a JS ruleset looks like. Can you give me an example? I don't use Spectral myself anymore.

@daveshanley
Copy link
Owner

This feature is something I am planning on working on very soon, so the more requests and details in this ticket, the better.

@daveshanley
Copy link
Owner

This feature was implemented in v0.6.0

https://quobix.com/vacuum/rulesets/sharing/

@jjwedemyer
Copy link

Hi, does the release of v0.6.0 imply that this statement is obsolete? https://quobix.com/vacuum/rulesets/understanding/#fn:1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants