Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions tools/spectral/ipa/rulesets/IPA-106.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,29 @@ functions:

rules:
xgen-IPA-106-create-method-request-body-is-request-suffixed-object:
description: 'The Create method request should be a Request suffixed object. http://go/ipa/106'
description: >-
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.
message: '{{error}} http://go/ipa/106'
severity: warn
given: '$.paths[*].post.requestBody.content'
then:
field: '@key'
function: 'createMethodRequestBodyIsRequestSuffixedObject'
xgen-IPA-106-create-method-should-not-have-query-parameters:
description: 'Create operations should not use query parameters. http://go/ipa/106'
description: >-
Create operations should not use query parameters. http://go/ipa/106
This rule applies only to POST requests targeting resource collection URIs.
message: '{{error}} http://go/ipa/106'
severity: warn
given: '$.paths[*].post'
then:
function: 'createMethodShouldNotHaveQueryParameters'
xgen-IPA-106-create-method-request-body-is-get-method-response:
description: |
Request body content of the Create method and response content of the Get method should refer to the same resource.
readOnly/writeOnly properties will be ignored. http://go/ipa/106
description: >-
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.
message: '{{error}} http://go/ipa/106'
severity: warn
given: '$.paths[*].post.requestBody.content'
Expand All @@ -37,15 +42,19 @@ rules:
functionOptions:
ignoredValues: ['readOnly', 'writeOnly']
xgen-IPA-106-create-method-request-has-no-readonly-fields:
description: 'Create method Request object must not include fields with readOnly:true. http://go/ipa/106'
description: >-
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.
message: '{{error}} http://go/ipa/106'
severity: warn
given: '$.paths[*].post.requestBody.content'
then:
field: '@key'
function: 'createMethodRequestHasNoReadonlyFields'
xgen-IPA-106-create-method-response-code-is-201:
description: 'Create methods must return a 201 Created response code. http://go/ipa/106'
description: >-
Create methods must return a 201 Created response code. http://go/ipa/106
This rule applies only to POST requests targeting resource collection URIs.
message: '{{error}} http://go/ipa/106'
severity: warn
given: '$.paths[*].post'
Expand Down
16 changes: 7 additions & 9 deletions tools/spectral/ipa/rulesets/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,13 @@ For rule definitions, see [IPA-105.yaml](https://github.com/mongodb/openapi/blob

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

| Rule Name | Description | Severity |
| ------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- |
| 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 |
| xgen-IPA-106-create-method-should-not-have-query-parameters | Create operations should not use query parameters. http://go/ipa/106 | warn |
| 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.
readOnly/writeOnly properties will be ignored. http://go/ipa/106
| warn |
| 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 |
| xgen-IPA-106-create-method-response-code-is-201 | Create methods must return a 201 Created response code. http://go/ipa/106 | warn |
| Rule Name | Description | Severity |
| ------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------- |
| 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 |
| 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 |
| 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 |
| 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 |
| 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 |

### IPA-108

Expand Down
Loading