Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 26efc10

Browse files
committed
location.append -> location.child
1 parent 954850b commit 26efc10

22 files changed

Lines changed: 31 additions & 26 deletions

resources/.redocly.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@ lint:
88
rules:
99
operation-2xx-response: warning
1010
operation-description: off
11+
path-http-verbs-order: error
1112
transformers:
1213
local/duplicate-description: off

resources/local-plugin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export const rules = {
99
if (operation.operationId === 'test') {
1010
report({
1111
message: `operationId must be not "test"`,
12-
location: location.append('operationId'),
12+
location: location.child('operationId'),
1313
});
1414
}
1515
},

src/ref-utils.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export function isRef(node: any): node is OasRef {
1212
export class Location {
1313
constructor(public source: Source, public pointer: string) {}
1414

15-
append(components: (string | number)[] | string | number) {
15+
child(components: (string | number)[] | string | number) {
1616
return new Location(
1717
this.source,
1818
joinPointer(
@@ -22,6 +22,10 @@ export class Location {
2222
);
2323
}
2424

25+
key() {
26+
return { ...this, reportOnKey: true }
27+
}
28+
2529
get absolutePointer() {
2630
return this.source.absoluteRef + this.pointer;
2731
}

src/rules/oas3/api-servers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export const OperationDescription: Oas3Rule = () => {
1313
if (!Array.isArray(root.servers) || root.servers.length === 0) {
1414
report({
1515
message: 'OpenAPI servers must a non-empty array.',
16-
location: location.append(['servers']),
16+
location: location.child(['servers']),
1717
});
1818
}
1919
},

src/rules/oas3/boolean-parameter-prefixes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export const BooleanParameterPrefixes: Oas3Rule = () => {
77
if (schema.type === 'boolean' && !/^(is|has)[A-Z]/.test(parents.Parameter.name)) {
88
report({
99
message: `Boolean parameter ${parents.Parameter.name} should have a \`is\` or \`has\` prefix`,
10-
location: parentLocations.Parameter.append(['name']),
10+
location: parentLocations.Parameter.child(['name']),
1111
});
1212
}
1313
},

src/rules/oas3/oas3-examples-value-or-externalValue.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export const ExampleValueOrExternalValue: Oas3Rule = () => {
66
if (example.value && example.externalValue) {
77
report({
88
message: 'Example object can have either "value" or "externalValue" fields.',
9-
location: { ...location.append(['value']), reportOnKey: true },
9+
location: location.child(['value']).key(),
1010
});
1111
}
1212
},

src/rules/oas3/oas3-server-not-example.com.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export const ServerNotExample: Oas3Rule = () => {
66
if (['example.com', 'localhost'].indexOf(server.url) !== -1) {
77
report({
88
message: 'Server URL should not point at example.com.',
9-
location: location.append(['url']),
9+
location: location.child(['url']),
1010
});
1111
}
1212
},

src/rules/oas3/oas3-server-trailing-slash.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export const ServerNoTrailingSlash: Oas3Rule = () => {
77
if (server.url.endsWith('/')) {
88
report({
99
message: 'Server URL should not have a trailing slash.',
10-
location: location.append(['url']),
10+
location: location.child(['url']),
1111
});
1212
}
1313
},

src/rules/oas3/openapi-tags-alphabetical.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export const OpenapiTagsAlphabetical: Oas3Rule = () => {
88
if (root.tags[i].name > root.tags[i + 1].name) {
99
report({
1010
message: 'The "tags" array should be in alphabetical order',
11-
location: location.append(['tags', i]),
11+
location: location.child(['tags', i]),
1212
});
1313
}
1414
}

src/rules/oas3/operation-operationId-unique.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export const OperationIdUnique: Oas3Rule = () => {
99
if (seenOperations.has(operation.operationId)) {
1010
report({
1111
message: 'Every operation must have a unique `operationId`',
12-
location: location.append([operation.operationId]),
12+
location: location.child([operation.operationId]),
1313
});
1414
}
1515
seenOperations.add(operation.operationId);

0 commit comments

Comments
 (0)