Documentation ¶
Overview ¶
Package schemamod contains utility functions to modify schemas.
Key functions can be used to add propertyNames to schema. This is intended for generating modified versions of a schema to verify strict compliance with only the defined properties of the schema.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddPropertyNames ¶
AddPropertyNames walks through a JSON schema contained in the "in" parameter, adding propertyName constraints. The resulting schema enforces that only the specified properties appear in the output instance document. This is intended to generate schemas that catch serialization output mistakes.
Note that existing propertyNames constraints are left unmodified. Also note that an extra "//GENERATED" property is added to clearly indicate the additional constraints that have been added.
For example:
{ "properties": { "doc": ... } }
... becomes something like this
{ "properties": { "doc": ... }, "propertyNames": { "//GENERATED": "propertyNames constraint generated", "enum": [ "doc" ] } }
func AddPropertyNamesToFile ¶
AddPropertyNamesToFile modifieds a JSON schema file, and writes the result to a new location. See AddPropertyNames for details.
Types ¶
This section is empty.