Work in progress
RESP API documentation is automatically generated thanks to the route api_documentation
The abstract entity ApiEntity
defines a function docData
which is used to create the standard documentation ( findall, findone, create, update, detroy ) for a data entity.
This means that the documentation contains automatically all the attributes defined in the entity model.
If you want to change the content of the api documentation for a specific entity, you have to override docData function.
Edit the file app/api/myentity.js and create a new function docData.
Here is an example :
const api_documentation = require('@core/helpers/api_documentation');
docData(){
// if you want to begin with the native documentation, you can create it using the helper
let doc_native = api_documentation.entityDocumentation('e_myentity', attributes, options);
// You can then create all the attributes of you new api route
let mynewattributes = [{
field: "MyDataField",
type: 'STRING',
description: `description`,
defaultValue: '',
required: true
}];
// Creation of documentation for new API routes
let doc_synchro = {
title: "Synchro",
description: "your description",
method: 'POST',
url: '/api/myentity/synchro',
parameters: {
query: [
api_documentation.globals.parameters.token
],
body: [mynewattributes]
},
response: "expected response text",
errors: [
api_documentation.globals.errors.error500
]
}
doc_native.routes.push(doc_synchro);
return doc_native;
}