Skip to content
Open
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
2 changes: 1 addition & 1 deletion docs/@v1/rules/oas/request-mime-type.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
slug: /docs/cli/v1/rules/oas/request-mine-type
slug: /docs/cli/v1/rules/oas/request-mime-type
---

# request-mime-type
Expand Down
2 changes: 1 addition & 1 deletion docs/@v2/rules/oas/request-mime-type.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
slug: /docs/cli/rules/oas/request-mine-type
slug: /docs/cli/rules/oas/request-mime-type
---

# request-mime-type
Expand Down
10 changes: 5 additions & 5 deletions docs/@v2/rules/respect/x-security-scheme-required-values.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
slug: /docs/cli/rules/respect/x-security-schema-required-values
slug: /docs/cli/rules/respect/x-security-scheme-required-values
---

# x-security-schema-required-values
# x-security-scheme-required-values

Validate that `x-security` has all required `values` described according to the used `scheme`.

Expand All @@ -25,7 +25,7 @@ An example configuration:

```yaml
arazzo1Rules:
x-security-schema-required-values: error
x-security-scheme-required-values: error
```

## Examples
Expand All @@ -34,7 +34,7 @@ Given the following configuration:

```yaml
arazzo1Rules:
x-security-schema-required-values: error
x-security-scheme-required-values: error
```

Example of an entry:
Expand All @@ -55,4 +55,4 @@ Example of an entry:

## Resources

- [Rule source](https://github.com/Redocly/redocly-cli/blob/main/packages/core/src/rules/respect/x-security-schema-required-values.ts)
- [Rule source](https://github.com/Redocly/redocly-cli/blob/main/packages/core/src/rules/respect/x-security-scheme-required-values.ts)
2 changes: 2 additions & 0 deletions packages/core/src/__tests__/lint.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ describe('lint', () => {
},
],
"message": "Operation object should contain \`operationId\` field.",
"reference": "https://redocly.com/docs/cli/rules/oas/operation-operationId",
"ruleId": "operation-operationId",
"severity": "warn",
"suggest": [],
Expand Down Expand Up @@ -2025,6 +2026,7 @@ describe('lint', () => {
},
],
"message": "Can't resolve $ref: ENOENT: no such file or directory 'custom-rules.yaml'",
"reference": "https://redocly.com/docs/cli/rules/oas/no-unresolved-refs",
"ruleId": "configuration no-unresolved-refs",
"severity": "error",
"suggest": [],
Expand Down
72 changes: 36 additions & 36 deletions packages/core/src/__tests__/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,21 +142,23 @@ describe('utils', () => {
describe('validateMimeType', () => {
it('should validate mime type without reporting errors', () => {
const report = vi.fn();
validateMimeType(
{ type: 'consumes', value: { consumes: ['application/json'] } },
{ report, location: { child: () => ({ key: () => ({}) as any }) } } as any,
['application/json']
);
validateMimeType({
type: 'consumes',
value: { consumes: ['application/json'] },
ctx: { report, location: { child: () => ({ key: () => ({}) as any }) } } as any,
allowedValues: ['application/json'],
});
expect(report).not.toHaveBeenCalled();
});

it('should report error for invalid mime type', () => {
const report = vi.fn();
validateMimeType(
{ type: 'consumes', value: { consumes: ['text/plain'] } },
{ report, location: { child: () => ({ key: () => ({}) as any }) } } as any,
['application/json']
);
validateMimeType({
type: 'consumes',
value: { consumes: ['text/plain'] },
ctx: { report, location: { child: () => ({ key: () => ({}) as any }) } } as any,
allowedValues: ['application/json'],
});
expect(report).toHaveBeenCalledWith({
message: 'Mime type "text/plain" is not allowed',
location: {},
Expand All @@ -165,43 +167,43 @@ describe('utils', () => {

it('should throw error if allowedValues is not provided', () => {
expect(() =>
validateMimeType(
{ type: 'consumes', value: { consumes: ['application/json'] } },
{ report: () => {}, location: { child: () => ({ key: () => ({}) as any }) } } as any,
validateMimeType({
type: 'consumes',
value: { consumes: ['application/json'] },
ctx: { report: () => {}, location: { child: () => ({ key: () => ({}) as any }) } } as any,
// @ts-expect-error
undefined
)
allowedValues: undefined,
})
).toThrow('Parameter "allowedValues" is not provided for "request-mime-type" rule');
});
});

describe('validateMimeTypeOAS3', () => {
it('should validate mime type without reporting errors', () => {
const report = vi.fn();
validateMimeTypeOAS3(
{
type: 'consumes',
value: { content: { 'application/json': { schema: { type: 'string' } } } },
},
{
validateMimeTypeOAS3({
type: 'consumes',
value: { content: { 'application/json': { schema: { type: 'string' } } } },
ctx: {
report,
location: { child: () => ({ child: () => ({ key: () => ({}) as any }) }) },
} as any,
['application/json']
);
allowedValues: ['application/json'],
});
expect(report).not.toHaveBeenCalled();
});

it('should report error for invalid mime type', () => {
const report = vi.fn();
validateMimeTypeOAS3(
{ type: 'consumes', value: { content: { 'text/plain': { schema: { type: 'string' } } } } },
{
validateMimeTypeOAS3({
type: 'consumes',
value: { content: { 'text/plain': { schema: { type: 'string' } } } },
ctx: {
report,
location: { child: () => ({ child: () => ({ key: () => ({}) as any }) }) },
} as any,
['application/json']
);
allowedValues: ['application/json'],
});
expect(report).toHaveBeenCalledWith({
message: 'Mime type "text/plain" is not allowed',
location: {},
Expand All @@ -210,18 +212,16 @@ describe('utils', () => {

it('should throw error if allowedValues is not provided', () => {
expect(() =>
validateMimeTypeOAS3(
{
type: 'consumes',
value: { content: { 'application/json': { schema: { type: 'string' } } } },
},
{
validateMimeTypeOAS3({
type: 'consumes',
value: { content: { 'application/json': { schema: { type: 'string' } } } },
ctx: {
report: () => {},
location: { child: () => ({ child: () => ({ key: () => ({}) as any }) }) },
} as any,
// @ts-expect-error
undefined
)
allowedValues: undefined,
})
).toThrow('Parameter "allowedValues" is not provided for "request-mime-type" rule');
});
});
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/__tests__/walk.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1607,6 +1607,7 @@ describe('context.report', () => {
},
],
"message": "MY ERR DESCRIPTION: Info object should contain \`contact\` field.",
"reference": "https://redocly.com/docs/cli/rules/oas/info-contact",
"ruleId": "info-contact",
"severity": "error",
"suggest": [],
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/config/__tests__/load.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ describe('loadConfig', () => {
},
],
"message": "Can't resolve $ref: ENOENT: no such file or directory 'fixtures/resolve-refs-in-config/wrong-ref.yaml'",
"reference": "https://redocly.com/docs/cli/rules/oas/no-unresolved-refs",
"ruleId": "configuration no-unresolved-refs",
"severity": "warn",
"suggest": [],
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/rules/__tests__/spec-ruleset.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ describe('spec ruleset', () => {
},
],
"message": "Don't put query string items in the path, they belong in parameters with \`in: query\`.",
"reference": "https://redocly.com/docs/cli/rules/oas/path-not-include-query",
"ruleId": "path-not-include-query",
"severity": "error",
"suggest": [],
Expand Down Expand Up @@ -57,6 +58,7 @@ describe('spec ruleset', () => {
},
],
"message": "Path parameter \`test\` is not used in the path \`/pets?id\`.",
"reference": "https://redocly.com/docs/cli/rules/oas/path-parameters-defined",
"ruleId": "path-parameters-defined",
"severity": "error",
"suggest": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ describe('Arazzo criteria-unique', () => {
},
],
"message": "The Step SuccessCriteria items must be unique.",
"reference": "https://redocly.com/docs/cli/rules/arazzo/criteria-unique",
"ruleId": "criteria-unique",
"severity": "error",
"suggest": [],
Expand All @@ -114,6 +115,7 @@ describe('Arazzo criteria-unique', () => {
},
],
"message": "The Step SuccessCriteria items must be unique.",
"reference": "https://redocly.com/docs/cli/rules/arazzo/criteria-unique",
"ruleId": "criteria-unique",
"severity": "error",
"suggest": [],
Expand All @@ -127,6 +129,7 @@ describe('Arazzo criteria-unique', () => {
},
],
"message": "The SuccessAction criteria items must be unique.",
"reference": "https://redocly.com/docs/cli/rules/arazzo/criteria-unique",
"ruleId": "criteria-unique",
"severity": "error",
"suggest": [],
Expand All @@ -140,6 +143,7 @@ describe('Arazzo criteria-unique', () => {
},
],
"message": "The FailureAction criteria items must be unique.",
"reference": "https://redocly.com/docs/cli/rules/arazzo/criteria-unique",
"ruleId": "criteria-unique",
"severity": "error",
"suggest": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ describe('Arazzo no-criteria-xpath', () => {
},
],
"message": "The \`xpath\` type criteria is not supported by Respect.",
"reference": "https://redocly.com/docs/cli/rules/respect/no-criteria-xpath",
"ruleId": "no-criteria-xpath",
"severity": "error",
"suggest": [],
Expand All @@ -106,6 +107,7 @@ describe('Arazzo no-criteria-xpath', () => {
},
],
"message": "The \`xpath\` type criteria is not supported by Respect.",
"reference": "https://redocly.com/docs/cli/rules/respect/no-criteria-xpath",
"ruleId": "no-criteria-xpath",
"severity": "error",
"suggest": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ describe('Arazzo no-x-security-scheme-name-without-openapi', () => {
},
],
"message": "The \`schemeName\` can be only used in Step with OpenAPI operation, please use \`scheme\` instead.",
"reference": "https://redocly.com/docs/cli/rules/respect/no-x-security-scheme-name-without-openapi",
"ruleId": "no-x-security-scheme-name-without-openapi",
"severity": "error",
"suggest": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ describe('Arazzo requestBody-replacements-unique', () => {
},
],
"message": "Every \`replacement\` in \`requestBody\` must be unique.",
"reference": "https://redocly.com/docs/cli/rules/arazzo/requestbody-replacements-unique",
"ruleId": "requestBody-replacements-unique",
"severity": "error",
"suggest": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ describe('Arazzo respect-supported-versions', () => {
},
],
"message": "Only 1.0.1 Arazzo version is fully supported by Respect.",
"reference": "https://redocly.com/docs/cli/rules/respect/respect-supported-versions",
"ruleId": "respect-supported-versions",
"severity": "error",
"suggest": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ describe('Arazzo sourceDescription-type', () => {
},
],
"message": "The \`type\` property of the \`sourceDescription\` object must be either \`openapi\` or \`arazzo\`.",
"reference": "https://redocly.com/docs/cli/rules/arazzo/sourcedescription-type",
"ruleId": "sourceDescription-type",
"severity": "error",
"suggest": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ describe('Arazzo sourceDescription-name-unique', () => {
},
],
"message": "The \`name\` must be unique amongst all SourceDescriptions.",
"reference": "https://redocly.com/docs/cli/rules/arazzo/sourcedescription-name-unique",
"ruleId": "sourceDescription-name-unique",
"severity": "error",
"suggest": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ describe('Arazzo step-onFailure-unique', () => {
},
],
"message": "The action \`name\` must be unique amongst listed \`onFailure\` actions.",
"reference": "https://redocly.com/docs/cli/rules/arazzo/step-onfailure-unique",
"ruleId": "step-onFailure-unique",
"severity": "error",
"suggest": [],
Expand All @@ -90,6 +91,7 @@ describe('Arazzo step-onFailure-unique', () => {
},
],
"message": "The action \`reference\` must be unique amongst listed \`onFailure\` actions.",
"reference": "https://redocly.com/docs/cli/rules/arazzo/step-onfailure-unique",
"ruleId": "step-onFailure-unique",
"severity": "error",
"suggest": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ describe('Arazzo step-onSuccess-unique', () => {
},
],
"message": "The action \`name\` must be unique amongst listed \`onSuccess\` actions.",
"reference": "https://redocly.com/docs/cli/rules/arazzo/step-onsuccess-unique",
"ruleId": "step-onSuccess-unique",
"severity": "error",
"suggest": [],
Expand All @@ -90,6 +91,7 @@ describe('Arazzo step-onSuccess-unique', () => {
},
],
"message": "The action \`reference\` must be unique amongst listed \`onSuccess\` actions.",
"reference": "https://redocly.com/docs/cli/rules/arazzo/step-onsuccess-unique",
"ruleId": "step-onSuccess-unique",
"severity": "error",
"suggest": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ describe('Arazzo stepId-unique', () => {
},
],
"message": "The \`stepId\` must be unique amongst all steps described in the workflow.",
"reference": "https://redocly.com/docs/cli/rules/arazzo/stepid-unique",
"ruleId": "stepId-unique",
"severity": "error",
"suggest": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ describe('Arazzo workflow-dependsOn', () => {
},
],
"message": "Every workflow in dependsOn must be unique.",
"reference": "https://redocly.com/docs/cli/rules/arazzo/workflow-dependson",
"ruleId": "workflow-dependsOn",
"severity": "error",
"suggest": [],
Expand Down Expand Up @@ -188,6 +189,7 @@ describe('Arazzo workflow-dependsOn', () => {
},
],
"message": "Workflow events-crus must be defined in workflows.",
"reference": "https://redocly.com/docs/cli/rules/arazzo/workflow-dependson",
"ruleId": "workflow-dependsOn",
"severity": "error",
"suggest": [],
Expand All @@ -201,6 +203,7 @@ describe('Arazzo workflow-dependsOn', () => {
},
],
"message": "SourceDescription tickets-from-museum-apis must be defined in sourceDescriptions.",
"reference": "https://redocly.com/docs/cli/rules/arazzo/workflow-dependson",
"ruleId": "workflow-dependsOn",
"severity": "error",
"suggest": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ describe('Arazzo workflowId-unique', () => {
},
],
"message": "Every workflow must have a unique \`workflowId\`.",
"reference": "https://redocly.com/docs/cli/rules/arazzo/workflowid-unique",
"ruleId": "workflowId-unique",
"severity": "error",
"suggest": [],
Expand Down
Loading
Loading