Skip to content

Commit adefcef

Browse files
fix: address metric level
1 parent f937b23 commit adefcef

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

tools/spectral/ipa/__tests__/IPA125OneOfSchemaPropertySameType.test.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ testRule('xgen-IPA-125-oneOf-schema-property-same-type', [
5959
errors: [
6060
{
6161
code: 'xgen-IPA-125-oneOf-schema-property-same-type',
62-
path: ['components', 'schemas', 'ExampleSchemaInvalid', 'oneOf'],
62+
path: ['components', 'schemas', 'ExampleSchemaInvalid'],
6363
message: "Property 'id' has different types or schemas in oneOf items.",
6464
severity: DiagnosticSeverity.Warning,
6565
},
@@ -94,13 +94,13 @@ testRule('xgen-IPA-125-oneOf-schema-property-same-type', [
9494
errors: [
9595
{
9696
code: 'xgen-IPA-125-oneOf-schema-property-same-type',
97-
path: ['components', 'schemas', 'ExampleSchemaInvalid', 'oneOf'],
97+
path: ['components', 'schemas', 'ExampleSchemaInvalid'],
9898
message: "Property 'id' has different types or schemas in oneOf items.",
9999
severity: DiagnosticSeverity.Warning,
100100
},
101101
{
102102
code: 'xgen-IPA-125-oneOf-schema-property-same-type',
103-
path: ['components', 'schemas', 'ExampleSchemaInvalid', 'oneOf'],
103+
path: ['components', 'schemas', 'ExampleSchemaInvalid'],
104104
message: "Property 'age' has different types or schemas in oneOf items.",
105105
severity: DiagnosticSeverity.Warning,
106106
},
@@ -237,13 +237,13 @@ testRule('xgen-IPA-125-oneOf-schema-property-same-type', [
237237
errors: [
238238
{
239239
code: 'xgen-IPA-125-oneOf-schema-property-same-type',
240-
path: ['components', 'schemas', 'ExampleSchemaInvalid', 'oneOf'],
240+
path: ['components', 'schemas', 'ExampleSchemaInvalid'],
241241
message: "Property 'name' has different types or schemas in oneOf items.",
242242
severity: DiagnosticSeverity.Warning,
243243
},
244244
{
245245
code: 'xgen-IPA-125-oneOf-schema-property-same-type',
246-
path: ['components', 'schemas', 'ExampleSchemaInvalid', 'oneOf'],
246+
path: ['components', 'schemas', 'ExampleSchemaInvalid'],
247247
message: "Property 'address' has different types or schemas in oneOf items.",
248248
severity: DiagnosticSeverity.Warning,
249249
},
@@ -386,7 +386,7 @@ testRule('xgen-IPA-125-oneOf-schema-property-same-type', [
386386
errors: [
387387
{
388388
code: 'xgen-IPA-125-oneOf-schema-property-same-type',
389-
path: ['components', 'schemas', 'ExampleSchema', 'properties', 'name', 'oneOf'],
389+
path: ['components', 'schemas', 'ExampleSchema', 'properties', 'name'],
390390
message: "Property 'first' has different types or schemas in oneOf items.",
391391
severity: DiagnosticSeverity.Warning,
392392
},
@@ -537,7 +537,7 @@ testRule('xgen-IPA-125-oneOf-schema-property-same-type', [
537537
errors: [
538538
{
539539
code: 'xgen-IPA-125-oneOf-schema-property-same-type',
540-
path: ['components', 'schemas', 'ExampleSchema', 'oneOf'],
540+
path: ['components', 'schemas', 'ExampleSchema'],
541541
message: "Property 'counter' has different types or schemas in oneOf items.",
542542
severity: DiagnosticSeverity.Warning,
543543
},
@@ -680,7 +680,7 @@ testRule('xgen-IPA-125-oneOf-schema-property-same-type', [
680680
errors: [
681681
{
682682
code: 'xgen-IPA-125-oneOf-schema-property-same-type',
683-
path: ['components', 'schemas', 'ExampleSchema', 'oneOf'],
683+
path: ['components', 'schemas', 'ExampleSchema'],
684684
message: "Property 'threshold' has different types or schemas in oneOf items.",
685685
severity: DiagnosticSeverity.Warning,
686686
},

tools/spectral/ipa/rulesets/functions/IPA125OneOfSchemaPropertySameType.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,16 @@ const RULE_NAME = 'xgen-IPA-125-oneOf-schema-property-same-type';
66

77
export default (input, _, { path, documentInventory }) => {
88
const oas = documentInventory.resolved;
9-
const parentSchema = resolveObject(oas, path.slice(0, path.length - 1));
9+
const schemaPath = path.slice(0, path.length - 1);
10+
const parentSchema = resolveObject(oas, schemaPath);
1011

1112
// Ignore base types, see IPA125OneOfNoBaseTypes.js
1213
if (input.some((oneOfOption) => oneOfOption.type !== 'object')) {
1314
return;
1415
}
1516

16-
const errors = checkViolationsAndReturnErrors(input, path);
17-
return evaluateAndCollectAdoptionStatus(errors, RULE_NAME, parentSchema, path);
17+
const errors = checkViolationsAndReturnErrors(input, schemaPath);
18+
return evaluateAndCollectAdoptionStatus(errors, RULE_NAME, parentSchema, schemaPath);
1819
};
1920

2021
function checkViolationsAndReturnErrors(schemas, path) {

0 commit comments

Comments
 (0)