Using HUG for building a Rest API, VERSION 2.3.0 (https://github.com/timothycrosley/hug)
I cannot use the Nested ability of Marshmallow in HUG. Here is some code.
import config
from tinydb import TinyDB, Query
import hug
import hashlib
import logging
import os
from marshmallow import Schema, fields, validates, ValidationError
class MultilanguageSchema(Schema):
language = fields.Str()
value = fields.Str()
class TitleSchema(Schema):
titles = fields.Nested(MultilanguageSchema, many = True)
class DescriptionSchema(Schema):
descriptions = fields.Nested(MultilanguageSchema, many = True)
@hug.post('/ads', requires=api_key_authentication, versions=1)
def post_ad(sites_id: hug.types.number,
name: hug.types.text,
age: hug.types.in_range(18, 99),
telephone: hug.types.number,
titles: hug.types.MarshmallowSchema(TitleSchema()),
descriptions: hug.types.MarshmallowSchema(DescriptionSchema()),
authed_user: hug.directives.user):
pdb.set_trace()
When I try to do a POST request with this example data I got empty data on the Nested fields.
sites_id: 1
name: Test Name
age: 34
telephone: 999999999
titles: {"language":"en","value":"Some Title"}
descriptions: {"language":"en","value":"Some Description"}
Using pdb:
titles: {}
descriptions: {}
Anyone have been able to use the Nested ability of Marshmallow in HUG. If yes, how to do it?