schemamod

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 22, 2020 License: BSD-3-Clause Imports: 3 Imported by: 0

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

func AddPropertyNames(in []byte) ([]byte, error)

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

func AddPropertyNamesToFile(inFile, outFile string) error

AddPropertyNamesToFile modifieds a JSON schema file, and writes the result to a new location. See AddPropertyNames for details.

Types

This section is empty.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL