-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: Provided a way to test a valid/invalid OpenApi Document against…
… the rules created using Spectrals CLI command.
- Loading branch information
Showing
2 changed files
with
398 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,204 @@ | ||
# This OpenAPI Document provides a way of testing all the rules for `jsonapi-errors-error-object.js` | ||
# using Spectrals CLI Command | ||
# | ||
# Usage: | ||
# spectral lint cliTest/errorsErrorObject/failing-rules.yaml --ruleset rules/jsonapi-errors-error-object.js | ||
# | ||
# This document will generate `22 errors` as expected for each rule. | ||
openapi: 3.1.0 | ||
info: | ||
title: User Information API | ||
version: 1.0.0 | ||
description: API for retrieving user information | ||
paths: | ||
/users/{userId}: | ||
get: | ||
tags: | ||
- users | ||
summary: Get User by ID | ||
description: Retrieves information for a specific user by their ID. | ||
operationId: getUserById | ||
parameters: | ||
- name: userId | ||
in: path | ||
required: true | ||
description: Unique identifier of the user | ||
schema: | ||
type: string | ||
responses: | ||
'200': | ||
description: Successful response with user information | ||
content: | ||
application/vnd.api+json: | ||
schema: | ||
type: object | ||
properties: | ||
data: | ||
type: object | ||
properties: | ||
id: | ||
type: string | ||
type: | ||
type: string | ||
enum: | ||
- user | ||
attributes: | ||
type: object | ||
properties: | ||
name: | ||
type: string | ||
email: | ||
type: string | ||
examples: | ||
user: | ||
summary: User Example | ||
value: | ||
data: | ||
id: '12345' | ||
type: user | ||
attributes: | ||
name: John Doe | ||
email: [email protected] | ||
'400': | ||
description: Bad Request | ||
content: | ||
application/vnd.api+json: | ||
schema: | ||
type: object | ||
properties: | ||
errors: | ||
type: string | ||
items: | ||
type: object | ||
properties: | ||
idd: | ||
type: string | ||
id: | ||
type: object | ||
links: | ||
type: string | ||
properties: | ||
about: | ||
type: object | ||
format: urie | ||
aboutt: | ||
type: string | ||
format: uri | ||
type: | ||
type: object | ||
format: urii | ||
status: | ||
type: object | ||
code: | ||
type: object | ||
title: | ||
type: object | ||
detail: | ||
type: object | ||
source: | ||
type: string | ||
properties: | ||
pointer: | ||
type: object | ||
parameter: | ||
type: object | ||
header: | ||
type: object | ||
headerr: | ||
type: string | ||
meta: | ||
type: string | ||
additionalProperties: true | ||
required: | ||
- detail | ||
'404': | ||
description: User Not Found | ||
content: | ||
application/vnd.api+json: | ||
schema: | ||
type: object | ||
properties: | ||
errors: | ||
type: array | ||
items: | ||
type: object | ||
properties: | ||
id: | ||
type: string | ||
links: | ||
type: object | ||
properties: | ||
about: | ||
type: string | ||
format: uri | ||
status: | ||
type: string | ||
code: | ||
type: string | ||
title: | ||
type: string | ||
detail: | ||
type: string | ||
source: | ||
type: object | ||
properties: | ||
pointer: | ||
type: string | ||
parameter: | ||
type: string | ||
header: | ||
type: string | ||
meta: | ||
type: object | ||
additionalProperties: true | ||
required: | ||
- detail | ||
'500': | ||
description: Internal Server Error | ||
content: | ||
application/vnd.api+json: | ||
schema: | ||
type: object | ||
properties: | ||
errors: | ||
type: array | ||
items: | ||
type: object | ||
properties: | ||
id: | ||
type: string | ||
links: | ||
type: object | ||
properties: | ||
about: | ||
type: string | ||
format: uri | ||
status: | ||
type: string | ||
code: | ||
type: string | ||
title: | ||
type: string | ||
detail: | ||
type: string | ||
source: | ||
type: object | ||
properties: | ||
pointer: | ||
type: string | ||
parameter: | ||
type: string | ||
header: | ||
type: string | ||
meta: | ||
type: object | ||
additionalProperties: true | ||
required: | ||
- detail | ||
components: | ||
schemas: | ||
Test: | ||
type: object | ||
properties: | ||
test: | ||
type: string |
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,194 @@ | ||
# This OpenAPI Document provides a way of testing all the rules for `jsonapi-errors-error-object.js` | ||
# using Spectrals CLI Command | ||
# | ||
# Usage: | ||
# spectral lint cliTest/errorsErrorObject/passing-rules.yaml --ruleset rules/jsonapi-errors-error-object.js | ||
# | ||
# This document will generate `0 errors` as expected for each rule. | ||
openapi: 3.1.0 | ||
info: | ||
title: User Information API | ||
version: 1.0.0 | ||
description: API for retrieving user information | ||
paths: | ||
/users/{userId}: | ||
get: | ||
tags: | ||
- users | ||
summary: Get User by ID | ||
description: Retrieves information for a specific user by their ID. | ||
operationId: getUserById | ||
parameters: | ||
- name: userId | ||
in: path | ||
required: true | ||
description: Unique identifier of the user | ||
schema: | ||
type: string | ||
responses: | ||
'200': | ||
description: Successful response with user information | ||
content: | ||
application/vnd.api+json: | ||
schema: | ||
type: object | ||
properties: | ||
data: | ||
type: object | ||
properties: | ||
id: | ||
type: string | ||
type: | ||
type: string | ||
enum: | ||
- user | ||
attributes: | ||
type: object | ||
properties: | ||
name: | ||
type: string | ||
email: | ||
type: string | ||
examples: | ||
user: | ||
summary: User Example | ||
value: | ||
data: | ||
id: '12345' | ||
type: user | ||
attributes: | ||
name: John Doe | ||
email: [email protected] | ||
'400': | ||
description: Bad Request | ||
content: | ||
application/vnd.api+json: | ||
schema: | ||
type: object | ||
properties: | ||
errors: | ||
type: array | ||
items: | ||
type: object | ||
properties: | ||
id: | ||
type: string | ||
links: | ||
type: object | ||
properties: | ||
about: | ||
type: string | ||
format: uri | ||
status: | ||
type: string | ||
code: | ||
type: string | ||
title: | ||
type: string | ||
detail: | ||
type: string | ||
source: | ||
type: object | ||
properties: | ||
pointer: | ||
type: string | ||
parameter: | ||
type: string | ||
header: | ||
type: string | ||
meta: | ||
type: object | ||
additionalProperties: true | ||
required: | ||
- detail | ||
'404': | ||
description: User Not Found | ||
content: | ||
application/vnd.api+json: | ||
schema: | ||
type: object | ||
properties: | ||
errors: | ||
type: array | ||
items: | ||
type: object | ||
properties: | ||
id: | ||
type: string | ||
links: | ||
type: object | ||
properties: | ||
about: | ||
type: string | ||
format: uri | ||
status: | ||
type: string | ||
code: | ||
type: string | ||
title: | ||
type: string | ||
detail: | ||
type: string | ||
source: | ||
type: object | ||
properties: | ||
pointer: | ||
type: string | ||
parameter: | ||
type: string | ||
header: | ||
type: string | ||
meta: | ||
type: object | ||
additionalProperties: true | ||
required: | ||
- detail | ||
'500': | ||
description: Internal Server Error | ||
content: | ||
application/vnd.api+json: | ||
schema: | ||
type: object | ||
properties: | ||
errors: | ||
type: array | ||
items: | ||
type: object | ||
properties: | ||
id: | ||
type: string | ||
links: | ||
type: object | ||
properties: | ||
about: | ||
type: string | ||
format: uri | ||
status: | ||
type: string | ||
code: | ||
type: string | ||
title: | ||
type: string | ||
detail: | ||
type: string | ||
source: | ||
type: object | ||
properties: | ||
pointer: | ||
type: string | ||
parameter: | ||
type: string | ||
header: | ||
type: string | ||
meta: | ||
type: object | ||
additionalProperties: true | ||
required: | ||
- detail | ||
components: | ||
schemas: | ||
Test: | ||
type: object | ||
properties: | ||
test: | ||
type: string |