Resource and Canonical Properties use of null
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Rust
- Estrellas
- 523
- Forks
- 75
- Merge medio
- 3 d 16 h
- PR fusionados (30 d)
- 24
Descripción
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"]
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Comienza revisando los esquemas JSON de los recursos DSC enumerados y la propiedad canónica _inDesiredState, utilizando como alcance la lista de recursos y propiedades del issue. Comprueba qué propiedades aceptan realmente null frente a las que simplemente son opcionales y, a continuación, valida los esquemas resultantes con respecto a la semántica documentada de JSON Schema y a las expectativas del autocompletado de Bicep. El trabajo estará terminado cuando se eliminen los tipos null injustificados y se conserven los valores nullable legítimos.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- json
- Área
- tooling
- Tipo de issue
- Error
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 35/100