Skip to content

CLOUDP-415688: add IPA-103, IPA-117 and IPA-131 Spectral rules - #1505

Draft
mongodb-sage-bot[bot] wants to merge 1 commit into
mainfrom
sage-bot/coding-session/sage-coding-session-1790171591830
Draft

mongodb-sage-bot[bot] wants to merge 1 commit into
mainfrom
sage-bot/coding-session/sage-coding-session-1790171591830

Conversation

@mongodb-sage-bot

Copy link
Copy Markdown
Contributor

Proposed changes

Implements the outstanding Spectral rule candidates identified for the
Terraform autogeneration IPA enhancements (CLOUDP-356095).

  • IPA-103 (new ruleset): xgen-IPA-103-response-body-root-shape (error)
    enforces that every JSON response body schema is an object with named
    properties, or a oneOf whose variants are all objects. It rejects
    arrays, primitives and objects whose only key is additionalProperties.
    IPA-110 collection envelopes (results/links/totalCount) satisfy the rule.
  • IPA-117: xgen-IPA-117-oneof-property-descriptions-must-match (warn)
    surfaces oneOf variants where a shared property's description diverges.
  • IPA-131 (new ruleset): per-extension structural validation that fires
    only when the extension is declared:
    • xgen-IPA-131-array-semantic (error): carrying property must be
      type: array and the value must be list or set.
    • xgen-IPA-131-server-computed-when-client-omitted (error): value must
      be a boolean and the property must not be listed as required.
    • xgen-IPA-131-server-computed-immutable (error): value must be a
      boolean and the property must be readOnly: true.

New rulesets are wired into ipa-spectral.yaml, the shared extension
constants are added to functions/utils/extensions.js, and the generated
rulesets README is regenerated.

Jira ticket: CLOUDP-415688

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

Important

MongoDB Contribution Guidelines

This pull request was generated by sage-bot on behalf of andrei.matei@mongodb.com (ticket assignee). The assignee must self-review the changes before requesting review from another engineer.
The assignee is not allowed to merge their own PR without approval from another engineer.

## Proposed changes

Implements the outstanding Spectral rule candidates identified for the
Terraform autogeneration IPA enhancements (CLOUDP-356095).

- IPA-103 (new ruleset): `xgen-IPA-103-response-body-root-shape` (error)
  enforces that every JSON response body schema is an object with named
  properties, or a `oneOf` whose variants are all objects. It rejects
  arrays, primitives and objects whose only key is `additionalProperties`.
  IPA-110 collection envelopes (results/links/totalCount) satisfy the rule.
- IPA-117: `xgen-IPA-117-oneof-property-descriptions-must-match` (warn)
  surfaces `oneOf` variants where a shared property's description diverges.
- IPA-131 (new ruleset): per-extension structural validation that fires
  only when the extension is declared:
  - `xgen-IPA-131-array-semantic` (error): carrying property must be
    `type: array` and the value must be `list` or `set`.
  - `xgen-IPA-131-server-computed-when-client-omitted` (error): value must
    be a boolean and the property must not be listed as required.
  - `xgen-IPA-131-server-computed-immutable` (error): value must be a
    boolean and the property must be `readOnly: true`.

New rulesets are wired into `ipa-spectral.yaml`, the shared extension
constants are added to `functions/utils/extensions.js`, and the generated
rulesets README is regenerated.

_Jira ticket:_ CLOUDP-415688

## Checklist

- [ ] I have signed the [MongoDB CLA](https://www.mongodb.com/legal/contributor-agreement)
- [x] I have added tests that prove my fix is effective or that my feature works

### Changes to Spectral
- [x] I have read the [README](../tools/spectral/README.md) file for Spectral Updates
@mongodb-sage-bot

Copy link
Copy Markdown
Contributor Author

Sage Bot can help with this pull request. Just @sage-bot in comments and I'll start working on changes in this branch.
Learn more about Sage Bot

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.

1 participant