2016-04-28 23 views
0

在迴環中,我怎麼能從顯示的swagger json中刪除PK。刪除pk中的迴環swagger

這是JSON顯示在我的招搖:

{ 
    "user_id": "string", 
    "order_type": "string", 
    "date": "2016-04-28", 
    "payload": { 
    "id": 0 
    }, 
    "id": 0 
} 

圖像detail-揚鞭

swagger

我怎麼能去掉 「標識」:0?

這是我order.json:

{ 
    "name": "Order", 
    "plural": "Orders", 
    "base": "Model", 
    "idInjection": true, 
    "options": { 
    "validateUpsert": true 
    }, 
    "properties": { 
    "user_id": { 
     "type": "string", 
     "required": true 
    }, 
    "order_type": { 
     "type": "string", 
     "required": true 
    }, 
    "date": { 
     "type": "date", 
     "required": true 
    }, 
    "payload": { 
     "type": "Payload", 
     "required": true 
    } 
    }, 
    "validations": [], 
    "relations": {}, 
    "acls": [], 
    "methods": {} 
} 

這是我order.js:

module.exports = (Order) => { 

    Order.create = function(body, cb) { 
    // 
    } 

    Order.remoteMethod('create', { 
    'http': {'path': '/'}, 
    'accepts': [ 
     {'arg': 'body', 'type': 'Order', 'required': true, 'http': { 'source': 'body' } } 
    ] 
    }); 

}; 
+0

你'啓用idInjection'。如果這不是您想要的,請禁用它。您也可以嘗試通過添加屬性'「id」:false'來隱藏它。 – CherryDT

+0

id注射沒有效果 – Sergio

回答

1

隱藏屬性的伎倆

{ 
    "name": "Order", 
    "plural": "Orders", 
    "base": "Model", 
    "idInjection": false, 
    "options": { 
    "validateUpsert": true 
    }, 
    "properties": { 
    ... 
    }, 
    "validations": [], 
    "relations": {}, 
    "acls": [], 
    "methods": {}, 
    "hidden": ["id"] 
} 
+0

您應該接受您自己的答案。 – CherryDT