Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Modify Plugs.DataToAttributes to follow JSON API sideposting draft

未关闭
#1,303 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
35/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
停滞
技术栈
elixir
领域
api, backend

调研方向

从 issue 中引用的 DataToAttributes 代码开始,检查 JaSerializer.Params.to_attributes 如何处理 belongs-to 关系。在更改行为之前,先查看 JSON API sideposting draft 和 issue #1301。完成的标准是:array 关系使用 temp-id 标识符选择匹配的 included 记录,而 map 关系仍由 JaSerializer.Params.to_attributes 处理。

由索引模型根据 Issue 内容生成。

描述

blocked

Problem

From https://github.com/json-api/json-api/pull/1197/files?short_path=571f6ce#diff-571f6cee9a492e0e177801c21a4b2b2a

Our current approach with included records is to simply assume they are related to the main record.

Based on the draft

  • included record payloads should have temp-id properties if they are to be created.
  • the main record payload should have a relationship where the identifier is %{data: [%{"temp-id" => "foo", "type" => "bar"}
  • the plug should get those identifiers, then replace the identifier payloads with the associated full payloads matched in included

Subtasks

  • instead of just taking any included records and assuming they're relationships in the resulting params map, DataToAttributes should parse the relationships map first
    • the relationship where data is a map is a belongs to and should be left alone. it's already handled by JaSerializer.Params.to_attributes
    • the relationship where data is an array should be checked for identifiers with temp-id keys
      • each temp-id should be found in the included section and added under the pluralized relationship key in the resulting map

An advantage of this is that we now are able to conclude it's definitely a has_many, so we do not need to explicitly specify this anymore.

References

The code this needs to modify is part of #1301 so this is blocked until that is merged.

主要语言
Elixir
星标
234
派生
82
PR 合并指标
30 天内没有已合并 PR

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

code-corps/code-corps-api 的其他 Issue

查看 code-corps/code-corps-api 的全部 Issue

相似的 Issue

更多 Elixir Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。