为了账号安全,请及时绑定邮箱和手机立即绑定

Flask 嵌套的 rest api 招摇不工作

Flask 嵌套的 rest api 招摇不工作

哔哔one 2021-09-14 15:13:19
address = api.schema_model('Address', {    'properties': {        'road': {            'type': 'string'        },    },    'type': 'object' })person = address = api.schema_model('Person', {    'required': ['address'],    'properties': {        'name': {            'type': 'string'        },        'age': {            'type': 'integer'        },        'birthdate': {            'type': 'string',            'format': 'date-time'        },        'address': {            '$ref': '#/definitions/Address',        }    },    'type': 'object' })错误在定义中隐藏解析器错误。Person.properties.address.$ref 无法解析引用,因为:无法解析指针:/NestedModel 在文档中不存在
查看完整描述

1 回答

?
浮云间

TA贡献1829条经验 获得超4个赞

最后我可以用下面的代码解决问题


nested_fields = api.schema_model('NestedModel', {'name': fields.String})

person = address = api.schema_model('Person', {

    'required': ['address'],

    'properties': {

        'name': {

            'type': 'string'

        },

        'age': {

            'type': 'integer'

        },

        'birthdate': {

            'type': 'string',

            'format': 'date-time'

        },

        'address': {


            'properties': {

                'arguments': {

                    'type': 'array',

                    'items': {


                    }

                }

            },

            'type': 'object'

        }

    },

    'type': 'object'

})


查看完整回答
反对 回复 2021-09-14
  • 1 回答
  • 0 关注
  • 182 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号