Skip to content

Conversation

@yelizhenden-mdb
Copy link
Collaborator

@yelizhenden-mdb yelizhenden-mdb commented Mar 19, 2025

Proposed changes

Jira ticket: CLOUDP-272001

Schema field names should avoid using "project", "projects", or "projectId".

      ##### Implementation details
      Rule checks for the following conditions:
        - Searches through all schemas in the API definition
        - Identifies property names that match "project" (case-insensitive)
        - Reports any instances where these field names are used
        - Suggests using "group", "groups", or "groupId" as alternatives

15 violations found

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 marked this pull request as ready for review March 19, 2025 14:25
@yelizhenden-mdb yelizhenden-mdb requested a review from a team as a code owner March 19, 2025 14:25
then:
function: 'IPA112AvoidProjectFieldNames'
functionOptions:
prohibitedFieldName: 'project'
Copy link
Member

Choose a reason for hiding this comment

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

[Nit] can we have this as array? I can see more prohibited names in future

Comment on lines +126 to +128
'x-xgen-IPA-exception': {
'xgen-IPA-112-avoid-project-field-names': 'reason',
},
Copy link
Collaborator

Choose a reason for hiding this comment

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

Q: Is it possible to have exceptions on properties? IIRC when we did the enum rule we had to have the exception on the schema

Copy link
Collaborator Author

@yelizhenden-mdb yelizhenden-mdb Mar 19, 2025

Choose a reason for hiding this comment

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

For enum one, we have the exceptions on the property level. Ex:


"roleName": {
            "description": "Human-readable label that identifies a group of privileges assigned to a database user. This value can either be a built-in role or a custom role.",
            "enum": [
              "atlasAdmin",
               ...
            ],
            "type": "string",
            "x-xgen-IPA-exception": {
              "xgen-IPA-123-enum-values-must-be-upper-snake-case": "Schema predates IPA validation"
            }
          }

which is equivalent of Schema annotation for the property itself on Java. I kept the same level for exception. Are you asking keeping the exception level for Schema annotation level but for the schema level?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah thanks for clarifying, I misremembered and thought it was on the schema level higher up. LGTM 👍

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.

(Prettier failure, otherwise LGTM)

@yelizhenden-mdb yelizhenden-mdb merged commit 475abee into main Mar 19, 2025
8 checks passed
@yelizhenden-mdb yelizhenden-mdb deleted the CLOUDP-272001 branch March 19, 2025 15:49
@wtrocki
Copy link
Member

wtrocki commented Mar 19, 2025

@yelizhenden-mdb Feel free to setup commit hook. It will sort out prettier during commit

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