Skip to content

Commit 936804f

Browse files
Fix: Refine Create method descriptions with the resource collection applicability (#532)
1 parent a60dc7f commit 936804f

File tree

2 files changed

+23
-16
lines changed

2 files changed

+23
-16
lines changed

tools/spectral/ipa/rulesets/IPA-106.yaml

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,29 @@ functions:
1010

1111
rules:
1212
xgen-IPA-106-create-method-request-body-is-request-suffixed-object:
13-
description: 'The Create method request should be a Request suffixed object. http://go/ipa/106'
13+
description: >-
14+
The Create method request should be a Request suffixed object. http://go/ipa/106
15+
This rule applies only to POST requests targeting resource collection URIs.
1416
message: '{{error}} http://go/ipa/106'
1517
severity: warn
1618
given: '$.paths[*].post.requestBody.content'
1719
then:
1820
field: '@key'
1921
function: 'createMethodRequestBodyIsRequestSuffixedObject'
2022
xgen-IPA-106-create-method-should-not-have-query-parameters:
21-
description: 'Create operations should not use query parameters. http://go/ipa/106'
23+
description: >-
24+
Create operations should not use query parameters. http://go/ipa/106
25+
This rule applies only to POST requests targeting resource collection URIs.
2226
message: '{{error}} http://go/ipa/106'
2327
severity: warn
2428
given: '$.paths[*].post'
2529
then:
2630
function: 'createMethodShouldNotHaveQueryParameters'
2731
xgen-IPA-106-create-method-request-body-is-get-method-response:
28-
description: |
29-
Request body content of the Create method and response content of the Get method should refer to the same resource.
30-
readOnly/writeOnly properties will be ignored. http://go/ipa/106
32+
description: >-
33+
Request body content of the Create method and response content of the Get method should refer to the same resource. http://go/ipa/106
34+
readOnly/writeOnly properties will be ignored.
35+
This rule applies only to POST requests targeting resource collection URIs.
3136
message: '{{error}} http://go/ipa/106'
3237
severity: warn
3338
given: '$.paths[*].post.requestBody.content'
@@ -37,15 +42,19 @@ rules:
3742
functionOptions:
3843
ignoredValues: ['readOnly', 'writeOnly']
3944
xgen-IPA-106-create-method-request-has-no-readonly-fields:
40-
description: 'Create method Request object must not include fields with readOnly:true. http://go/ipa/106'
45+
description: >-
46+
Create method Request object must not include fields with readOnly:true. http://go/ipa/106
47+
This rule applies only to POST requests targeting resource collection URIs.
4148
message: '{{error}} http://go/ipa/106'
4249
severity: warn
4350
given: '$.paths[*].post.requestBody.content'
4451
then:
4552
field: '@key'
4653
function: 'createMethodRequestHasNoReadonlyFields'
4754
xgen-IPA-106-create-method-response-code-is-201:
48-
description: 'Create methods must return a 201 Created response code. http://go/ipa/106'
55+
description: >-
56+
Create methods must return a 201 Created response code. http://go/ipa/106
57+
This rule applies only to POST requests targeting resource collection URIs.
4958
message: '{{error}} http://go/ipa/106'
5059
severity: warn
5160
given: '$.paths[*].post'

tools/spectral/ipa/rulesets/README.md

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,13 @@ For rule definitions, see [IPA-105.yaml](https://github.com/mongodb/openapi/blob
5353

5454
For rule definitions, see [IPA-106.yaml](https://github.com/mongodb/openapi/blob/main/tools/spectral/ipa/rulesets/IPA-106.yaml).
5555

56-
| Rule Name | Description | Severity |
57-
| ------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- |
58-
| xgen-IPA-106-create-method-request-body-is-request-suffixed-object | The Create method request should be a Request suffixed object. http://go/ipa/106 | warn |
59-
| xgen-IPA-106-create-method-should-not-have-query-parameters | Create operations should not use query parameters. http://go/ipa/106 | warn |
60-
| xgen-IPA-106-create-method-request-body-is-get-method-response | Request body content of the Create method and response content of the Get method should refer to the same resource.
61-
readOnly/writeOnly properties will be ignored. http://go/ipa/106
62-
| warn |
63-
| xgen-IPA-106-create-method-request-has-no-readonly-fields | Create method Request object must not include fields with readOnly:true. http://go/ipa/106 | warn |
64-
| xgen-IPA-106-create-method-response-code-is-201 | Create methods must return a 201 Created response code. http://go/ipa/106 | warn |
56+
| Rule Name | Description | Severity |
57+
| ------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------- |
58+
| xgen-IPA-106-create-method-request-body-is-request-suffixed-object | The Create method request should be a Request suffixed object. http://go/ipa/106 This rule applies only to POST requests targeting resource collection URIs. | warn |
59+
| xgen-IPA-106-create-method-should-not-have-query-parameters | Create operations should not use query parameters. http://go/ipa/106 This rule applies only to POST requests targeting resource collection URIs. | warn |
60+
| xgen-IPA-106-create-method-request-body-is-get-method-response | Request body content of the Create method and response content of the Get method should refer to the same resource. http://go/ipa/106 readOnly/writeOnly properties will be ignored. This rule applies only to POST requests targeting resource collection URIs. | warn |
61+
| xgen-IPA-106-create-method-request-has-no-readonly-fields | Create method Request object must not include fields with readOnly:true. http://go/ipa/106 This rule applies only to POST requests targeting resource collection URIs. | warn |
62+
| xgen-IPA-106-create-method-response-code-is-201 | Create methods must return a 201 Created response code. http://go/ipa/106 This rule applies only to POST requests targeting resource collection URIs. | warn |
6563

6664
### IPA-108
6765

0 commit comments

Comments
 (0)