-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
+ updated the camel case rule to use the built in casing function instead of regex to get performance + Addressed all the comments on the confluence page + Updated documentation with links --------- Signed-off-by: Ethan Honzik <105084033+EthanHonzikSPS@users.noreply.github.com> Co-authored-by: Brandon Sahadeo <50463922+brandonsahadeo@users.noreply.github.com>
- Loading branch information
1 parent
0995d49
commit cd1301c
Showing
25 changed files
with
3,826 additions
and
1,730 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -94,4 +94,4 @@ class SpectralTestHarness { | |
|
||
module.exports = { | ||
SpectralTestHarness | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
const { SpectralTestHarness } = require("../harness/spectral-test-harness.js"); | ||
|
||
describe("sps-camel-case-properties", () => { | ||
let spectral = null; | ||
const ruleName = "sps-camel-case-properties"; | ||
const ruleset = "src/naming.ruleset.yml"; | ||
|
||
beforeEach(async () => { | ||
spectral = new SpectralTestHarness(ruleset); | ||
}); | ||
|
||
test("valid property names", async () => { | ||
const spec = ` | ||
openapi: 3.0.1 | ||
paths: | ||
/users: | ||
post: | ||
requestBody: | ||
content: | ||
application/json: | ||
schema: | ||
type: object | ||
properties: | ||
orderNumber: | ||
type: string | ||
lineItemNumber: | ||
type: integer | ||
responses: | ||
'200': | ||
description: Successful operation | ||
content: | ||
application/json: | ||
schema: | ||
type: object | ||
properties: | ||
userId: | ||
type: string | ||
userName: | ||
type: string | ||
test1: | ||
type: string | ||
`; | ||
|
||
await spectral.validateSuccess(spec, ruleName); | ||
}); | ||
|
||
test("invalid usage of camel casing in property names", async () => { | ||
const spec = ` | ||
openapi: 3.0.1 | ||
paths: | ||
/users: | ||
post: | ||
requestBody: | ||
content: | ||
application/json: | ||
schema: | ||
type: object | ||
properties: | ||
OrderNumber: | ||
type: string | ||
line_item_number: | ||
type: integer | ||
responses: | ||
'200': | ||
description: Successful operation | ||
content: | ||
application/json: | ||
schema: | ||
type: object | ||
properties: | ||
User_Id: | ||
type: string | ||
user_Name: | ||
type: string | ||
`; | ||
|
||
await spectral.validateFailure(spec, ruleName, "Error", 4); | ||
}); | ||
|
||
test("invalid usage of camel casing for acronyms", async () => { | ||
const spec = ` | ||
openapi: 3.0.1 | ||
paths: | ||
/users: | ||
post: | ||
requestBody: | ||
content: | ||
application/json: | ||
schema: | ||
type: object | ||
properties: | ||
orderID: | ||
type: string | ||
responses: | ||
'200': | ||
description: Successful operation | ||
content: | ||
application/json: | ||
schema: | ||
type: object | ||
properties: | ||
userID: | ||
type: string | ||
userName: | ||
type: string | ||
`; | ||
|
||
await spectral.validateFailure(spec, ruleName, "Error", 2); | ||
}); | ||
}); |
Oops, something went wrong.