Skip to main content

Structure of package.json

The basic package file package.json looks as follows:

{
"name": "hello-world",
"description": "description of my hello-world component",
"version": "1.0.0",
"oc": {
"files": {
"data": "server.js",
"template": {
"src": "template.hbs",
"type": "oc-template-handlebars"
}
}
},
"devDependencies": {
"oc-template-handlebars-compiler": "6.0.8"
}
}
ParameterTypeDescription
namestringthe component's name, by default the name of initialised component
descriptionstringthe component's description, by default an empty string
versionstringthe component's version, by default 1.0.0
authorstringthe component's author - suggested format is John Doe <john@doe.com>
repositorystringthe component's repository
dependenciesobjectthe npm modules the component requires
devDependenciesobjectthe npm modules the component requires in order to be developed. By convention a component of templateTypeX will require a devDependency called templateTypeX-compiler to work
ocobjectthe data involved with the component
oc.containerbooleanforces the component to be server-side rendered without being wrapped inside the <oc-component /> tag.
oc.filesobjectnon-static component files
oc.files.envobjectoptional path for a .env file with environment variables
oc.files.datastringthe model provider's filename, by default server.js
oc.files.templateobjectrepresents the data involved with template - view, template engine
oc.files.template.srcstringthe view's filename, by default template.html
oc.files.template.typestringthe template engine's type, by default handlebars
oc.files.staticarray of stringsAn array of directories that contain static resources referenced from the component's markup
oc.minifybooleanDefault true, will minify static css and js files during publishing
oc.parametersobjectDescribes the component's api. Used to auto-generate documentation and get requests validation. Each key is the parameter name
oc.parameters[key].mandatorybooleanDefault false, if true, any request that does not include a valid value will be rejected with a 400 code.
oc.parameters[key].typestringType of parameter, used for a basic validation check Allowed types are string, boolean, number. When parameter is not valid, request will be rejected with a 400 code
oc.parameters[key].descriptionstringUsed for auto-generated documentation
oc.parameters[key].examplestringUsed for auto-generated documentation
oc.parameters[key].default*Default value of optional parameter - applied when value is not specified in the request
oc.pluginsarray of stringsthe plugins the component requires
oc.renderInfobooleanDefault true, appends script, which adds rendered component information (name and version) to the oc.renderedComponents object
oc.statestringDescribes the state of the component with a keyword. Suggested values are active, experimental, deprecated