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
When using the built-in function casing with the argument camel Spectral raises an error when it encounters a single, uppercase word at the end of the camel-cased string. For example:
coordinateX
scaleY
To Reproduce
Using the following OpenAPI document:
openapi: 3.0.3info:
title: Spectral evidencedescription: Noddy API to use in Spectral ticketversion: 0.0.1paths:
/:
get:
responses:
"200":
description: OKcontent:
application/json:
schema:
type: objectproperties:
coordinateX:
type: stringscaleY:
type: string
And the following ruleset:
extends: spectral:oasrules:
operation-operationId: offoas3-api-servers: offinfo-contact: offoperation-description: offoperation-tags: offcamel-case-enforcement:
message: "Property is not named in lower camel case: {{path}}, {{property}}"severity: errorgiven: $..[?(@.type === 'object' && @.properties)].properties.*~then:
function: casingfunctionOptions:
type: camel
Executing Spectral gives the following output:
➜ spectral-evidence spectral lint --ruleset ./evidence.yaml openapi.yaml
OpenAPI 3.x detected
/Users/chris/Documents/git/github/spectral-evidence/openapi.yaml
22:31 error camel-case-enforcement Property is not named in lower camel case: #/paths/~1/get/responses/200/content/application~1json/schema/properties/coordinateX, coordinateX paths./.get.responses[200].content.application/json.schema.properties.coordinateX
24:26 error camel-case-enforcement Property is not named in lower camel case: #/paths/~1/get/responses/200/content/application~1json/schema/properties/scaleY, scaleY paths./.get.responses[200].content.application/json.schema.properties.scaleY
✖ 2 problems (2 errors, 0 warnings, 0 infos, 0 hints)
➜ spectral-evidence
I think this is the root of the issue: here - the regex should allow end of line I guess i.e. ([a-z{__DIGITS__}]+|$)
Expected behavior
The ruleset should not raise the camel-case-enforcement errors as semantically the property names are correct.
Environment:
Node version: 12.20.0
Library version: 5.7.2
OS: macOs Catalina 10.15.7
The text was updated successfully, but these errors were encountered:
SensibleWood
changed the title
Camel case function does not accommodate single letter words
Camel case function does not accommodate uppercase single letter words
Feb 4, 2021
SensibleWood
changed the title
Camel case function does not accommodate uppercase single letter words
Camel case function does not accommodate uppercase single letter words at the end of a property name
Feb 4, 2021
Describe the bug
When using the built-in function
casing
with the argumentcamel
Spectral raises an error when it encounters a single, uppercase word at the end of the camel-cased string. For example:To Reproduce
Using the following OpenAPI document:
And the following ruleset:
Executing Spectral gives the following output:
I think this is the root of the issue: here - the regex should allow end of line I guess i.e.
([a-z{__DIGITS__}]+|$)
Expected behavior
The ruleset should not raise the camel-case-enforcement errors as semantically the property names are correct.
Environment:
The text was updated successfully, but these errors were encountered: