I'm trying to implement a route in my flask application to serve the OPTIONS method of a given resource and return a description of the marshmallow schema associated to said resource. Something similar to what django does:
{
"name": "Dataset List",
"description": "",
"renders": [
"application/json",
"text/html"
],
"parses": [
"application/json",
"application/x-www-form-urlencoded",
"multipart/form-data"
],
"actions": {
"POST": {
"id": {
"type": "integer",
"required": false,
"read_only": true,
"label": "ID"
},
"url": {
"type": "field",
"required": false,
"read_only": true,
"label": "Url"
},
"name": {
"type": "string",
"required": true,
"read_only": false,
"label": "Name",
"help_text": "The dataset name.",
"max_length": 256
}
}
}
}
I can't seem to find any method in Schema
or in the docs that returns this description, and AlbumSchema.opts.fields
is empty. Is it possible to iterate throughout the fields and build the description I need? Something in the line of:
desc = {f: {"required": f.required,
"type": f.__class__.__name__,
...}
for f in AlbumSchema.fields}