@aep_dev/aep-openapi-linter 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +64 -0
- package/aep/0004.yaml +38 -0
- package/aep/0122.yaml +110 -0
- package/aep/0131.yaml +78 -0
- package/aep/0132.yaml +115 -0
- package/aep/0133.yaml +165 -0
- package/aep/0134.yaml +124 -0
- package/aep/0135.yaml +49 -0
- package/aep/0136.yaml +53 -0
- package/aep/0137.yaml +115 -0
- package/aep/0140.yaml +17 -0
- package/aep/0142.yaml +37 -0
- package/aep/0143.yaml +31 -0
- package/aep/0144.yaml +39 -0
- package/aep/0151.yaml +94 -0
- package/aep/0158.yaml +175 -0
- package/aep/0193.yaml +54 -0
- package/functions/aep-142-time-field-type.js +107 -0
- package/functions/operations-endpoint.js +40 -0
- package/functions/parameter-names-unique.js +78 -0
- package/functions/singleton-utils.js +87 -0
- package/functions/skipSingletonsSchema.js +35 -0
- package/functions/standardized-codes.js +50 -0
- package/package.json +60 -0
- package/spectral.yaml +50 -0
package/aep/0134.yaml
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
aliases:
|
|
2
|
+
UpdateOperation:
|
|
3
|
+
description: An Update method is a patch on path that ends in a path parameter
|
|
4
|
+
targets:
|
|
5
|
+
- formats: ['oas2', 'oas3']
|
|
6
|
+
given:
|
|
7
|
+
- $.paths[?(@property.match(/\}$/))].patch
|
|
8
|
+
|
|
9
|
+
rules:
|
|
10
|
+
aep-134-content-type:
|
|
11
|
+
description: The request body content type should be "application/merge-patch+json"
|
|
12
|
+
severity: warn
|
|
13
|
+
formats: ['oas3']
|
|
14
|
+
given: '#UpdateOperation'
|
|
15
|
+
then:
|
|
16
|
+
field: requestBody.content.application/merge-patch+json
|
|
17
|
+
function: truthy
|
|
18
|
+
|
|
19
|
+
aep-134-operation-id:
|
|
20
|
+
description: The operation ID should be Update{resource-singular}.
|
|
21
|
+
message: The operation ID does not conform to AEP-134
|
|
22
|
+
severity: error
|
|
23
|
+
formats: ['oas2', 'oas3']
|
|
24
|
+
given: '#UpdateOperation'
|
|
25
|
+
then:
|
|
26
|
+
function: schema
|
|
27
|
+
functionOptions:
|
|
28
|
+
schema:
|
|
29
|
+
type: object
|
|
30
|
+
properties:
|
|
31
|
+
operationId:
|
|
32
|
+
type: string
|
|
33
|
+
pattern: '^[Uu][Pp][Dd][Aa][Tt][Ee][A-Z].*$'
|
|
34
|
+
required: ['operationId']
|
|
35
|
+
|
|
36
|
+
aep-134-request-body:
|
|
37
|
+
description: A standard update method must accept the resource in the request body.
|
|
38
|
+
message: The request body is not an AEP resource.
|
|
39
|
+
severity: error
|
|
40
|
+
formats: ['oas3']
|
|
41
|
+
given: '#UpdateOperation'
|
|
42
|
+
then:
|
|
43
|
+
function: schema
|
|
44
|
+
functionOptions:
|
|
45
|
+
schema:
|
|
46
|
+
type: object
|
|
47
|
+
required: ['requestBody']
|
|
48
|
+
properties:
|
|
49
|
+
requestBody:
|
|
50
|
+
# I tried putting this schema is a separate file and $ref'ing it, but it didn't work
|
|
51
|
+
description: A content object with an AEP resource schema.
|
|
52
|
+
type: object
|
|
53
|
+
required: ['content']
|
|
54
|
+
properties:
|
|
55
|
+
content:
|
|
56
|
+
type: object
|
|
57
|
+
additionalProperties:
|
|
58
|
+
type: object
|
|
59
|
+
required: ['schema']
|
|
60
|
+
properties:
|
|
61
|
+
schema:
|
|
62
|
+
type: object
|
|
63
|
+
required: ['x-aep-resource']
|
|
64
|
+
|
|
65
|
+
aep-134-required-params:
|
|
66
|
+
description: A standard update method must not have any required parameters other than path parameters.
|
|
67
|
+
severity: error
|
|
68
|
+
formats: ['oas2', 'oas3']
|
|
69
|
+
given:
|
|
70
|
+
- '#UpdateOperation.parameters[?(@.in != "path")]'
|
|
71
|
+
- '#UpdateOperation^.parameters[?(@.in != "path")]' # parameters at path item level
|
|
72
|
+
then:
|
|
73
|
+
field: required
|
|
74
|
+
function: falsy
|
|
75
|
+
|
|
76
|
+
aep-134-response-body:
|
|
77
|
+
description: The success response for a standard Update method must be the updated AEP resource.
|
|
78
|
+
message: The response body is not an AEP resource.
|
|
79
|
+
severity: error
|
|
80
|
+
formats: ['oas3']
|
|
81
|
+
given: '#UpdateOperation'
|
|
82
|
+
then:
|
|
83
|
+
function: schema
|
|
84
|
+
functionOptions:
|
|
85
|
+
schema:
|
|
86
|
+
type: object
|
|
87
|
+
required: ['responses']
|
|
88
|
+
properties:
|
|
89
|
+
responses:
|
|
90
|
+
type: object
|
|
91
|
+
# don't require a 200 response, since it's possible to have a 202
|
|
92
|
+
properties:
|
|
93
|
+
'200':
|
|
94
|
+
description: A content object with an AEP resource schema.
|
|
95
|
+
type: object
|
|
96
|
+
required: ['content']
|
|
97
|
+
properties:
|
|
98
|
+
content:
|
|
99
|
+
type: object
|
|
100
|
+
additionalProperties:
|
|
101
|
+
type: object
|
|
102
|
+
required: ['schema']
|
|
103
|
+
properties:
|
|
104
|
+
schema:
|
|
105
|
+
type: object
|
|
106
|
+
required: ['x-aep-resource']
|
|
107
|
+
|
|
108
|
+
aep-134-unknown-optional-params:
|
|
109
|
+
description: A standard Update method should not have unknown optional parameters.
|
|
110
|
+
severity: warn
|
|
111
|
+
formats: ['oas2', 'oas3']
|
|
112
|
+
given:
|
|
113
|
+
- '#UpdateOperation.parameters[?(@.in == "query")]' # only check query parameters
|
|
114
|
+
- '#UpdateOperation^.parameters[?(@.in == "query")]' # parameters at path item level
|
|
115
|
+
then:
|
|
116
|
+
# Use schema function on name so that the error points to the name field
|
|
117
|
+
function: schema
|
|
118
|
+
functionOptions:
|
|
119
|
+
schema:
|
|
120
|
+
type: object
|
|
121
|
+
properties:
|
|
122
|
+
name:
|
|
123
|
+
# Update has no defined optional parameters
|
|
124
|
+
enum: [null]
|
package/aep/0135.yaml
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
aliases:
|
|
2
|
+
DeleteOperation:
|
|
3
|
+
description: A Delete operation is a delete on path that ends in a path parameter
|
|
4
|
+
targets:
|
|
5
|
+
- formats: ['oas2', 'oas3']
|
|
6
|
+
given:
|
|
7
|
+
# first condition excludes custom methods and second condition matches paths ending in a path parameter
|
|
8
|
+
- $.paths[?(!@property.match(/:[^/]*$/) && @property.match(/\}$/))].delete
|
|
9
|
+
|
|
10
|
+
rules:
|
|
11
|
+
aep-135-http-body:
|
|
12
|
+
description: A delete operation must not accept a request body.
|
|
13
|
+
severity: error
|
|
14
|
+
formats: ['oas3']
|
|
15
|
+
given:
|
|
16
|
+
- '#DeleteOperation.requestBody'
|
|
17
|
+
then:
|
|
18
|
+
function: falsy
|
|
19
|
+
|
|
20
|
+
aep-135-operation-id:
|
|
21
|
+
description: The operation ID should be Delete{resource-singular}.
|
|
22
|
+
message: The operation ID does not conform to AEP-135
|
|
23
|
+
severity: error
|
|
24
|
+
formats: ['oas2', 'oas3']
|
|
25
|
+
given: '#DeleteOperation'
|
|
26
|
+
then:
|
|
27
|
+
function: schema
|
|
28
|
+
functionOptions:
|
|
29
|
+
schema:
|
|
30
|
+
type: object
|
|
31
|
+
properties:
|
|
32
|
+
operationId:
|
|
33
|
+
type: string
|
|
34
|
+
pattern: '^[Dd][Ee][Ll][Ee][Tt][Ee][A-Z].*$'
|
|
35
|
+
required: ['operationId']
|
|
36
|
+
|
|
37
|
+
aep-135-response-204:
|
|
38
|
+
description: A delete operation should have a 204 response.
|
|
39
|
+
message: A delete operation should have a `204` response.
|
|
40
|
+
severity: warn
|
|
41
|
+
formats: ['oas2', 'oas3']
|
|
42
|
+
given: '#DeleteOperation.responses'
|
|
43
|
+
then:
|
|
44
|
+
function: schema
|
|
45
|
+
functionOptions:
|
|
46
|
+
schema:
|
|
47
|
+
oneOf:
|
|
48
|
+
- required: ['204']
|
|
49
|
+
- required: ['202']
|
package/aep/0136.yaml
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
aliases:
|
|
2
|
+
CustomOperation:
|
|
3
|
+
description: A custom method is identified by a path containing a colon (:) before the verb
|
|
4
|
+
targets:
|
|
5
|
+
- formats: ['oas2', 'oas3']
|
|
6
|
+
given:
|
|
7
|
+
# condition excludes custom methods Update Array custom operations defined in AEP-144, as different list of rules applies to them
|
|
8
|
+
- $.paths[?(@property.match(/:(?!add|remove)([^/]*)$/))]
|
|
9
|
+
|
|
10
|
+
rules:
|
|
11
|
+
aep-136-http-body:
|
|
12
|
+
description: GET-based custom methods must have no request body.
|
|
13
|
+
severity: error
|
|
14
|
+
formats: ['oas3']
|
|
15
|
+
given: '#CustomOperation.get.requestBody'
|
|
16
|
+
then:
|
|
17
|
+
function: falsy
|
|
18
|
+
|
|
19
|
+
aep-136-http-method:
|
|
20
|
+
description: Custom methods should use POST or GET.
|
|
21
|
+
severity: warn
|
|
22
|
+
formats: ['oas2', 'oas3']
|
|
23
|
+
given: '#CustomOperation'
|
|
24
|
+
then:
|
|
25
|
+
function: schema
|
|
26
|
+
functionOptions:
|
|
27
|
+
schema:
|
|
28
|
+
# trigger if any method is not POST or GET
|
|
29
|
+
not:
|
|
30
|
+
anyOf:
|
|
31
|
+
- required: ['delete']
|
|
32
|
+
- required: ['head']
|
|
33
|
+
- required: ['options']
|
|
34
|
+
- required: ['patch']
|
|
35
|
+
- required: ['put']
|
|
36
|
+
- required: ['trace']
|
|
37
|
+
|
|
38
|
+
aep-136-operation-id:
|
|
39
|
+
description: The operation ID should start with a colon and a capital letter.
|
|
40
|
+
message: The operation ID does not conform to AEP-136
|
|
41
|
+
severity: warn
|
|
42
|
+
formats: ['oas2', 'oas3']
|
|
43
|
+
given: '#CustomOperation[*]'
|
|
44
|
+
then:
|
|
45
|
+
function: schema
|
|
46
|
+
functionOptions:
|
|
47
|
+
schema:
|
|
48
|
+
type: object
|
|
49
|
+
properties:
|
|
50
|
+
operationId:
|
|
51
|
+
type: string
|
|
52
|
+
pattern: '^:[A-Z].*$'
|
|
53
|
+
required: ['operationId']
|
package/aep/0137.yaml
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
aliases:
|
|
2
|
+
ApplyOperation:
|
|
3
|
+
description: An Apply method is a put on path that ends in a path parameter
|
|
4
|
+
targets:
|
|
5
|
+
- formats: ['oas2', 'oas3']
|
|
6
|
+
given:
|
|
7
|
+
- $.paths[?(@property.match(/\}$/))].put
|
|
8
|
+
|
|
9
|
+
rules:
|
|
10
|
+
aep-137-operation-id:
|
|
11
|
+
description: The operation ID should be Apply{resource-singular}.
|
|
12
|
+
message: The operation ID does not conform to AEP-137
|
|
13
|
+
severity: error
|
|
14
|
+
formats: ['oas2', 'oas3']
|
|
15
|
+
given: '#ApplyOperation'
|
|
16
|
+
then:
|
|
17
|
+
function: schema
|
|
18
|
+
functionOptions:
|
|
19
|
+
schema:
|
|
20
|
+
type: object
|
|
21
|
+
properties:
|
|
22
|
+
operationId:
|
|
23
|
+
type: string
|
|
24
|
+
pattern: '^[Aa][Pp][Pp][Ll][Yy].*$'
|
|
25
|
+
required: ['operationId']
|
|
26
|
+
|
|
27
|
+
aep-137-request-body:
|
|
28
|
+
description: A standard Apply method must accept the resource in the request body.
|
|
29
|
+
message: The request body is not an AEP resource.
|
|
30
|
+
severity: error
|
|
31
|
+
formats: ['oas3']
|
|
32
|
+
given: '#ApplyOperation'
|
|
33
|
+
then:
|
|
34
|
+
function: schema
|
|
35
|
+
functionOptions:
|
|
36
|
+
schema:
|
|
37
|
+
type: object
|
|
38
|
+
required: ['requestBody']
|
|
39
|
+
properties:
|
|
40
|
+
requestBody:
|
|
41
|
+
# I tried putting this schema is a separate file and $ref'ing it, but it didn't work
|
|
42
|
+
description: A content object with an AEP resource schema.
|
|
43
|
+
type: object
|
|
44
|
+
required: ['content']
|
|
45
|
+
properties:
|
|
46
|
+
content:
|
|
47
|
+
type: object
|
|
48
|
+
additionalProperties:
|
|
49
|
+
type: object
|
|
50
|
+
required: ['schema']
|
|
51
|
+
properties:
|
|
52
|
+
schema:
|
|
53
|
+
type: object
|
|
54
|
+
required: ['x-aep-resource']
|
|
55
|
+
|
|
56
|
+
aep-137-required-params:
|
|
57
|
+
description: A standard Apply method must not have any required parameters other than path parameters.
|
|
58
|
+
severity: error
|
|
59
|
+
formats: ['oas2', 'oas3']
|
|
60
|
+
given:
|
|
61
|
+
- '#ApplyOperation.parameters[?(@.in != "path")]'
|
|
62
|
+
- '#ApplyOperation^.parameters[?(@.in != "path")]' # parameters at path item level
|
|
63
|
+
then:
|
|
64
|
+
field: required
|
|
65
|
+
function: falsy
|
|
66
|
+
|
|
67
|
+
aep-137-response-body:
|
|
68
|
+
description: The success response for a standard Apply method must be the AEP resource.
|
|
69
|
+
message: The response body is not an AEP resource.
|
|
70
|
+
severity: error
|
|
71
|
+
formats: ['oas3']
|
|
72
|
+
given: '#ApplyOperation'
|
|
73
|
+
then:
|
|
74
|
+
function: schema
|
|
75
|
+
functionOptions:
|
|
76
|
+
schema:
|
|
77
|
+
type: object
|
|
78
|
+
required: ['responses']
|
|
79
|
+
properties:
|
|
80
|
+
responses:
|
|
81
|
+
type: object
|
|
82
|
+
# don't require a 200 response, since it's possible to have a 202
|
|
83
|
+
properties:
|
|
84
|
+
'200':
|
|
85
|
+
description: A content object with an AEP resource schema.
|
|
86
|
+
type: object
|
|
87
|
+
required: ['content']
|
|
88
|
+
properties:
|
|
89
|
+
content:
|
|
90
|
+
type: object
|
|
91
|
+
additionalProperties:
|
|
92
|
+
type: object
|
|
93
|
+
required: ['schema']
|
|
94
|
+
properties:
|
|
95
|
+
schema:
|
|
96
|
+
type: object
|
|
97
|
+
required: ['x-aep-resource']
|
|
98
|
+
|
|
99
|
+
aep-137-unknown-optional-params:
|
|
100
|
+
description: A standard Apply method should not have unknown optional parameters.
|
|
101
|
+
severity: warn
|
|
102
|
+
formats: ['oas2', 'oas3']
|
|
103
|
+
given:
|
|
104
|
+
- '#ApplyOperation.parameters[?(@.in == "query")]' # only check query parameters
|
|
105
|
+
- '#ApplyOperation^.parameters[?(@.in == "query")]' # parameters at path item level
|
|
106
|
+
then:
|
|
107
|
+
# Use schema function on name so that the error points to the name field
|
|
108
|
+
function: schema
|
|
109
|
+
functionOptions:
|
|
110
|
+
schema:
|
|
111
|
+
type: object
|
|
112
|
+
properties:
|
|
113
|
+
name:
|
|
114
|
+
# Apply has no defined optional parameters
|
|
115
|
+
enum: [null]
|
package/aep/0140.yaml
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
rules:
|
|
2
|
+
aep-140-boolean-property-naming:
|
|
3
|
+
description: 'Boolean properties should omit the prefix "is".'
|
|
4
|
+
severity: warn
|
|
5
|
+
given: '$..[?(@.type == "boolean")]~'
|
|
6
|
+
then:
|
|
7
|
+
field: '@key'
|
|
8
|
+
function: pattern
|
|
9
|
+
functionOptions:
|
|
10
|
+
notMatch: '^[Ii][Ss]_?[A-Za-z0-9_-]*$'
|
|
11
|
+
|
|
12
|
+
aep-140-uri-property-naming:
|
|
13
|
+
description: 'Properties representing URLs or URIs should be named "uri" rather than "url".'
|
|
14
|
+
severity: warn
|
|
15
|
+
given: '$..[?(@.type == "string" && (@property.match(/url$/)))]~'
|
|
16
|
+
then:
|
|
17
|
+
function: falsy
|
package/aep/0142.yaml
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
functionsDir: ../functions
|
|
2
|
+
functions:
|
|
3
|
+
- aep-142-time-field-type
|
|
4
|
+
|
|
5
|
+
rules:
|
|
6
|
+
aep-142-time-field-type:
|
|
7
|
+
description: 'Fields with time-related suffixes should use appropriate types and formats.'
|
|
8
|
+
message: '{{error}}'
|
|
9
|
+
severity: warn
|
|
10
|
+
formats: ['oas2', 'oas3']
|
|
11
|
+
given: '$..properties[?(@property.match(/_(time|times|date|seconds|millis|micros|nanos)$/))]'
|
|
12
|
+
then:
|
|
13
|
+
function: aep-142-time-field-type
|
|
14
|
+
|
|
15
|
+
aep-142-time-field-names:
|
|
16
|
+
description: 'Timestamp fields should use imperative mood with _time suffix, not past tense.'
|
|
17
|
+
message: 'Use imperative mood with "_time" suffix (e.g., "{{property}}_time") instead of past tense.'
|
|
18
|
+
severity: warn
|
|
19
|
+
formats: ['oas2', 'oas3']
|
|
20
|
+
given: '$..[?(@.type == "string" && @.format == "date-time")]~'
|
|
21
|
+
then:
|
|
22
|
+
field: '@key'
|
|
23
|
+
function: pattern
|
|
24
|
+
functionOptions:
|
|
25
|
+
notMatch: '(created|creation|updated|modified|expired|purged|deleted|published|started|ended|completed)'
|
|
26
|
+
|
|
27
|
+
aep-142-time-field-suffix:
|
|
28
|
+
description: 'Timestamp fields must end in _time suffix.'
|
|
29
|
+
message: 'Timestamp field "{{property}}" should end with "_time" suffix.'
|
|
30
|
+
severity: warn
|
|
31
|
+
formats: ['oas2', 'oas3']
|
|
32
|
+
given: '$..[?(@.type == "string" && @.format == "date-time")]~'
|
|
33
|
+
then:
|
|
34
|
+
field: '@key'
|
|
35
|
+
function: pattern
|
|
36
|
+
functionOptions:
|
|
37
|
+
match: '_time$'
|
package/aep/0143.yaml
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
functionsDir: ../functions
|
|
2
|
+
functions:
|
|
3
|
+
- standardized-codes
|
|
4
|
+
|
|
5
|
+
rules:
|
|
6
|
+
aep-143-standardized-codes:
|
|
7
|
+
description: Field names for standardized codes must follow AEP-143 conventions.
|
|
8
|
+
message: '{{error}}'
|
|
9
|
+
severity: error
|
|
10
|
+
formats: ['oas2', 'oas3']
|
|
11
|
+
given: $.components.schemas[*]
|
|
12
|
+
then:
|
|
13
|
+
function: standardized-codes
|
|
14
|
+
|
|
15
|
+
aep-143-standardized-codes-string-type:
|
|
16
|
+
description: Standardized code fields must be of type "string".
|
|
17
|
+
message: 'Standardized code field "{{property}}" must be type "string"'
|
|
18
|
+
severity: error
|
|
19
|
+
formats: ['oas2', 'oas3']
|
|
20
|
+
given:
|
|
21
|
+
- $.components.schemas[*].properties[?(@property in ['content_type', 'currency_code', 'language_code'])]
|
|
22
|
+
- $.components.schemas[*].properties[?(@property in ['region_code', 'time_zone', 'utc_offset'])]
|
|
23
|
+
then:
|
|
24
|
+
function: schema
|
|
25
|
+
functionOptions:
|
|
26
|
+
schema:
|
|
27
|
+
type: object
|
|
28
|
+
required: ['type']
|
|
29
|
+
properties:
|
|
30
|
+
type:
|
|
31
|
+
const: string
|
package/aep/0144.yaml
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
aliases:
|
|
2
|
+
AddRemovePathItem:
|
|
3
|
+
description: An Update Array operation is a post request that updates an array with add or remove operation
|
|
4
|
+
targets:
|
|
5
|
+
- formats: ['oas2', 'oas3']
|
|
6
|
+
given:
|
|
7
|
+
- $.paths[?(@property.match(/:(add|remove)([^/]*)$/))]
|
|
8
|
+
|
|
9
|
+
rules:
|
|
10
|
+
aep-144-operation-id:
|
|
11
|
+
description: The operation ID must begin with the word add or remove.
|
|
12
|
+
message: The operation ID does not conform to AEP-144.
|
|
13
|
+
severity: error
|
|
14
|
+
formats: ['oas2', 'oas3']
|
|
15
|
+
given: '#AddRemovePathItem[*].operationId'
|
|
16
|
+
then:
|
|
17
|
+
function: pattern
|
|
18
|
+
functionOptions:
|
|
19
|
+
match: '^([Aa]dd|[Rr]emove)[A-Z].*$'
|
|
20
|
+
|
|
21
|
+
aep-144-http-method:
|
|
22
|
+
description: An Update Array operation must be POST.
|
|
23
|
+
severity: error
|
|
24
|
+
formats: ['oas2', 'oas3']
|
|
25
|
+
given: '#AddRemovePathItem'
|
|
26
|
+
then:
|
|
27
|
+
function: schema
|
|
28
|
+
functionOptions:
|
|
29
|
+
schema:
|
|
30
|
+
# trigger if any method is not POST
|
|
31
|
+
not:
|
|
32
|
+
anyOf:
|
|
33
|
+
- required: ['delete']
|
|
34
|
+
- required: ['get']
|
|
35
|
+
- required: ['head']
|
|
36
|
+
- required: ['options']
|
|
37
|
+
- required: ['patch']
|
|
38
|
+
- required: ['put']
|
|
39
|
+
- required: ['trace']
|
package/aep/0151.yaml
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
aliases:
|
|
2
|
+
LongRunningOperation:
|
|
3
|
+
description: An operation that returns 202 Accepted for long-running operations
|
|
4
|
+
targets:
|
|
5
|
+
- formats: ['oas2', 'oas3']
|
|
6
|
+
given:
|
|
7
|
+
- $.paths[*].[post,put,patch,delete].responses.202^^
|
|
8
|
+
|
|
9
|
+
functionsDir: ../functions
|
|
10
|
+
functions:
|
|
11
|
+
- operations-endpoint
|
|
12
|
+
|
|
13
|
+
rules:
|
|
14
|
+
aep-151-202-only-success:
|
|
15
|
+
description: Long-running operations must return 202 as the only success status code
|
|
16
|
+
message: Long-running operations must return 202 as the only success status code
|
|
17
|
+
severity: error
|
|
18
|
+
formats: ['oas2', 'oas3']
|
|
19
|
+
given:
|
|
20
|
+
- '#LongRunningOperation.responses'
|
|
21
|
+
then:
|
|
22
|
+
function: schema
|
|
23
|
+
functionOptions:
|
|
24
|
+
schema:
|
|
25
|
+
not:
|
|
26
|
+
anyOf:
|
|
27
|
+
- required: ['200']
|
|
28
|
+
- required: ['201']
|
|
29
|
+
- required: ['204']
|
|
30
|
+
|
|
31
|
+
aep-151-202-schema-required:
|
|
32
|
+
description: A 202 response must define an application/json response body with Operation schema
|
|
33
|
+
severity: error
|
|
34
|
+
formats: ['oas3']
|
|
35
|
+
given:
|
|
36
|
+
- '#LongRunningOperation.responses.202'
|
|
37
|
+
then:
|
|
38
|
+
function: schema
|
|
39
|
+
functionOptions:
|
|
40
|
+
schema:
|
|
41
|
+
type: object
|
|
42
|
+
required: ['content']
|
|
43
|
+
properties:
|
|
44
|
+
content:
|
|
45
|
+
type: object
|
|
46
|
+
required: ['application/json']
|
|
47
|
+
properties:
|
|
48
|
+
'application/json':
|
|
49
|
+
type: object
|
|
50
|
+
required: ['schema']
|
|
51
|
+
|
|
52
|
+
aep-151-operation-schema:
|
|
53
|
+
description: Operation schema must have correct property types
|
|
54
|
+
message: Operation schema must have correct property types
|
|
55
|
+
severity: error
|
|
56
|
+
formats: ['oas3']
|
|
57
|
+
given:
|
|
58
|
+
- '#LongRunningOperation.responses.202.content.application/json.schema'
|
|
59
|
+
then:
|
|
60
|
+
function: schema
|
|
61
|
+
functionOptions:
|
|
62
|
+
schema:
|
|
63
|
+
type: object
|
|
64
|
+
required: ['properties']
|
|
65
|
+
properties:
|
|
66
|
+
properties:
|
|
67
|
+
type: object
|
|
68
|
+
required: ['path', 'done', 'error', 'response']
|
|
69
|
+
properties:
|
|
70
|
+
path:
|
|
71
|
+
type: object
|
|
72
|
+
required: ['type']
|
|
73
|
+
properties:
|
|
74
|
+
type:
|
|
75
|
+
enum: ['string']
|
|
76
|
+
done:
|
|
77
|
+
type: object
|
|
78
|
+
required: ['type']
|
|
79
|
+
properties:
|
|
80
|
+
type:
|
|
81
|
+
enum: ['boolean']
|
|
82
|
+
error:
|
|
83
|
+
type: object
|
|
84
|
+
response:
|
|
85
|
+
type: object
|
|
86
|
+
|
|
87
|
+
aep-151-operations-endpoint:
|
|
88
|
+
description: Services with long-running operations must define an operations endpoint
|
|
89
|
+
message: '{{error}}'
|
|
90
|
+
severity: error
|
|
91
|
+
formats: ['oas2', 'oas3']
|
|
92
|
+
given: $.paths
|
|
93
|
+
then:
|
|
94
|
+
function: operations-endpoint
|