-
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.
feat: URN-like Domain Reference Standards (#46)
Introduction of URN-Like references using the "ref" keyword for inner domain references: "sps:book:et89e-di087-lkjer2", along with linting rules.
- Loading branch information
1 parent
3edbce9
commit f3e2953
Showing
8 changed files
with
507 additions
and
29 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,60 @@ | ||
const { SpectralTestHarness } = require("../harness/spectral-test-harness.js"); | ||
|
||
describe("sps-ref-in-url", () => { | ||
let spectral = null; | ||
const ruleName = "sps-ref-in-url"; | ||
const ruleset = "src/naming.ruleset.yml"; | ||
|
||
beforeEach(async () => { | ||
spectral = new SpectralTestHarness(ruleset); | ||
}); | ||
|
||
test("no errors for regular query parameters", async () => { | ||
const spec = ` | ||
openapi: 3.1.0 | ||
paths: | ||
/v1/users/{id}: | ||
get: | ||
summary: hello | ||
parameters: | ||
- name: filterThing | ||
in: query | ||
- name: id | ||
in: path | ||
`; | ||
|
||
await spectral.validateSuccess(spec, ruleName); | ||
}); | ||
|
||
test("warnings for ref in query parameter", async () => { | ||
const spec = ` | ||
openapi: 3.1.0 | ||
paths: | ||
/v1/users/{id}: | ||
get: | ||
summary: hello | ||
parameters: | ||
- name: ref | ||
in: query | ||
- name: id | ||
in: path | ||
`; | ||
await spectral.validateFailure(spec, ruleName, "Warning"); | ||
}); | ||
|
||
test("warnings for ref in path parameter", async () => { | ||
const spec = ` | ||
openapi: 3.1.0 | ||
paths: | ||
/v1/users/{ref}: | ||
get: | ||
summary: hello | ||
parameters: | ||
- name: other | ||
in: query | ||
- name: ref | ||
in: path | ||
`; | ||
await spectral.validateFailure(spec, ruleName, "Warning"); | ||
}); | ||
}); |
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,65 @@ | ||
const { SpectralTestHarness } = require("../harness/spectral-test-harness.js"); | ||
|
||
describe("sps-ref-property-name", () => { | ||
let spectral = null; | ||
const ruleName = "sps-ref-property-name"; | ||
const ruleset = "src/naming.ruleset.yml"; | ||
|
||
beforeEach(async () => { | ||
spectral = new SpectralTestHarness(ruleset); | ||
}); | ||
|
||
test("Ref property successful with proper format", async () => { | ||
const spec = ` | ||
openapi: 3.0.1 | ||
paths: {} | ||
components: | ||
schemas: | ||
MySchema: | ||
type: object | ||
properties: | ||
ref: | ||
type: string | ||
format: sps-ref | ||
value: | ||
type: string | ||
`; | ||
|
||
await spectral.validateSuccess(spec, ruleName); | ||
}); | ||
|
||
test("Ref property fails without proper format", async () => { | ||
const spec = ` | ||
openapi: 3.0.1 | ||
paths: {} | ||
components: | ||
schemas: | ||
MySchema: | ||
type: object | ||
properties: | ||
ref: | ||
type: string | ||
value: | ||
type: string | ||
`; | ||
await spectral.validateFailure(spec, ruleName, "Error"); | ||
}); | ||
|
||
test("Ref property fails with wrong format", async () => { | ||
const spec = ` | ||
openapi: 3.0.1 | ||
paths: {} | ||
components: | ||
schemas: | ||
MySchema: | ||
type: object | ||
properties: | ||
ref: | ||
type: string | ||
format: uuid | ||
value: | ||
type: string | ||
`; | ||
await spectral.validateFailure(spec, ruleName, "Error"); | ||
}); | ||
}); |
Oops, something went wrong.