Skip to content

Conversation

@manupedrozo
Copy link
Collaborator

@manupedrozo manupedrozo commented Nov 4, 2025

Description

Improving the generation of TF schema attribute names to provide better default UX.

  • Implemented a custom snake case conversion that treats multiple consecutive uppercase letters as part of the same word, except for the last one.

    Examples:
    Before: MongoDBMajorVersion -> mongo_dbmajor_version
    After: MongoDBMajorVersion -> mongo_db_major_version

    Before: AwsIAMType -> aws_iamtype
    After: AwsIAMType -> aws_iam_type

  • Removed xstrings usage from stringcase package.

  • Removed snake_case to camelCase conversions across the autogen code.
    Converting from camelCase to snake_case is fine but its not a reversible operation (see #3740).

  • Config aliases are no longer case converted (preventing potential inconsistencies).

    Example:
    To add an alias for the cluster name in path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName}
    Before we would provide cluster_name: name. cluster_name would be converted to clusterName and replaced in the path.
    Now we directly provide clusterName: name.

Link to any related issue(s): CLOUDP-349435

Type of change:

  • Bug fix (non-breaking change which fixes an issue). Please, add the "bug" label to the PR.
  • New feature (non-breaking change which adds functionality). Please, add the "enhancement" label to the PR. A migration guide must be created or updated if the new feature will go in a major version.
  • Breaking change (fix or feature that would cause existing functionality to not work as expected). Please, add the "breaking change" label to the PR. A migration guide must be created or updated.
  • This change requires a documentation update
  • Documentation fix/enhancement

Required Checklist:

  • I have signed the MongoDB CLA
  • I have read the contributing guides
  • I have checked that this change does not generate any credentials and that they are NOT accidentally logged anywhere.
  • I have added tests that prove my fix is effective or that my feature works per HashiCorp requirements
  • I have added any necessary documentation (if appropriate)
  • I have run make fmt and formatted my code
  • If changes include deprecations or removals I have added appropriate changelog entries.
  • If changes include removal or addition of 3rd party GitHub actions, I updated our internal document. Reach out to the APIx Integration slack channel to get access to the internal document.

Further comments

@manupedrozo manupedrozo force-pushed the CLOUDP-349435-custom-case-conversion branch from 4d2dc20 to 5cdcd83 Compare November 4, 2025 11:10
@manupedrozo manupedrozo marked this pull request as ready for review November 4, 2025 12:10
@manupedrozo manupedrozo requested a review from a team as a code owner November 4, 2025 12:10
method: PATCH
version_header: application/vnd.atlas.2023-01-01+json
schema:
aliases:
Copy link
Collaborator

Choose a reason for hiding this comment

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

nice with simplified config!

path: /api/atlas/v2/groups/{groupId}/auditLog
version_header: application/vnd.atlas.2023-01-01+json
name: auditing_api
packageName: auditingapi
Copy link
Collaborator

Choose a reason for hiding this comment

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

[nit] Aren't these always following the same rule. Do we need to be explicit?

Copy link
Collaborator Author

@manupedrozo manupedrozo Nov 4, 2025

Choose a reason for hiding this comment

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

No need to be explicit but would rather calculate once and avoid maintaining consistency in multiple places.
We now set it once during spec generation and reuse it during code generation, which also makes it configurable in the intermediate model.

Copy link
Collaborator

@EspenAlbert EspenAlbert left a comment

Choose a reason for hiding this comment

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

Nice just a few nit comments

Copy link
Member

@AgustinBettati AgustinBettati left a comment

Choose a reason for hiding this comment

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

nice!

Comment on lines +18 to 21
groupId: projectId
group_id: project_id
nested_list_array_attr.inner_num_attr: inner_num_attr_alias
outer_object.nested_level1.level_field1: level_field1_alias
Copy link
Member

Choose a reason for hiding this comment

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

nit: should we adjust these overrides? Not certain if the snake case is still supported

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

These are still supported!
We can provide aliases for TF schema attributes. I expect that we'll do this for group_id -> project_id before releasing an autogen resource.

@manupedrozo manupedrozo merged commit e244b6f into master Nov 4, 2025
53 checks passed
@manupedrozo manupedrozo deleted the CLOUDP-349435-custom-case-conversion branch November 4, 2025 17:01
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.

4 participants