forked from italia/api-oas-checker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproblem.yml
50 lines (50 loc) · 1.75 KB
/
problem.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
rules:
use-problem-json-for-default:
description: >-
APIs should use Problem json for errors.
See https://docs.italia.it/italia/piano-triennale-ict/lg-modellointeroperabilita-docs/it/bozza/doc/profili-di-interazione/regole-comuni-rest-soap.html#usare-lo-schema-problem-json-per-le-risposte-di-errore
message: >-
Use media-type application/problem+json for default responses (errors)
and the associate schema. {{path}}
formats:
- oas3
severity: error
recommended: true
given: >-
$.[responses][default][content]
then:
field: 'application/problem+json'
function: truthy
use-problem-json-schema:
description: >-
APIs should use Problem json for errors.
See https://docs.italia.it/italia/piano-triennale-ict/lg-modellointeroperabilita-docs/it/bozza/doc/profili-di-interazione/regole-comuni-rest-soap.html#usare-lo-schema-problem-json-per-le-risposte-di-errore
message: >-
Use RFC7807 schema to model errors. {{path}}
formats:
- oas3
severity: error
recommended: true
# Search for 4xx, 5xx and default responses schema.
given: >-
$.[responses]
[?(@property[0] != "1" && @property[0] != "2" && @property[0] != "3" )]
[[schema]]
then:
function: schema
functionOptions:
schema:
$ref: https://teamdigitale.github.io/openapi/0.0.6/definitions.yaml#/schemas/Problem
# https://opensource.zalando.com/problem/schema.yaml#/Problem
response-with-json-object:
message: |-
Responses must use json objects {{path}}
severity: warn
recommended: true
given: >-
$.[responses][*][content][*][schema]
then:
field: type
function: pattern
functionOptions:
match: object