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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeExtension isn't available to configurable rules #1223

Open
lornajane opened this issue Aug 8, 2023 · 0 comments · May be fixed by #1520
Open

TypeExtension isn't available to configurable rules #1223

lornajane opened this issue Aug 8, 2023 · 0 comments · May be fixed by #1520
Assignees
Labels
configurable rules governance Issues relating to problems with or requests for API governance/linting/decorating p2 Type: Bug Something isn't working

Comments

@lornajane
Copy link
Collaborator

Describe the bug

I used a custom plugin and added a new type to my type tree. I expected to be able to use the type as a subject in a configurable rule, but I get the error ``type can be one of the following only: "any", "Root", "Tag", "TagList", ... as if my new type isn't available. I think the type is correctly added because the `spec` rule picks up if the structure of the data isn't correct.

To Reproduce
Steps to reproduce the behavior:

  1. With a custom plugin plugins/type-extension.js that contains the following code:
const XMetaData = {
  properties: {
    lifecycle: { type: 'string'},
    'owner-team': { type: 'string'},
  },
  required: ['lifecycle']
};

module.exports = {
  id: 'type-extension',
  typeExtension: {
    oas3(types) {
      newTypes = {
        ...types,
        XMetaData: XMetaData,
        Info: {
          ...types.Info,
          properties: {
            ...types.Info.properties,
            'x-metadata': 'XMetaData',
          }
        }
      };
      return newTypes;
    }
  }
};

  1. Given this redocly.yaml file
extends: []

plugins:
  - 'plugins/type-extension.js'

rules:
  spec: warn
  rule/metadata-lifecycle:
    subject:
      type: XMetaData
      property: lifecycle
    assertions:
      enum: ["alpha", "beta", "production", "deprecated"]
  1. And an OpenAPI file with this (snippet from the start of the file)
  x-metadata:
    lifecycle: production
    owner-team: Engineering/Integrations
  1. Run this command with these arguments... redocly lint openapi.yaml
  2. See error

Expected behavior

I want to be able to write a configurable rule that uses the new type.

Redocly Version(s)

1.0.0

Node.js Version(s)
v16.20.0

@lornajane lornajane added the Type: Bug Something isn't working label Aug 8, 2023
@tatomyr tatomyr added the p2 label Aug 15, 2023
@lornajane lornajane mentioned this issue Sep 11, 2023
11 tasks
@lornajane lornajane added the governance Issues relating to problems with or requests for API governance/linting/decorating label Nov 17, 2023
@DmitryAnansky DmitryAnansky self-assigned this Mar 27, 2024
@DmitryAnansky DmitryAnansky linked a pull request Apr 10, 2024 that will close this issue
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
configurable rules governance Issues relating to problems with or requests for API governance/linting/decorating p2 Type: Bug Something isn't working
Projects
None yet
3 participants