Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Aliased Attribute Names Are Not Used In Error Responses

Đang mở
#1,447 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
38/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
rails, ruby
Lĩnh vực
api, backend

Hướng nghiên cứu

Không có tệp triển khai hoặc bài kiểm thử nào được nêu tên. Hãy tái hiện trường hợp ủy quyền attribute :active, delegate: :status_is_active và theo dõi cách các lỗi xác thực được tuần tự hóa; hoàn thành khi cả chi tiết lỗi và source pointer của JSON:API đều sử dụng active thay vì status_is_active.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

This issue is a (choose one):

  • [X ] Problem/bug report.
  • Feature request.
  • Request for support. Note: Please try to avoid submitting issues for support requests. Use Gitter instead.

Checklist before submitting:

  • [ X] I've searched for an existing issue.
  • I've asked my question on Gitter and have not received a satisfactory answer.
  • I've included a complete bug report template. This step helps us and allows us to see the bug without trying to reproduce the problem from your description. It helps you because you will frequently detect if it's a problem specific to your project.
  • [ X] The feature I'm asking for is compliant with the JSON:API spec.

Description

I have a model with an attribute named status_is_active. In the API we want this to render as active so do the following in the resource:

attribute :active, delegate: :status_is_active

If there is an API error related to this attribute, the error reports the name from the model rather than the name from the resource. For example:

{
  "errors": [
    {
      "title": "is not included in the list",
      "detail": "status_is_active - is not included in the list",
      "code": "100",
      "source": {
          "pointer": "/data/attributes/status_is_active"
      },
      "status": "422"
    }
  ]
}

Expected: the error uses the name of the attribute in the resource rather than the name used in the model. For example:

{
  "errors": [
    {
      "title": "is not included in the list",
      "detail": "active - is not included in the list",
      "code": "100",
      "source": {
          "pointer": "/data/attributes/active"
      },
      "status": "422"
    }
  ]
}

Rationale: users of the API only know about what's in the API - returning a value from the model that is aliased in the API is confusing/wrong.

Thanks!

Ngôn ngữ chính
Ruby
Star
2.3k
Fork
546
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của JSONAPI-Resources/jsonapi-resources

Tất cả issue của JSONAPI-Resources/jsonapi-resources

Issue tương tự

Thêm issue về Ruby

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.