Data
Example of automatic documentation
Thanks to JSON Schema and standardization, we are able to generate a clear and explicit documentation of any entity of the your Data Model.
You can see the resulting API documentation for the Accounts entity here
Original Schema
- Javascript Object
- Raw JSON Object
const c = require('../../../dist/constants');
const MODEL_DATABASE = 'datastore';
const MODEL_NAME = 'accounts';
const CORRELATION_FIELD = 'account_id';
const is_enabled = c.COMPONENTS.is_enabled;
const tags = c.COMPONENT_TAGS;
const annotations = c.COMPONENT_ANNOTATIONS;
const email = {
...c.COMPONENT_EMAIL,
description: 'Account email of the user',
example: 'john@doe.org',
};
const auth = {
type: 'string',
description: 'Authentication token',
};
const is_email_verified = {
...c.COMPONENT_BOOLEAN,
description: 'Is the email verified',
example: false,
};
const email_verification_token = {
...c.COMPONENT_UUID_V4,
description: 'Verification token for a newly registerd email',
};
const reset_password_uuid = {
...c.COMPONENT_UUID_V4,
description: 'Unique ID to use to reset the password',
};
const reset_password_expires_by = {
...c.COMPONENT_DATE,
description: 'Reset password request expiration date',
};
const properties = {
is_enabled,
tags,
annotations,
auth,
// Email
email,
email_verification_token,
is_email_verified,
// Reset password
reset_password_uuid,
reset_password_expires_by,
};
module.exports = {
is_enabled: true,
db: MODEL_DATABASE,
name: MODEL_NAME,
correlation_field: CORRELATION_FIELD,
encrypted_fields: ['email'],
schema: {
model: {
properties,
},
events: {
[c.EVENT_TYPE_CREATED]: {
'0_0_0': {
required: ['email', 'auth'],
properties,
},
},
[c.EVENT_TYPE_UPDATED]: {
'0_0_0': {
properties,
},
},
[c.EVENT_TYPE_RESTORED]: {
'0_0_0': {
properties,
},
},
},
},
};
{
"is_enabled" : true,
"db" : "datastore",
"name" : "accounts",
"correlation_field" : "account_id",
"encrypted_fields" : [
"email"
],
"schema" : {
"model" : {
"properties" : {
"is_enabled" : {
"type" : "boolean",
"description" : "Boolean indicating the enabling state of the entity",
"example" : true
},
"auth" : {
"type" : "string",
"description" : "Authentication token"
},
"email" : {
"type" : "string",
"description" : "Account email of the user",
"example" : "john@doe.org",
"format" : "email"
},
"email_verification_token" : {
"type" : "string",
"description" : "Verification token for a newly registerd email",
"example" : "9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d",
"pattern" : "^([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})?$"
},
"is_email_verified" : {
"type" : "boolean",
"description" : "Is the email verified",
"example" : false
},
"reset_password_uuid" : {
"type" : "string",
"description" : "Unique ID to use to reset the password",
"example" : "9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d",
"pattern" : "^([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})?$"
},
"reset_password_expires_by" : {
"type" : "string",
"description" : "Reset password request expiration date",
"example" : "2019-01-01T00:00:00.000Z",
"format" : "date-time"
}
}
},
"events" : {
"CREATED" : {
"0_0_0" : {
"required" : [
"email",
"auth"
],
"properties" : {
"is_enabled" : {
"type" : "boolean",
"description" : "Boolean indicating the enabling state of the entity",
"example" : true
},
"auth" : {
"type" : "string",
"description" : "Authentication token"
},
"email" : {
"type" : "string",
"description" : "Account email of the user",
"example" : "john@doe.org",
"format" : "email"
},
"email_verification_token" : {
"type" : "string",
"description" : "Verification token for a newly registerd email",
"example" : "9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d",
"pattern" : "^([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})?$"
},
"is_email_verified" : {
"type" : "boolean",
"description" : "Is the email verified",
"example" : false
},
"reset_password_uuid" : {
"type" : "string",
"description" : "Unique ID to use to reset the password",
"example" : "9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d",
"pattern" : "^([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})?$"
},
"reset_password_expires_by" : {
"type" : "string",
"description" : "Reset password request expiration date",
"example" : "2019-01-01T00:00:00.000Z",
"format" : "date-time"
}
}
}
},
"UPDATED" : {
"0_0_0" : {
"properties" : {
"is_enabled" : {
"type" : "boolean",
"description" : "Boolean indicating the enabling state of the entity",
"example" : true
},
"auth" : {
"type" : "string",
"description" : "Authentication token"
},
"email" : {
"type" : "string",
"description" : "Account email of the user",
"example" : "john@doe.org",
"format" : "email"
},
"email_verification_token" : {
"type" : "string",
"description" : "Verification token for a newly registerd email",
"example" : "9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d",
"pattern" : "^([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})?$"
},
"is_email_verified" : {
"type" : "boolean",
"description" : "Is the email verified",
"example" : false
},
"reset_password_uuid" : {
"type" : "string",
"description" : "Unique ID to use to reset the password",
"example" : "9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d",
"pattern" : "^([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})?$"
},
"reset_password_expires_by" : {
"type" : "string",
"description" : "Reset password request expiration date",
"example" : "2019-01-01T00:00:00.000Z",
"format" : "date-time"
}
}
}
},
"RESTORED" : {
"0_0_0" : {
"properties" : {
"is_enabled" : {
"type" : "boolean",
"description" : "Boolean indicating the enabling state of the entity",
"example" : true
},
"auth" : {
"type" : "string",
"description" : "Authentication token"
},
"email" : {
"type" : "string",
"description" : "Account email of the user",
"example" : "john@doe.org",
"format" : "email"
},
"email_verification_token" : {
"type" : "string",
"description" : "Verification token for a newly registerd email",
"example" : "9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d",
"pattern" : "^([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})?$"
},
"is_email_verified" : {
"type" : "boolean",
"description" : "Is the email verified",
"example" : false
},
"reset_password_uuid" : {
"type" : "string",
"description" : "Unique ID to use to reset the password",
"example" : "9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d",
"pattern" : "^([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})?$"
},
"reset_password_expires_by" : {
"type" : "string",
"description" : "Reset password request expiration date",
"example" : "2019-01-01T00:00:00.000Z",
"format" : "date-time"
}
}
}
}
}
}
}