expand-to
v0.0.6
Published
Tools for transforming JSON-schema models into dev/build/test/run-time application tools
Downloads
4
Readme
Expand-to 
Tools for transforming JSON-schema models into dev/build/test/run-time application tools
Features
belongsTo→ nests one resource inside anotherhasMany→ adds routes for one-to-many relationshipshasMany+as→ adds routes for polymorphic one-to-many relationshipsname: user+hasMany→ a nested a copy ofhasManyroutes are added to the user resource for accessing via the users' implicit identitytreeOf→ adds routes for accessing and mutating a hierarchical resourceimmutable: true→ omits methods that would mutate the resourceversioned: true→ adds routes for listing, accessing, and restoring versioned entities (TODO)undeletable: true→ adds routes for listing, accessing, and undeleting soft deleted entities (TODO)
Examples
Test suite examples are dumped in OpenAPI format:
See examples dir for more examples
API
A single low level function is provided to tranform a spec into a raw description of the resources and models. Usually this will not be called directly.
expandToResources(spec, config = {})→{ paths, models }
The most common use case is to use the following functions that take a spec and an optional config and return an object that is useful to your application.
expandToOperations(spec, config = {})→{ paths, models, operations }expandToOpenApi(spec, config = {})→openApiSpecexpandToValidations(spec, config = {})→{ paths, models, operations, validations }expandToTestData(spec, config = {})→(operationName)→testData
Alternatively each core API function exposes a lower level function that can be used to compose your own custom tranformations.
expandToOpenApi({ operations, models }, config = {})→{ models, operations, spec }expandToOperations({ paths, models }, config = {})→{ paths, models, operations }expandToValidations({ operations, models }, config = {})→{ paths, models, operations, validations }expandToTestData({ operations, models }, config = {})→{ paths, models, operations, testData }
