@microsoft/fast-permutator v2.3.0
FAST Permutator
FAST Permutator has been deprecated. Use FAST Tooling React instead.
The FAST permutator creates all possible data permutations from a given JSON Schema, allowing for deep testing or display of complex data sets.
Use
Including the permutator
Add the permutator as a required variable:
const permutator = require('@microsoft/fast-permutator');Permutating data sets
The main export of the permutator is to recieve a schema and any schema references. For example, take this simple schema:
let schema = {
type: "object",
properties: {
stringItem: {
type: "string",
example: "Hello World"
},
booleanItem: {
type: "boolean"
}
},
required: [
"stringItem"
]
};
permutator(schema);This main export permutator will generate the following data:
[
{
stringItem: "Hello World"
},
{
stringItem: "Hello World"
booleanItem: true
},
{
stringItem: "Hello World"
booleanItem: false
}
]If an example or a default is not provided, fake data will be generated.
Exporting an example
Use the export getExample to retrieve an example piece of data.
permutator.getExample(schema);Simplifying schemas
Use the export simplifySchemas to show all schema permutations. This can be useful for extrapolating out all possible schema combinations.
permutator.simplifySchemas(schema, references);Finding properties
Use the export getDeepPropLocations to find properties within the schema.
permutator.getDeepPropLocations(schema, propertyName);Resolve references
Use the export resolveReferences to resolve the references of a schema by consolidating them with their referenced schema.
permutator.resolveReferences(schema, references);Resolving properties
Use the export resolveSchemaProps to resolve the given props for a schema.
permutator.resolveSchemaProps(schema, ['$ref', 'allOf']);Developing
Contribute to the ES6 source files in the lib folder.
Testing
Run npm run test to test the exposed utilities and schemas
Building
Run npm run build to build before npm publish to convert files to ES5 from ES6.
Special properties
whitelistedignores a propertyexampleis a piece of supplied example data
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago