mirror of
https://github.com/adidas/api-guidelines.git
synced 2025-10-25 15:19:19 +00:00
Split ruleset into general, oas2 and oas3 specific
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
extends: [spectral:oas2]
|
extends: [spectral:oas2, spectral:oas3]
|
||||||
rules:
|
rules:
|
||||||
|
# General OAS rules
|
||||||
operation-operationId: false
|
operation-operationId: false
|
||||||
operation-tags: info
|
operation-tags: info
|
||||||
operation-2xx-response: error
|
operation-2xx-response: error
|
||||||
@@ -34,23 +35,6 @@ rules:
|
|||||||
function: pattern
|
function: pattern
|
||||||
functionOptions:
|
functionOptions:
|
||||||
match: "/^[a-z$_]{1}[A-Z09$_]*/"
|
match: "/^[a-z$_]{1}[A-Z09$_]*/"
|
||||||
protocol-https-only:
|
|
||||||
description: "ALL requests MUST go through `https` protocol only"
|
|
||||||
recommended: true
|
|
||||||
severity: error
|
|
||||||
type: "style"
|
|
||||||
message: "Schemes MUST be https and no other value is allowed."
|
|
||||||
given: $
|
|
||||||
then:
|
|
||||||
field: schemes
|
|
||||||
function: schema
|
|
||||||
functionOptions:
|
|
||||||
schema:
|
|
||||||
type: array
|
|
||||||
items:
|
|
||||||
type: string
|
|
||||||
enum: ["https"]
|
|
||||||
maxItems: 1
|
|
||||||
request-GET-no-body:
|
request-GET-no-body:
|
||||||
description: A `GET` request MUST NOT accept a `body` parameter
|
description: A `GET` request MUST NOT accept a `body` parameter
|
||||||
severity: error
|
severity: error
|
||||||
@@ -85,6 +69,37 @@ rules:
|
|||||||
functionOptions:
|
functionOptions:
|
||||||
schema:
|
schema:
|
||||||
$ref: ./supermodel/adidas/api/ProblemDetail.yaml
|
$ref: ./supermodel/adidas/api/ProblemDetail.yaml
|
||||||
|
uri-template-cannot-dash:
|
||||||
|
description: The `URI` template ([RFC 6570](https://tools.ietf.org/html/rfc6570)) cannot contain a `-` character
|
||||||
|
severity: error
|
||||||
|
recommended: true
|
||||||
|
message: "{{property}}: {{description}}"
|
||||||
|
given: $.paths[*]~
|
||||||
|
then:
|
||||||
|
function: pattern
|
||||||
|
functionOptions:
|
||||||
|
notMatch: "/-/"
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
# Only OAS2 rules
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
protocol-https-only:
|
||||||
|
description: "ALL requests MUST go through `https` protocol only"
|
||||||
|
recommended: true
|
||||||
|
severity: error
|
||||||
|
type: "style"
|
||||||
|
message: "Schemes MUST be https and no other value is allowed."
|
||||||
|
given: $
|
||||||
|
then:
|
||||||
|
field: schemes
|
||||||
|
function: schema
|
||||||
|
functionOptions:
|
||||||
|
schema:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
enum: ["https"]
|
||||||
|
maxItems: 1
|
||||||
request-support-json: # This will have to take into account the schemes as well as consumes parameter
|
request-support-json: # This will have to take into account the schemes as well as consumes parameter
|
||||||
description: Every request SHOULD support `application/json` media type
|
description: Every request SHOULD support `application/json` media type
|
||||||
severity: warn
|
severity: warn
|
||||||
@@ -100,16 +115,12 @@ rules:
|
|||||||
type: string
|
type: string
|
||||||
enum:
|
enum:
|
||||||
- application/json
|
- application/json
|
||||||
uri-template-cannot-dash:
|
|
||||||
description: The `URI` template ([RFC 6570](https://tools.ietf.org/html/rfc6570)) cannot contain a `-` character
|
# ---------------------------------------------------------------------------
|
||||||
severity: error
|
# Only OAS3 rules
|
||||||
recommended: true
|
# ---------------------------------------------------------------------------
|
||||||
message: "{{property}}: {{description}}"
|
|
||||||
given: $.paths[*]~
|
|
||||||
then:
|
|
||||||
function: pattern
|
|
||||||
functionOptions:
|
|
||||||
notMatch: "/-/"
|
|
||||||
# Needs update of JSON Schema in spectral to draft-07 or newer to implement if-then statements
|
# Needs update of JSON Schema in spectral to draft-07 or newer to implement if-then statements
|
||||||
# headers-hyphenated-pascal-case:
|
# headers-hyphenated-pascal-case:
|
||||||
# description: All `HTTP` headers MUST use `Hyphenated-Pascal-Case` notation
|
# description: All `HTTP` headers MUST use `Hyphenated-Pascal-Case` notation
|
||||||
|
|||||||
Reference in New Issue
Block a user