You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Bug Description
If an API is being linted that has several $ref's in it, then our linter can sometimes fail to print the correct path in the final error message. It still has an internal path to the true error that it can use for all other intents and purposes (like for use inside the rule functions), but in the message that prints to the console, the location is presented on an incomplete path. This is sometimes eliminating errors when there are multiple problems on similar deep paths.
To Reproduce
Given this ruleset:
{
"rules": {
"oas3-field-names-camel-case": {
"description": "Representation field names should use lowerCamelCase.",
"message": "{{property}} field is not lowerCamelCase",
"formats": ["oas3"],
"severity": "error",
"given": [
"$.paths.*.*.responses.*.content.*.*..[*]~",
"$.paths.*.*.requestBody.content.*.*..[*]~",
"$.paths.*.*.parameters.*"
],
"then": {
"function": "casing",
"functionOptions": {
"type": "camel"
}
}
}
}
}
...and this API:
openapi: '3.0.3'info:
title: Sample APIdescription: This is a sample API.version: '1.0'contact:
name: John Smithservers:
- url: http://api.example.comtags:
- name: Sampledescription: This is a sample tag.paths:
/test:
post:
description: Get some test data.operationId: getTestDataparameters:
- in: queryname: userIdschema:
type: integerrequired: truedescription: Numeric ID of the user to get.tags:
- SamplerequestBody:
required: truecontent:
application/json:
schema:
type: stringresponses:
'200':
description: OKcontent:
application/json:
schema:
$ref: '#/Location1'Location1:
anObjectName:
$ref: '#/Location2'Location2:
BadCamelCase:
type: stringReallyBadCamelCase:
type: string
Run this CLI command: spectral lint --ruleset <JSON ruleset file> <API file>
See printed error message:
42:16 error oas3-field-names-camel-case anObjectName field is not lowerCamelCase Location1.anObjectName
✖ 1 problem (1 error, 0 warnings, 0 infos, 0 hints)
Expected behavior
Two error messages should be printed, pointing to the locations of BadCamelCase (Line 46, Location2.BadCamelCase) and ReallyBadCamelCase (Line 48, Location2.ReallyBadCamelCase). However, given this specific case of nested $refs with object names along the path, the path that Spectral reads can only reach Location1.anObjectName, and does not reference the full path to either of the two words that break the camel case rule. A detailed list of examples of $ref situations that do and don't work can be found in this discussion post: #1909
Environment:
Library version: 5.9.1
OS: macOS Big Sur 11.6.2
The text was updated successfully, but these errors were encountered:
Bug Description
If an API is being linted that has several $ref's in it, then our linter can sometimes fail to print the correct path in the final error message. It still has an internal path to the true error that it can use for all other intents and purposes (like for use inside the rule functions), but in the message that prints to the console, the location is presented on an incomplete path. This is sometimes eliminating errors when there are multiple problems on similar deep paths.
To Reproduce
...and this API:
Run this CLI command:
spectral lint --ruleset <JSON ruleset file> <API file>
See printed error message:
Expected behavior
Two error messages should be printed, pointing to the locations of BadCamelCase (Line 46, Location2.BadCamelCase) and ReallyBadCamelCase (Line 48, Location2.ReallyBadCamelCase). However, given this specific case of nested $refs with object names along the path, the path that Spectral reads can only reach Location1.anObjectName, and does not reference the full path to either of the two words that break the camel case rule. A detailed list of examples of $ref situations that do and don't work can be found in this discussion post: #1909
Environment:
The text was updated successfully, but these errors were encountered: