mirror of
https://github.com/adidas/api-guidelines.git
synced 2025-10-25 15:19:19 +00:00
Update and rename .spectral.yml to adidas-spectral.yaml
-- Included spectral asyncapi rules. -- Updated rules annotations -- Updated custom rules
This commit is contained in:
@@ -1,13 +1,12 @@
|
|||||||
extends: ["spectral:oas"]
|
extends: [[spectral:oas, all], [spectral:asyncapi, all]]
|
||||||
rules:
|
rules:
|
||||||
|
operation-tags: off
|
||||||
|
operation-operationId: off
|
||||||
|
operation-success-response: error
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ----------------------------#
|
||||||
# General OAS rules
|
# Adidas OAS v2.0, v3.0 rules #
|
||||||
# ---------------------------------------------------------------------------
|
# ----------------------------#
|
||||||
|
|
||||||
operation-operationId: false
|
|
||||||
operation-tags: false
|
|
||||||
operation-2xx-response: error
|
|
||||||
|
|
||||||
adidas-paths-kebab-case:
|
adidas-paths-kebab-case:
|
||||||
description: All YAML/JSON paths MUST follow kebab-case
|
description: All YAML/JSON paths MUST follow kebab-case
|
||||||
@@ -86,9 +85,9 @@ rules:
|
|||||||
functionOptions:
|
functionOptions:
|
||||||
match: "/^([A-Z][a-z0-9]-)*([A-Z][a-z0-9])+/"
|
match: "/^([A-Z][a-z0-9]-)*([A-Z][a-z0-9])+/"
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ----------------------#
|
||||||
# Only OAS2 rules
|
# Adidas OAS v2.0 rules #
|
||||||
# ---------------------------------------------------------------------------
|
# ----------------------#
|
||||||
|
|
||||||
adidas-oas2-protocol-https-only:
|
adidas-oas2-protocol-https-only:
|
||||||
description: "ALL requests MUST go through `https` protocol only"
|
description: "ALL requests MUST go through `https` protocol only"
|
||||||
@@ -138,18 +137,8 @@ rules:
|
|||||||
given: "$..parameters..[?(@.in == 'body' && (@.example || @.schema.$ref))]"
|
given: "$..parameters..[?(@.in == 'body' && (@.example || @.schema.$ref))]"
|
||||||
then:
|
then:
|
||||||
function: truthy
|
function: truthy
|
||||||
|
|
||||||
# example-exists-in-definitions:
|
# example-exists-in-definitions covery by oas2-valid-media-example
|
||||||
# description: All models MUST have a valid example.
|
|
||||||
# severity: error
|
|
||||||
# recommended: true
|
|
||||||
# formats:
|
|
||||||
# - oas2
|
|
||||||
# message: "{{ property }} MUST have a valid example."
|
|
||||||
# given: "$..definitions..[?(!@.example || !@..$ref)]"
|
|
||||||
# then:
|
|
||||||
# function: falsy
|
|
||||||
# "$..parameters..[?(@.in == 'body')]..[?(@property !== 'properties' && @.example && ( @.type || @.format || @.$ref ))]"
|
|
||||||
|
|
||||||
adidas-oas2-response-success-hal: # schemes and/or produces
|
adidas-oas2-response-success-hal: # schemes and/or produces
|
||||||
description: "All success responses MUST be of media type `application/hal+json`"
|
description: "All success responses MUST be of media type `application/hal+json`"
|
||||||
@@ -183,9 +172,9 @@ rules:
|
|||||||
schema:
|
schema:
|
||||||
$ref: "./supermodel/adidas/api/ProblemDetail.yaml"
|
$ref: "./supermodel/adidas/api/ProblemDetail.yaml"
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ----------------------#
|
||||||
# Only OAS3 rules
|
# Adidas OAS v3.0 rules #
|
||||||
# ---------------------------------------------------------------------------
|
# ----------------------#
|
||||||
|
|
||||||
adidas-oas3-request-support-json:
|
adidas-oas3-request-support-json:
|
||||||
description: Every request MUST support `application/json` media type
|
description: Every request MUST support `application/json` media type
|
||||||
@@ -198,39 +187,9 @@ rules:
|
|||||||
then:
|
then:
|
||||||
function: falsy
|
function: falsy
|
||||||
|
|
||||||
adidas-oas3-valid-example-in-parameters:
|
# adidas-oas3-valid-example-in-parameters && adidas-oas3-valid-example-in-definitions covered by oas3-valid-media-example
|
||||||
description: Examples must be valid against their defined schema.
|
|
||||||
message: "{{error}}"
|
|
||||||
recommended: true
|
|
||||||
formats:
|
|
||||||
- oas3
|
|
||||||
severity: 0
|
|
||||||
type: validation
|
|
||||||
given: "$..parameters..[?(@.in == 'body')]..[?(@property !== 'properties' && @.example
|
|
||||||
&& ( @.type || @.format || @.$ref ))]"
|
|
||||||
then:
|
|
||||||
function: schemaPath
|
|
||||||
functionOptions:
|
|
||||||
field: example
|
|
||||||
schemaPath: "$"
|
|
||||||
|
|
||||||
adidas-oas3-valid-example-in-definitions:
|
adidas-oas3-protocol-https-only:
|
||||||
description: Examples must be valid against their defined schema.
|
|
||||||
message: "{{error}}"
|
|
||||||
recommended: true
|
|
||||||
formats:
|
|
||||||
- oas3
|
|
||||||
severity: 0
|
|
||||||
type: validation
|
|
||||||
given: "$..definitions..[?(@property !== 'properties' && @.example && (@.type ||
|
|
||||||
@.format || @.$ref))]"
|
|
||||||
then:
|
|
||||||
function: schemaPath
|
|
||||||
functionOptions:
|
|
||||||
field: example
|
|
||||||
schemaPath: "$"
|
|
||||||
|
|
||||||
adidas-oas3-protocol-https-only: # checks how does the servers array values start
|
|
||||||
description: "ALL requests MUST go through `https` protocol only"
|
description: "ALL requests MUST go through `https` protocol only"
|
||||||
formats:
|
formats:
|
||||||
- oas3
|
- oas3
|
||||||
@@ -248,7 +207,6 @@ rules:
|
|||||||
severity: error
|
severity: error
|
||||||
given: $.paths..responses[?( @property >= 201 && @property < 300 && @property != 204)].content[*]~
|
given: $.paths..responses[?( @property >= 201 && @property < 300 && @property != 204)].content[*]~
|
||||||
recommended: true
|
recommended: true
|
||||||
# type: "style"
|
|
||||||
formats:
|
formats:
|
||||||
- oas3
|
- oas3
|
||||||
message: "Response documents MUST be of application/hal+json media types: {{error}}"
|
message: "Response documents MUST be of application/hal+json media types: {{error}}"
|
||||||
Reference in New Issue
Block a user