Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/dull-pigs-jump.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@redocly/cli": patch
"@redocly/openapi-core": patch
---

Updated sourceDescriptions to require a valid type, to align with the Arazzo specification.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ exports[`resolveConfig should ignore minimal from the root and read local file 1
"requestBody-replacements-unique": "warn",
"sourceDescription-name-unique": "error",
"sourceDescription-type": "error",
"sourceDescriptions-not-empty": "error",
"spec": "error",
"step-onFailure-unique": "warn",
"step-onSuccess-unique": "warn",
Expand Down Expand Up @@ -158,6 +159,7 @@ exports[`resolveStyleguideConfig should resolve extends with local file config w
"requestBody-replacements-unique": "warn",
"sourceDescription-name-unique": "error",
"sourceDescription-type": "error",
"sourceDescriptions-not-empty": "error",
"spec": "error",
"step-onFailure-unique": "warn",
"step-onSuccess-unique": "warn",
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/config/all.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ const all: PluginStyleguideConfig<'built-in'> = {
'no-criteria-xpath': 'error',
'no-actions-type-end': 'error',
'criteria-unique': 'error',
'sourceDescriptions-not-empty': 'error',
},
};

Expand Down
1 change: 1 addition & 0 deletions packages/core/src/config/minimal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ const minimal: PluginStyleguideConfig<'built-in'> = {
'no-criteria-xpath': 'off',
'no-actions-type-end': 'off',
'criteria-unique': 'off',
'sourceDescriptions-not-empty': 'off',
},
};

Expand Down
1 change: 1 addition & 0 deletions packages/core/src/config/recommended-strict.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ const recommendedStrict: PluginStyleguideConfig<'built-in'> = {
'no-criteria-xpath': 'error',
'no-actions-type-end': 'error',
'criteria-unique': 'error',
'sourceDescriptions-not-empty': 'error',
},
};

Expand Down
1 change: 1 addition & 0 deletions packages/core/src/config/recommended.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ const recommended: PluginStyleguideConfig<'built-in'> = {
'no-criteria-xpath': 'warn',
'no-actions-type-end': 'warn',
'criteria-unique': 'warn',
'sourceDescriptions-not-empty': 'error',
},
};

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
import { outdent } from 'outdent';
import { lintDocument } from '../../../lint';
import { parseYamlToDocument, replaceSourceWithRef, makeConfig } from '../../../../__tests__/utils';
import { BaseResolver } from '../../../resolve';

describe('Arazzo sourceDescriptions-not-empty', () => {
const document1 = 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
- 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
`,
'arazzo.yaml'
);

const document2 = parseYamlToDocument(
outdent`
arazzo: '1.0.0'
info:
title: Cool API
version: 1.0.0
description: A cool API
sourceDescriptions: []
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
`,
'arazzo.yaml'
);

it('should not report an error when sourceDescriptions have at least one entry.', async () => {
const results = await lintDocument({
externalRefResolver: new BaseResolver(),
document: document1,
config: await makeConfig({
rules: {},
arazzoRules: { 'sourceDescriptions-not-empty': 'error' },
}),
});

expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
});

it('should report an error when sourceDescriptions is empty list.', async () => {
const results = await lintDocument({
externalRefResolver: new BaseResolver(),
document: document2,
config: await makeConfig({
rules: {},
arazzoRules: { 'sourceDescriptions-not-empty': 'error' },
}),
});

expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
[
{
"location": [
{
"pointer": "#/sourceDescriptions",
"reportOnKey": false,
"source": "arazzo.yaml",
},
],
"message": "The \`sourceDescriptions\` list must have at least one entry.",
"ruleId": "sourceDescriptions-not-empty",
"severity": "error",
"suggest": [],
},
]
`);
});
});
Loading