I'm trying to create a Nested field to a response model. I don't unserstand why the generated swagger.json is aware of the nested field but do not register it under $/definitions.
This is my Model
HypervisorResponse = ns.model('HypervisorResponse', {
'name': fields.String(required=True, example='hypervisor01.xx.com'),
'ip_addr': fields.String(required=True, example='192.168.0.0'),
'provider': fields.String(required=True),
'runtime': fields.Nested(
ns.model('RuntimeResponse', {
'uptime': fields.Integer(attribute='uptime'),
'last_boot': fields.String(attribute='last_boot'),
'memory_total': fields.Integer(attribute='memory_total'),
'memory_used': fields.Integer(attribute='memory_used')
})
)
})
The outputted swagger.json is
"HypervisorResponse": {
"required": [
"ip_addr",
"name",
"provider"
],
"properties": {
"name": {
"type": "string",
"example": "hypervisor01.xx.com"
},
"ip_addr": {
"type": "string",
"example": "192.168.0.0"
},
"provider": {
"type": "string"
},
"runtime": {
"$ref": "#/definitions/RuntimeResponse"
}
},
"type": "object"
}
After a while i figured out that the NAMESPACE ordered property were the cause of it. Setting it to False solved the issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With