MCPcopy Create free account
hub / github.com/wavetermdev/waveterm / allowNullValues

Function allowNullValues

cmd/generateschema/main-generateschema.go:111–121  ·  view source on GitHub ↗

allowNullValues wraps the top-level additionalProperties of a map schema with anyOf: [originalSchema, {type: "null"}] so that setting a key to null is valid (e.g. "bg@foo": null to remove a default entry).

(schema *jsonschema.Schema)

Source from the content-addressed store, hash-verified

109// anyOf: [originalSchema, {type: "null"}] so that setting a key to null is valid
110// (e.g. "bg@foo": null to remove a default entry).
111func allowNullValues(schema *jsonschema.Schema) {
112 if schema.AdditionalProperties != nil && schema.AdditionalProperties != jsonschema.TrueSchema && schema.AdditionalProperties != jsonschema.FalseSchema {
113 original := schema.AdditionalProperties
114 schema.AdditionalProperties = &jsonschema.Schema{
115 AnyOf: []*jsonschema.Schema{
116 original,
117 {Type: "null"},
118 },
119 }
120 }
121}
122
123func generateSchema(template any, dir string, allowNull bool) error {
124 settingsSchema := jsonschema.Reflect(template)

Callers 2

generateSchemaFunction · 0.85
generateWidgetsSchemaFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected