Remove methods
By default, two endpoints are created:
- A global endpoint, with three methods:
get()
, that returns all the element of the table.
post(**kwargs)
, that adds a new row to the table.
- A detail endpoint, with three methods:
get(idx)
, that returns the entry with the given id.
put(idx, **kwargs)
, that updates the entry with the given id with the given data.
patch(idx, **kwargs)
that patches the entry with the given id with the given oatch.
delete(idx)
, that deletes the entry with the given id.
If one or several of those methods are not necessary, the option --remove-methods
or -r
allows to not
generate some of those methods.
Example:
generate_from_schema -p C:/Users/User/instance.json -a application_name --remove-methods get-list -r delete-detail
In that example, for each table, the detail endpoint will not contain the delete()
method and
the list endpoint will not contain the get()
method. The choices for this method are
get-list
, post-list
, get-detail
, put-detail
, delete-detail
and patch-detail
.
One table
By default, the module accepts schemas that contain several tables at once (see for example the
instance schema for the rostering application, in cornflow-dags). If you only need to create one table,
the schema can also have the following format:
{
"type": "array",
"description": "Table with the employee master information",
"items": {
"type": "object",
"properties": {
"id": {
"description": "The unique identifier for each employee.",
"type": "integer",
},
"name": {
"description": "The name of each employee.",
"type": "string",
},
},
"required": [
"id",
"name",
]
}
}
that is, the schema is simply the description of the table. In that case, you can use
the --one
option to indicate the name of the table. If not, the generated table will be called
{application_name}_data
by default.
Example:
generate_from_schema -p C:/Users/User/instance.json -a application_name --one table_name
In that case, only one table will be created.