文件操作 - stepId-unique.test.ts
返回文件管理
返回主菜单
删除本文件
文件: /var/www/OLD/node_modules/@redocly/openapi-core/src/rules/arazzo/__tests__/stepId-unique.test.ts
编辑文件内容
import { outdent } from 'outdent'; import { lintDocument } from '../../../lint'; import { parseYamlToDocument, replaceSourceWithRef, makeConfig } from '../../../../__tests__/utils'; import { BaseResolver } from '../../../resolve'; describe('Arazzo stepId-unique', () => { 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: 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 - 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 - 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 `stepId` is not unique amongst all steps described in the workflow', async () => { const results = await lintDocument({ externalRefResolver: new BaseResolver(), document, config: await makeConfig({ rules: { 'stepId-unique': 'error' }, }), }); expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(` [ { "location": [ { "pointer": "#/workflows/1/steps/1", "reportOnKey": false, "source": "arazzo.yaml", }, ], "message": "The \`stepId\` must be unique amongst all steps described in the workflow.", "ruleId": "stepId-unique", "severity": "error", "suggest": [], }, ] `); }); it('should not report when the `stepId` is not unique amongst all steps described in the workflow', async () => { const results = await lintDocument({ externalRefResolver: new BaseResolver(), document, config: await makeConfig({ rules: {}, }), }); expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`); }); });
修改文件时间
将文件时间修改为当前时间的前一年
删除文件