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:
|
||||
# General OAS rules
|
||||
operation-operationId: false
|
||||
operation-tags: info
|
||||
operation-2xx-response: error
|
||||
@@ -34,23 +35,6 @@ rules:
|
||||
function: pattern
|
||||
functionOptions:
|
||||
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:
|
||||
description: A `GET` request MUST NOT accept a `body` parameter
|
||||
severity: error
|
||||
@@ -85,6 +69,37 @@ rules:
|
||||
functionOptions:
|
||||
schema:
|
||||
$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
|
||||
description: Every request SHOULD support `application/json` media type
|
||||
severity: warn
|
||||
@@ -100,16 +115,12 @@ rules:
|
||||
type: string
|
||||
enum:
|
||||
- application/json
|
||||
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 OAS3 rules
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
# Needs update of JSON Schema in spectral to draft-07 or newer to implement if-then statements
|
||||
# headers-hyphenated-pascal-case:
|
||||
# description: All `HTTP` headers MUST use `Hyphenated-Pascal-Case` notation
|
||||
|
||||
Reference in New Issue
Block a user