diff --git a/.changeset/new-falcons-unite.md b/.changeset/new-falcons-unite.md new file mode 100644 index 0000000000..da6ec1d319 --- /dev/null +++ b/.changeset/new-falcons-unite.md @@ -0,0 +1,5 @@ +--- +"@redocly/openapi-core": patch +--- + +Removed the `no-actions-type-end` Spot rule. diff --git a/docs/guides/lint-arazzo.md b/docs/guides/lint-arazzo.md index 1efa1e22cb..805a9dfb23 100644 --- a/docs/guides/lint-arazzo.md +++ b/docs/guides/lint-arazzo.md @@ -85,7 +85,6 @@ The rules available for linting Arazzo are: - `step-onFailure-unique`: the `onFailure` actions of the `step` object must be unique. - `requestBody-replacements-unique`: the `replacements` of the `requestBody` object must be unique. - `no-criteria-xpath`: the `xpath` type criteria is not supported by Spot. -- `no-actions-type-end`: the `end` type action is not supported by Spot. - `criteria-unique`: the criteria list must not contain duplicated assertions. Add the rules to `redocly.yaml`, but for Arazzo specifications, the rules go in their own configuration section called `arazzoRules`. diff --git a/docs/rules/spec-ruleset.md b/docs/rules/spec-ruleset.md index 015f0008c4..4d7b337c61 100644 --- a/docs/rules/spec-ruleset.md +++ b/docs/rules/spec-ruleset.md @@ -22,5 +22,4 @@ All the rules are of severity `error`: - `step-onFailure-unique` - `requestBody-replacements-unique` - `no-criteria-xpath` -- `no-actions-type-end` - `criteria-unique` diff --git a/docs/rules/spot/no-actions-type-end.test.md b/docs/rules/spot/no-actions-type-end.test.md deleted file mode 100644 index 3c28bab8fe..0000000000 --- a/docs/rules/spot/no-actions-type-end.test.md +++ /dev/null @@ -1,55 +0,0 @@ ---- -slug: /docs/cli/rules/spot/no-actions-type-end ---- - -# no-actions-type-end - -The `end` type action is not supported by Spot. - -| Arazzo | Compatibility | -| ------ | ------------- | -| 1.0.0 | ✅ | - -## API design principles - -This is a `Spot`-specific rule. -The `end` type action is not supported by Spot. - -## Configuration - -| Option | Type | Description | -| -------- | ------ | ------------------------------------------------------- | -| severity | string | Possible values: `off`, `warn`, `error`. Default `off`. | - -An example configuration: - -```yaml -arazzoRules: - no-actions-type-end: error -``` - -## Examples - -Given the following configuration: - -```yaml -arazzoRules: - no-actions-type-end: error -``` - -Example of an action: - -```yaml Object example -onSuccess: - - name: 'onSuccessActionName' - type: 'goto' - stepId: 'buy-ticket' -onFailure: - - name: 'onFailureActionName' - type: 'goto' - stepId: 'buy-ticket' -``` - -## Resources - -- [Rule source](https://github.com/Redocly/redocly-cli/blob/main/packages/core/src/rules/spot/no-actions-type-end.ts) diff --git a/packages/core/src/config/__tests__/__snapshots__/config-resolvers.test.ts.snap b/packages/core/src/config/__tests__/__snapshots__/config-resolvers.test.ts.snap index e0a1e725df..6236055ffa 100644 --- a/packages/core/src/config/__tests__/__snapshots__/config-resolvers.test.ts.snap +++ b/packages/core/src/config/__tests__/__snapshots__/config-resolvers.test.ts.snap @@ -6,7 +6,6 @@ exports[`resolveConfig should ignore minimal from the root and read local file 1 "arazzo1Preprocessors": {}, "arazzo1Rules": { "criteria-unique": "warn", - "no-actions-type-end": "warn", "no-criteria-xpath": "warn", "parameters-not-in-body": "warn", "parameters-unique": "error", @@ -234,7 +233,6 @@ exports[`resolveStyleguideConfig should resolve extends with local file config w "arazzo1Preprocessors": {}, "arazzo1Rules": { "criteria-unique": "warn", - "no-actions-type-end": "warn", "no-criteria-xpath": "warn", "parameters-not-in-body": "warn", "parameters-unique": "error", diff --git a/packages/core/src/config/all.ts b/packages/core/src/config/all.ts index a672dd8c52..70d884617d 100644 --- a/packages/core/src/config/all.ts +++ b/packages/core/src/config/all.ts @@ -211,7 +211,6 @@ const all: PluginStyleguideConfig<'built-in'> = { arazzo1Rules: { 'criteria-unique': 'error', 'no-criteria-xpath': 'error', - 'no-actions-type-end': 'error', 'parameters-not-in-body': 'error', 'parameters-unique': 'error', 'requestBody-replacements-unique': 'error', diff --git a/packages/core/src/config/minimal.ts b/packages/core/src/config/minimal.ts index 4e8831f7ce..04c9a0414f 100644 --- a/packages/core/src/config/minimal.ts +++ b/packages/core/src/config/minimal.ts @@ -187,7 +187,6 @@ const minimal: PluginStyleguideConfig<'built-in'> = { arazzo1Rules: { 'criteria-unique': 'off', 'no-criteria-xpath': 'off', - 'no-actions-type-end': 'off', 'parameters-not-in-body': 'off', 'parameters-unique': 'off', 'requestBody-replacements-unique': 'off', diff --git a/packages/core/src/config/recommended-strict.ts b/packages/core/src/config/recommended-strict.ts index 344226cd1a..6627ebaf8e 100644 --- a/packages/core/src/config/recommended-strict.ts +++ b/packages/core/src/config/recommended-strict.ts @@ -187,7 +187,6 @@ const recommendedStrict: PluginStyleguideConfig<'built-in'> = { arazzo1Rules: { 'criteria-unique': 'error', 'no-criteria-xpath': 'error', - 'no-actions-type-end': 'error', 'parameters-not-in-body': 'error', 'parameters-unique': 'error', 'requestBody-replacements-unique': 'error', diff --git a/packages/core/src/config/recommended.ts b/packages/core/src/config/recommended.ts index 3da554861b..6a27fad79b 100644 --- a/packages/core/src/config/recommended.ts +++ b/packages/core/src/config/recommended.ts @@ -187,7 +187,6 @@ const recommended: PluginStyleguideConfig<'built-in'> = { arazzo1Rules: { 'criteria-unique': 'warn', 'no-criteria-xpath': 'warn', - 'no-actions-type-end': 'warn', 'parameters-not-in-body': 'warn', 'parameters-unique': 'error', 'requestBody-replacements-unique': 'warn', diff --git a/packages/core/src/config/spec.ts b/packages/core/src/config/spec.ts index 7b3ebb6dd3..2374e2a080 100644 --- a/packages/core/src/config/spec.ts +++ b/packages/core/src/config/spec.ts @@ -24,7 +24,6 @@ const spec: PluginStyleguideConfig<'built-in'> = { 'step-onFailure-unique': 'error', 'requestBody-replacements-unique': 'error', 'no-criteria-xpath': 'error', - 'no-actions-type-end': 'error', 'criteria-unique': 'error', }, }; diff --git a/packages/core/src/rules/arazzo/__tests__/no-actions-type-end.test.ts b/packages/core/src/rules/arazzo/__tests__/no-actions-type-end.test.ts deleted file mode 100644 index 79ce32beba..0000000000 --- a/packages/core/src/rules/arazzo/__tests__/no-actions-type-end.test.ts +++ /dev/null @@ -1,121 +0,0 @@ -import { outdent } from 'outdent'; -import { lintDocument } from '../../../lint'; -import { parseYamlToDocument, replaceSourceWithRef, makeConfig } from '../../../../__tests__/utils'; -import { BaseResolver } from '../../../resolve'; - -describe('Arazzo no-actions-type-end', () => { - const document = parseYamlToDocument( - outdent` - arazzo: '1.0.0' - info: - title: Cool API - version: 1.0.0 - description: A cool API - sourceDescriptions: - - name: museum-api - type: openapi - url: openapi.yaml - workflows: - - workflowId: get-museum-hours - description: This workflow demonstrates how to get the museum opening hours and buy tickets. - parameters: - - in: header - name: Authorization - value: Basic Og== - steps: - - stepId: create-event - description: >- - Create a new special event. - operationPath: $sourceDescriptions.museum-api#/paths/~1special-events/post - requestBody: - payload: - name: 'Mermaid Treasure Identification and Analysis' - location: 'Under the seaaa 🦀 🎶 🌊.' - eventDescription: 'Join us as we review and classify a rare collection of 20 thingamabobs, gadgets, gizmos, whoosits, and whatsits, kindly donated by Ariel.' - dates: - - '2023-09-05' - - '2023-09-08' - price: 0 - successCriteria: - - condition: $statusCode == 201 - onSuccess: - - name: 'onSuccessActionName' - type: 'end' - stepId: 'buy-ticket' - onFailure: - - name: 'onFailureActionName' - type: 'end' - stepId: 'buy-ticket' - outputs: - createdEventId: $response.body.eventId - name: $response.body.name - - workflowId: get-museum-hours-2 - description: This workflow demonstrates how to get the museum opening hours and buy tickets. - parameters: - - in: header - name: Authorization - value: Basic Og== - steps: - - stepId: get-museum-hours - description: >- - Get museum hours by resolving request details with getMuseumHours operationId from openapi.yaml description. - operationId: museum-api.getMuseumHours - successCriteria: - - condition: $statusCode == 200 - `, - 'arazzo.yaml' - ); - - it('should report when the type `end` action exists', async () => { - const results = await lintDocument({ - externalRefResolver: new BaseResolver(), - document, - config: await makeConfig({ - rules: { 'no-actions-type-end': 'error' }, - }), - }); - - expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(` - [ - { - "location": [ - { - "pointer": "#/workflows/0/steps/0/onSuccess/0/type", - "reportOnKey": false, - "source": "arazzo.yaml", - }, - ], - "message": "The \`end\` type action is not supported by Spot.", - "ruleId": "no-actions-type-end", - "severity": "error", - "suggest": [], - }, - { - "location": [ - { - "pointer": "#/workflows/0/steps/0/onFailure/0/type", - "reportOnKey": false, - "source": "arazzo.yaml", - }, - ], - "message": "The \`end\` type action is not supported by Spot.", - "ruleId": "no-actions-type-end", - "severity": "error", - "suggest": [], - }, - ] - `); - }); - - it('should not report when the type `end` action exists', async () => { - const results = await lintDocument({ - externalRefResolver: new BaseResolver(), - document, - config: await makeConfig({ - rules: {}, - }), - }); - - expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`); - }); -}); diff --git a/packages/core/src/rules/arazzo/index.ts b/packages/core/src/rules/arazzo/index.ts index 2893075f35..8e546f360c 100644 --- a/packages/core/src/rules/arazzo/index.ts +++ b/packages/core/src/rules/arazzo/index.ts @@ -13,7 +13,6 @@ import { StepOnSuccessUnique } from './step-onSuccess-unique'; import { StepOnFailureUnique } from './step-onFailure-unique'; import { RequestBodyReplacementsUnique } from './requestBody-replacements-unique'; import { NoCriteriaXpath } from '../spot/no-criteria-xpath'; -import { NoActionsTypeEnd } from '../spot/no-actions-type-end'; import { CriteriaUnique } from './criteria-unique'; import type { Arazzo1Rule } from '../../visitors'; @@ -35,7 +34,6 @@ export const rules: Arazzo1RuleSet<'built-in'> = { 'step-onFailure-unique': StepOnFailureUnique, 'requestBody-replacements-unique': RequestBodyReplacementsUnique, 'no-criteria-xpath': NoCriteriaXpath, - 'no-actions-type-end': NoActionsTypeEnd, 'criteria-unique': CriteriaUnique, }; diff --git a/packages/core/src/rules/spot/no-actions-type-end.ts b/packages/core/src/rules/spot/no-actions-type-end.ts deleted file mode 100644 index 8383e9890a..0000000000 --- a/packages/core/src/rules/spot/no-actions-type-end.ts +++ /dev/null @@ -1,27 +0,0 @@ -import type { Arazzo1Rule } from '../../visitors'; -import type { UserContext } from '../../walk'; - -export const NoActionsTypeEnd: Arazzo1Rule = () => { - return { - FailureActionObject: { - enter(action, { report, location }: UserContext) { - if (action.type === 'end') { - report({ - message: 'The `end` type action is not supported by Spot.', - location: location.child(['type']), - }); - } - }, - }, - SuccessActionObject: { - enter(action, { report, location }: UserContext) { - if (action.type === 'end') { - report({ - message: 'The `end` type action is not supported by Spot.', - location: location.child(['type']), - }); - } - }, - }, - }; -}; diff --git a/packages/core/src/types/redocly-yaml.ts b/packages/core/src/types/redocly-yaml.ts index 1f7c77fafe..356357c75a 100644 --- a/packages/core/src/types/redocly-yaml.ts +++ b/packages/core/src/types/redocly-yaml.ts @@ -154,7 +154,6 @@ const builtInArazzo1Rules = [ 'step-onFailure-unique', 'requestBody-replacements-unique', 'no-criteria-xpath', - 'no-actions-type-end', 'criteria-unique', ] as const;