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 packages/rulesets/src/arazzo/schemas/validators.ts

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ testRule('duplicated-entry-in-enum', [
},

{
name: 'osa3: enum with duplicated entries',
name: 'oas3: enum with duplicated entries',
document: {
openapi: '3.0.0',
components: {
Expand Down Expand Up @@ -158,4 +158,62 @@ testRule('duplicated-entry-in-enum', [
},
errors: [],
},
{
name: 'oas3.1: valid model',
document: {
openapi: '3.1.0',
components: {
schemas: {
Test: {
type: 'integer',
enum: [1, 2, 3, null],
},
},
},
},
errors: [],
},

{
name: 'oas3.1: enum with duplicated entries',
document: {
openapi: '3.1.0',
components: {
schemas: {
Test: {
type: 'integer',
enum: [1, 2, 3, 4, 5, 2],
},
},
},
},
errors: [
{
message: `"enum" property must not have duplicate items (items ## 1 and 5 are identical)`,
path: ['components', 'schemas', 'Test', 'enum'],
severity: DiagnosticSeverity.Warning,
},
],
},
{
name: 'oas3.1: enum with duplicated null entries',
document: {
openapi: '3.1.0',
components: {
schemas: {
Test: {
type: 'integer',
enum: [null, 1, 3, 4, 5, 2, null],
},
},
},
},
errors: [
{
message: `"enum" property must not have duplicate items (items ## 0 and 6 are identical)`,
path: ['components', 'schemas', 'Test', 'enum'],
severity: DiagnosticSeverity.Warning,
},
],
},
]);
2 changes: 1 addition & 1 deletion packages/rulesets/src/oas/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ const ruleset = {
severity: 'warn',
recommended: true,
message: '{{error}}',
given: ["$..[?(@property !== 'properties' && @.enum && @.enum.constructor.name === 'Array')]"],
given: ["$..[?(@property !== 'properties' && @ != null && @.enum && @.enum.constructor.name === 'Array')]"],
then: {
field: 'enum',
function: oasSchema,
Expand Down
Loading