2016-04-28 6 views
0

ループバックでは、表示されたswagger jsonからPKを削除する方法を教えてください。 ループバックswaggerでpkを削除します

この

は、JSON私の闊歩に表示されている:0:私は "ID" を削除できるか

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

画像SWAGGER

swagger

detail-?

これは私の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

をしました。これがあなたが望むものでない場合は、無効にしてください。 '' id ":false'プロパティを追加することで、モデル内に隠すこともできます。 – CherryDT

+0

idInjectionは効果がありません – Sergio

答えて

1

Hiddenプロパティは、あなたが `idInjection`が有効になっているトリック

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

あなた自身の答えを受け入れてください。 – CherryDT

関連する問題