Skip to content

Required assertion function for lists of strings #1406

@tatomyr

Description

@tatomyr

Is your feature request related to a problem? Please describe.

Redocly CLI configurable rules allow using the required assertion function to check whether an object contains specified keys.
However, currently there's no way to check if a list contains specific words.

Describe the solution you'd like

Either allow the required assertion to be applied against lists of strings, or introduce a separate assertion function (i.e. contains) which will take a list of required words to check.

Describe alternatives you've considered

Implementing a custom assertion function through a plugin.

Additional context

This came from a real case when we couldn't enforce page and items properties to be set in the required list for a specific kind of schemas:

type: object
properties:
  object:
    type: string
    const: list
  page:
    $ref: ../Page.yaml
  items:
    type: array
    minItems: 0
    items:
      $ref: ./PullRequest.yaml
required:
  - object
  - page # <-- required to be in the `required`
  - items # <-- required to be in the `required`

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions