Skip to content

Conversation

@yelizhenden-mdb
Copy link
Collaborator

@yelizhenden-mdb yelizhenden-mdb commented Apr 2, 2025

Proposed changes

Jira ticket: CLOUDP-306577


  xgen-IPA-121-date-time-fields-mention-iso-8601:
    description: |
      Fields with format="date-time" should mention ISO 8601 and UTC in their description.

Found 48 violations to fix

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

@yelizhenden-mdb yelizhenden-mdb requested a review from Copilot April 2, 2025 13:02
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request implements a new Spectral rule (IPA-121) to ensure that any API field with a date-time format explicitly mentions the ISO 8601 standard in its description.

  • Adds a new function (IPA121DateTimeFieldsMentionISO8601.js) to check for the ISO 8601 mention in date-time fields.
  • Updates Spectral rulesets and documentation (IPA-121.yaml and README.md) accordingly.
  • Introduces tests for various valid and invalid cases in IPA121DateTimeFieldsMentionISO8601.test.js.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tools/spectral/ipa/rulesets/functions/IPA121DateTimeFieldsMentionISO8601.js Implements the new rule function to enforce ISO 8601 description requirement.
tools/spectral/ipa/rulesets/README.md Documents the new rule with a brief description and usage details.
tools/spectral/ipa/rulesets/IPA-121.yaml Defines the rule in the Spectral ruleset configuration.
tools/spectral/ipa/ipa-spectral.yaml Adds the new IPA-121 ruleset to the overall IPA Spectral configuration.
tools/spectral/ipa/tests/IPA121DateTimeFieldsMentionISO8601.test.js Provides test cases for validating the rule’s behavior.

@yelizhenden-mdb yelizhenden-mdb marked this pull request as ready for review April 2, 2025 13:23
@yelizhenden-mdb yelizhenden-mdb requested a review from a team as a code owner April 2, 2025 13:23
Comment on lines 13 to 16
// Not to duplicate the check for referenced schemas
if (!propertyObject) {
return;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

[Nit] I think you could do this by using the unresolved oas, and this check isn't needed

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 can't think of a way to capture whether a property belongs to a referenced schema. Do you have any suggestions?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Not sure I understand the question. I tested locally to remove this check and by setting resolved: false in the rule definition, and the results are the same. Since the unresolved oas will not send matches for places where $ref is included, it will only validate inline schemas, params and schemas in the components.schemas section

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah okay, you suggested changing the resolved flag to false. Sure, makes sense 👍

@yelizhenden-mdb yelizhenden-mdb changed the title CLOUDP-306577: IPA121: Datetime CLOUDP-306577: IPA-121: Datetime Apr 2, 2025
Copy link
Collaborator

@lovisaberggren lovisaberggren left a comment

Choose a reason for hiding this comment

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

TY!

@yelizhenden-mdb yelizhenden-mdb merged commit 0493c98 into main Apr 2, 2025
8 checks passed
@yelizhenden-mdb yelizhenden-mdb deleted the CLOUDP-306577 branch April 2, 2025 14:45
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.

3 participants