Skip to content

Add path parameter ID suffix convention - #36

Open
tomasvanrijsse wants to merge 3 commits into
crescat-io:masterfrom
Timatic:path-parameter-id-suffix
Open

Add path parameter ID suffix convention#36
tomasvanrijsse wants to merge 3 commits into
crescat-io:masterfrom
Timatic:path-parameter-id-suffix

Conversation

@tomasvanrijsse

Copy link
Copy Markdown
Contributor

Add path parameter naming convention that appends "Id" suffix for clearer parameter names.
This follows common PHP/REST API conventions where path parameters represent identifiers.

Example: /users/{user} → $userId parameter

This might be a personal preference, but having properties like $user where the value should be $user->id is confusing to me. This obviously only applies to APIs that have path parameters that lack the Id suffix (which is the default for Laravel routes). Let me know what you think.

Changes:

  • Added appendIdToPathParameters config option (default: false)
  • Added transformPathParameter() in RequestGenerator and ResourceGenerator
  • Transform parameter names in constructor signatures
  • Transform parameter references in resolveEndpoint() method
  • Transform parameter names in resource method signatures

tomasvanrijsse and others added 3 commits January 12, 2026 14:57
Add configurable path parameter naming convention that appends "Id"
suffix for clearer parameter names. This follows common PHP/REST API
conventions where path parameters represent identifiers.

Example: /users/{user} → $userId parameter

Changes:
- Added appendIdToPathParameters config option (default: false)
- Added transformPathParameter() in RequestGenerator and ResourceGenerator
- Transform parameter names in constructor signatures
- Transform parameter references in resolveEndpoint() method
- Transform parameter names in resource method signatures
- Maintain backward compatibility (disabled by default)

Configuration:
  new Config(
    connectorName: 'MyApi',
    namespace: 'MyNamespace',
    appendIdToPathParameters: true  // Enable ID suffix
  )

Test coverage:
- Added test to verify feature works when enabled
- All existing tests pass (backward compatible)

Related to Phase 1, PR crescat-io#7 of generator improvements.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
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