Skip to content

Commit

Permalink
feat: added 1.0.1 arazzo version to spot supported versions rule (#1879)
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitryAnansky authored Feb 4, 2025
1 parent 62f6412 commit be6bbf2
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/big-kings-sort.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@redocly/openapi-core": patch
---

Added support for Arazzo version 1.0.1 in Spot validation rules.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,36 @@ import { parseYamlToDocument, replaceSourceWithRef, makeConfig } from '../../../
import { BaseResolver } from '../../../resolve';

describe('Arazzo spot-supported-versions', () => {
const document = parseYamlToDocument(
const documentWithUnsupportedVersion = parseYamlToDocument(
outdent`
arazzo: '1.0.2'
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
`,
'arazzo.yaml'
);

const documentWithSupportedVersion = parseYamlToDocument(
outdent`
arazzo: '1.0.1'
info:
Expand Down Expand Up @@ -36,7 +65,7 @@ describe('Arazzo spot-supported-versions', () => {
it('should report on arazzo version error', async () => {
const results = await lintDocument({
externalRefResolver: new BaseResolver(),
document,
document: documentWithUnsupportedVersion,
config: await makeConfig({
rules: { 'spot-supported-versions': 'error' },
}),
Expand All @@ -52,7 +81,7 @@ describe('Arazzo spot-supported-versions', () => {
"source": "arazzo.yaml",
},
],
"message": "Only 1.0.0 Arazzo version is supported by Spot.",
"message": "Only 1.0.0, 1.0.1 Arazzo versions are supported by Spot.",
"ruleId": "spot-supported-versions",
"severity": "error",
"suggest": [],
Expand All @@ -61,10 +90,22 @@ describe('Arazzo spot-supported-versions', () => {
`);
});

it('should not report on arazzo version error', async () => {
it('should not report on arazzo version error when supported version is used', async () => {
const results = await lintDocument({
externalRefResolver: new BaseResolver(),
document: documentWithSupportedVersion,
config: await makeConfig({
rules: { 'spot-supported-versions': 'error' },
}),
});

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

it('should not report on arazzo version error when rule is not configured', async () => {
const results = await lintDocument({
externalRefResolver: new BaseResolver(),
document,
document: documentWithSupportedVersion,
config: await makeConfig({
rules: {},
}),
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/typings/arazzo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,4 +167,4 @@ export interface ArazzoDefinition {

export const VERSION_PATTERN = /^1\.0\.\d+(-.+)?$/;

export const ARAZZO_VERSIONS_SUPPORTED_BY_SPOT = ['1.0.0'];
export const ARAZZO_VERSIONS_SUPPORTED_BY_SPOT = ['1.0.0', '1.0.1'];

1 comment on commit be6bbf2

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements 78.6% 5053/6429
🟡 Branches 67.18% 2059/3065
🟡 Functions 73.16% 834/1140
🟡 Lines 78.88% 4767/6043

Test suite run success

836 tests passing in 120 suites.

Report generated by 🧪jest coverage report action from be6bbf2

Please sign in to comment.