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

Should we remove the requirement on properties with default values ?

未关闭
#3 0 条评论 0 个 reaction 已指派 2 人 在 GitHub 查看

@IsakNaslundBh 已经在做这个了。

开始于 2025年9月3日。

评估

这个 Issue 还没有评估数据。

描述

type:question

In the BHoM_UI, users are only required to provide properties that don't have a default value. Considering that the JSON schemas are meant to be used with external partners that don't necessarily have the exact same set of properties as the BHoM, it would be great to do something similar. That way, they can provide only the properties that are relevant within their own environment without having to handle the potential extra richness/complexity that the BHoM might offer.

Here's an example of what I mean. Here's our current schema for a Line:

{
  "$id" : "https://raw.githubusercontent.com/BHoM/BHoM_JSONSchema/develop/Geometry_oM/Line.json",
  "title" : "Line",
  "type" : ["object", "null"],
  "description" : "Line: A straight segment in space defining the shortest distance between two points in three-dimensional Euclidean geometry.\nThe Vector from Start to End defines the Line direction, which can be important for some applications.",
  "properties" : {
    "Start" : {
      "$ref" : "https://raw.githubusercontent.com/BHoM/BHoM_JSONSchema/develop/Geometry_oM/Point.json"
    },
    "End" : {
      "$ref" : "https://raw.githubusercontent.com/BHoM/BHoM_JSONSchema/develop/Geometry_oM/Point.json"
    },
    "Infinite" : {
      "type" : "boolean",
      "description" : "Defines the Line as a ray of infinite extents in both directions"
    },
    "_t" : {
      "type" : ["string", "null"],
      "description" : "Optional type disciminator.",
      "const" : "BH.oM.Geometry.Line"
    },
    "_bhomVersion" : {
      "type" : ["string", "null"],
      "description" : "Optional version of BHoM used as part of automatic versioning and schema upgrades."
    }
  },
  "required" : ["Start", "End", "Infinite"]
}

This means that this would fail the validation as it doesn't contain the Infinite property:

{
    "_t": "BH.oM.Geometry.Line",
    "Start": {
      "_t": "BH.oM.Geometry.Point",
      "X": 1,
      "Y": 2,
      "Z": 3
    },
    "End": {
      "_t": "BH.oM.Geometry.Point",
      "X": 1,
      "Y": 2,
      "Z": 3
    },
    "_bhomVersion": "8.1"
}

My issue here is that the BHoM Line would actually be created successfully from the above. So we are enforcing additional constrains that are not a reflection of that would actually work in practice.

I understand that we want to protect the user from incorrectly naming properties. But would it be possible to have warnings instead of errors on properties from the json that are not found on the BHoM object itself? This is what we do in the BHoM_UI and it works quite well that way, providing the best of both worlds.

主要语言
C#
星标
0
派生
0
PR 合并指标
30 天内没有已合并 PR

环境准备

从这里开始

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

BHoM/JSONSchema_Toolkit 的其他 Issue

查看 BHoM/JSONSchema_Toolkit 的全部 Issue

相似的 Issue

更多 C# Issue

把新 issue 发到你的邮箱

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