Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consistent field naming when aliasing #393

Closed

Conversation

franzliedke
Copy link

@franzliedke franzliedke commented Feb 5, 2024

This fixes #281 by adding a new source: option to fields, identifiers and associations, as a replacement for the name: option.

The beauty of this approach is that the structure of the resulting JSON document can more easily recognized even when "squinting" and only looking at the first parameter of each field or association:

class MyBlueprint < Blueprinter::Base
  identifier :uuid, source: :id

  field :title, source: :title_string
  association :owner, blueprint: UserBlueprint, source: :user
end

I tweaked all existing tests and made them pass. To get this out of draft state:

  • Agree on naming
  • Add tests for deprecated name: options
  • Add deprecation warnings when using deprecated name: options

Checklist:

  • I have updated the necessary documentation
  • I have signed off all my commits as required by DCO
  • My build is green

Signed-off-by: Franz Liedke <franz@develophp.org>
Signed-off-by: Franz Liedke <franz@develophp.org>
@ritikesh
Copy link
Collaborator

I'm good with the approach, however, we need to support the older way as well and provide deprecation warnings for the same.

Copy link

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make field naming more consistent
2 participants