Skip to content

Conversation

@yelizhenden-mdb
Copy link
Collaborator

Proposed changes

Jira ticket: CLOUDP-305821

  • Introduces CONTRIBUTING.md for the guidelines how to contribute to the repo
  • Updates README.md with what the project is and how to use it

Checklist

  • I have signed the MongoDB CLA
  • I have added tests that prove my fix is effective or that my feature works

Changes to Spectral

  • I have read the README file for Spectral Updates

Further comments

"x-xgen-IPA-exception": {
"xgen-IPA-104-resource-has-GET": "Legacy API, not used by infrastructure-as-code tooling",
}
```
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy part from the spec when you mention exception placements or reference to openapi file as example of exceptions

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exception placements are also referring to the MMS Java code, should we include it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant that you can list examples where exception can be placed or not placed.

Example:

For example on how to place exceptions please refer to the atlas openapi file [ref]

Or

Exceptions can be typically correlated with spectral `given` value and placed on:

- in path object
- in each http method, requests  and responses
- components. schemas objects

Comment on lines 69 to 88
### Resource & Singleton Evaluation

In the IPA Spectral validation, a resource can be identified using a resource collection path.

For example, resource collection path: `/resource`

- To get all paths and the path objects for this resource, use [getResourcePathItems](https://github.com/mongodb/openapi/blob/99823b3dfd315f892c5f64f1db50f2124261929c/tools/spectral/ipa/rulesets/functions/utils/resourceEvaluation.js#L143)

- Will return path objects for paths (if present):
- Resource collection path `/resource`
- Single resource path `/resource + /{someId}`
- Custom method path(s)
- `/resource + /{someId} + :customMethod`
- `/resource + :customMethod`

- To check if a resource is a singleton, take the returned object from [getResourcePathItems](https://github.com/mongodb/openapi/blob/99823b3dfd315f892c5f64f1db50f2124261929c/tools/spectral/ipa/rulesets/functions/utils/resourceEvaluation.js#L143) and evaluate the resource using [isSingletonResource](https://github.com/mongodb/openapi/blob/99823b3dfd315f892c5f64f1db50f2124261929c/tools/spectral/ipa/rulesets/functions/utils/resourceEvaluation.js#L71)
- To check if a path belongs to a resource collection, use [isResourceCollectionIdentifier](https://github.com/mongodb/openapi/blob/99823b3dfd315f892c5f64f1db50f2124261929c/tools/spectral/ipa/rulesets/functions/utils/resourceEvaluation.js#L13)
- To check if a path belongs to a single resource, use [isSingleResourceIdentifier](https://github.com/mongodb/openapi/blob/99823b3dfd315f892c5f64f1db50f2124261929c/tools/spectral/ipa/rulesets/functions/utils/resourceEvaluation.js#L31)

![info](https://img.shields.io/badge/info-blue) Note: Paths like `/resource/resource` or `/resource/{id}/{id}` are not evaluated as valid resource or single resource paths using isResourceCollectionIdentifier or isSingleResourceIdentifier.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wondering if that can be incorporated into rules documentation?
This would not be typical content in Contributing

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is an implementation detail, so I thought that it might stay here in contributing. I will rephrase it a bit

Copy link
Member

@wtrocki wtrocki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome PR! Thank you for adding those changes!
All comments optional

@yelizhenden-mdb yelizhenden-mdb marked this pull request as ready for review April 8, 2025 11:11
@yelizhenden-mdb yelizhenden-mdb requested a review from a team as a code owner April 8, 2025 11:11
@yelizhenden-mdb yelizhenden-mdb merged commit a62ca77 into main Apr 8, 2025
8 checks passed
@yelizhenden-mdb yelizhenden-mdb deleted the CLOUDP-305821 branch April 8, 2025 12:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants