The API v2 docs on theforeman.org are automatically generated using from the functional tests using the apipie-rails gem.
The current docs show a root node in POST/PUT calls such as
POST /api/operatingsystems
{
"operatingsystem": {
"name": "awsome_os",
"major": "1",
"minor": "2"
}
}
In order to generate docs without a root node like this:
POST /api/operatingsystems
{
"name": "awsome_os",
"major": "1",
"minor": "2"
}
then we need to update the functional tests to not have a root node.
What do people think about changing nearly all the POST/PUT functional tests?
Rails, using config/initializers/wrap_parameters.rb automatically wraps the parameters into a root node, since that the controller requires the parameters to be in a named root node
def create
@operatingsystem = Operatingsystem.new(params[:operatingsystem])
so the actual parameters received look like this
{
"name": "awsome_os",
"major": "1",
"minor": "2",
"operatingsystem": {
"name": "awsome_os",
"major": "1",
"minor": "2"
}
}
Note, that "path generated" params are not wrapped by Rails. For example
POST /api/architectures/1/operatingsystems
has a parameter {"architecture_id": 1} but it is not wrapped in the "operatingsystem" root node. Here is a good explanation
Regards,
Joseph