Resource and Canonical Properties use of null
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Rust
- Star
- 526
- Fork
- 76
- Merge trung bình
- 3 ngày 16 giờ
- Pull request đã merge (30 ngày)
- 24
Mô tả
Prerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest version
- Search the existing issues.
Summary
There are built-in resources and canonical properties (_inDesiredState) that use null in addition to actual type of the property. Null should NOT be a valid type unless the property actually accepts null as a valid use case. By allowing null it can confuse users when we have auto-complete in BICEP and weakens the strongly validated schema.
JSON schema null and undefined properties are different.
https://json-schema.org/understanding-json-schema/reference/null
Excerpt:
It's important to remember that in JSON, null isn't equivalent to something being absent. See Required Properties for an example.
The mechanism to indicate a property is required or optional is by the use of the required property.
I understand that we're using nullable types so we can return only the properties that are actually defined instead of empty strings or false bools but it is not best practice.
Resources with Nullable Properties:
-
Microsoft.DSC.Debug/Echo
showSecrets:type: ["boolean", "null"] -
Microsoft.DSC.Transitional/PowerShellScript
getScript:type: ["string", "null"]
setScript:type: ["string", "null"]
testScript:type: ["string", "null"]
input:type: ["string", "boolean", "integer", "object", "array", "null"]
output:type: ["array", "null"]
_inDesiredState:type: ["boolean", "null"] -
Microsoft.DSC.Transitional/WindowsPowerShellScript
getScript:type: ["string", "null"]
setScript:type: ["string", "null"]
testScript:type: ["string", "null"]
input:type: ["string", "boolean", "integer", "object", "array", "null"]
output:type: ["array", "null"]
_inDesiredState:type: ["boolean", "null"] -
Microsoft.OpenSSH.SSHD/Windows
shell:type: ["string", "null"]
cmdOption:type: ["string", "null"]
escapeArguments:type: ["boolean", "null"] -
Microsoft.Windows/RebootPending
reasons:type: ["array", "null"]
The entire object itself:type: ["object", "null"] -
Microsoft.Windows/Registry
_metadata:anyOf: [{"$ref": "#/$defs/Metadata"}, {"type": "null"}]
valueName:type: ["string", "null"]
valueData:anyOf: [{"$ref": "#/$defs/RegistryValueData"}, {"type": "null"}]
_exist:type: ["boolean", "null"]
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu bằng cách xem xét các lược đồ JSON cho những tài nguyên DSC được liệt kê và thuộc tính chuẩn _inDesiredState, sử dụng danh sách tài nguyên và thuộc tính của issue làm phạm vi. Kiểm tra thuộc tính nào thực sự chấp nhận null thay vì chỉ là tùy chọn, sau đó xác thực các lược đồ thu được theo ngữ nghĩa JSON Schema được lập tài liệu và kỳ vọng của tính năng tự động hoàn tất Bicep. Hoàn tất có nghĩa là loại bỏ các kiểu null không có cơ sở trong khi vẫn giữ lại các giá trị nullable hợp lệ.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- json
- Lĩnh vực
- tooling
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 35/100