Skip to content

Nested models problem #486

@wackazong

Description

@wackazong

I have a data structure with has nesting. I cannot get restplus to create a correct Swagger documentation. I tried

ns = api.namespace('calendars', description='Operations related to calendars')

availability = ns.model('Availability', {
    'monday': fields.String(required=True, description='Availability of the therapist on Monday'),
})

calendar = ns.model('Calendar', {
    'id': fields.Integer(readOnly=True, description='The unique identifier'),
    'availability': fields.Nested(availability, description='The availability of the therapist during the week')
})

and

ns = api.namespace('calendars', description='Operations related to calendars')

availability = {
    'monday': fields.String(required=True, description='Availability of the therapist on Monday'),
}

calendar = ns.model('Calendar', {
    'id': fields.Integer(readOnly=True, description='The unique identifier'),
    'availability': availability)

and

ns = api.namespace('calendars', description='Operations related to calendars')

availability = {
    'monday': fields.String(required=True, description='Availability of the therapist on Monday'),
}

calendar = ns.model('Calendar', {
    'id': fields.Integer(readOnly=True, description='The unique identifier'),
    'availability': fields.Nested(availability, description='The availability of the therapist during the week')
})

In the first case the Availability model is not in the definitions of the swagger file. In the latter two, restplus seems to expect a model and not a dict. How do I define this correctly? Seems like a trivial data model to me.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions