我创建了一个 API。获取我的资源给出:
{
category: {
id: "517ed1bff929f90e1152ad43",
name: "Test category"
},
cost: "Free",
description: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras tincidunt augue in mi scelerisque quis condimentum velit sollicitudin. Nam eleifend posuere semper. Pellentesque non nulla et arcu ornare lacinia. Donec quis dui at velit placerat volutpat vitae sit amet lorem. ",
genders: [
"M",
"F"
],
id: "517ed1bff929f90e1152ad44",
tags: [
{
id: "517ed1bff929f90e1152ad3f",
name: "testing",
resource_uri: "/api/v1/interests/517ed1bff929f90e1152ad3f/"
},
{
id: "517ed1bff929f90e1152ad41",
name: "coding",
resource_uri: "/api/v1/interests/517ed1bff929f90e1152ad41/"
}
],
location: {
lat_lng: [
51.500705,
-0.124575
],
locality: "London",
name: "Big Ben"
},
resource_uri: "/api/v1/events/517ed1bff929f90e1152ad44/",
slug: "test-event1",
title: "Test event1"
}
我希望允许用户以列表形式提交标签,例如 ['testing', 'coding', 'python'] 而不是要求他们提交对象 - 这是因为如果不存在标签对象,我将创建一个。
我怎么能用美味的派来做到这一点,它违反了 REST 原则?