Работая в приложении vuejs с axios, у меня есть некоторые данные, структурированные следующим образом:
{
...
surgeries: [],//array of object
patientDiseases: [
{
date: a javascrtipt date,
disease: /api/diseases/#id //This is a valid IRI provided by the api in a select
}
] //array of object
}
Когда я публикую этот набор данных, ответ api-platform будет предоставлен неверно (недопустимый IRI?)
Вот трассировка стека
{
"@context": "\/api\/contexts\/Error",
"@type": "hydra:Error",
"hydra:title": "An error occurred",
"hydra:description": "Invalid value provided (invalid IRI?).",
"trace": [{
"namespace": "",
"short_class": "",
"class": "",
"type": "",
"function": "",
"file": "G:\\6.programacion\\from git\\Veterinaria\\vendor\\api-platform\\core\\src\\Serializer\\AbstractItemNormalizer.php",
"line": 177,
"args": []
}, {
"namespace": "ApiPlatform\\Core\\Serializer",
"short_class": "AbstractItemNormalizer",
"class": "ApiPlatform\\Core\\Serializer\\AbstractItemNormalizer",
"type": "-\u003E",
"function": "setAttributeValue",
"file": "G:\\6.programacion\\from git\\Veterinaria\\vendor\\symfony\\serializer\\Normalizer\\AbstractObjectNormalizer.php",
"line": 261,
"args": [
["object", "App\\Entity\\Disease"],
["integer", 0],
["string", "\/api\/diseases\/4"],
["string", "json"],
["array", {
"groups": ["array", [
["string", "patient"]
]],
"collection_operation_name": ["string", "post"],
"operation_type": ["string", "collection"],
"api_allow_update": ["boolean", true],
"resource_class": ["string", "App\\Entity\\PatientDisease"],
"request_uri": ["string", "\/api\/patients"],
"uri": ["string", "http:\/\/localhost:8000\/api\/patients"],
"api_denormalize": ["boolean", true],
"cache_key": ["string", "e83f0aaf1c78a8d5386bc220724081e1"]
}]
]
}, {
"namespace": "Symfony\\Component\\Serializer\\Normalizer",
"short_class": "AbstractObjectNormalizer",
"class": "Symfony\\Component\\Serializer\\Normalizer\\AbstractObjectNormalizer",
"type": "-\u003E",
"function": "denormalize",
"file": "G:\\6.programacion\\from git\\Veterinaria\\vendor\\api-platform\\core\\src\\Serializer\\AbstractItemNormalizer.php",
"line": 132,
"args": [
["string", "\/api\/diseases\/4"],
["string", "App\\Entity\\Disease"],
["string", "json"],
["array", {
"groups": ["array", [
["string", "patient"]
]],
"collection_operation_name": ["string", "post"],
"operation_type": ["string", "collection"],
"api_allow_update": ["boolean", true],
"resource_class": ["string", "App\\Entity\\PatientDisease"],
"request_uri": ["string", "\/api\/patients"],
"uri": ["string", "http:\/\/localhost:8000\/api\/patients"],
"api_denormalize": ["boolean", true],
"cache_key": ["string", "e83f0aaf1c78a8d5386bc220724081e1"]
}]
]
}, {
"namespace": "ApiPlatform\\Core\\Serializer",
"short_class": "AbstractItemNormalizer",
"class": "ApiPlatform\\Core\\Serializer\\AbstractItemNormalizer",
"type": "-\u003E",
"function": "denormalize",
"file": "G:\\6.programacion\\from git\\Veterinaria\\vendor\\api-platform\\core\\src\\Serializer\\ItemNormalizer.php",
"line": 43,
"args": [
["string", "\/api\/diseases\/4"],
["string", "App\\Entity\\Disease"],
["string", "json"],
["array", {
"groups": ["array", [
["string", "patient"]
]],
"collection_operation_name": ["string", "post"],
"operation_type": ["string", "collection"],
"api_allow_update": ["boolean", true],
"resource_class": ["string", "App\\Entity\\PatientDisease"],
"request_uri": ["string", "\/api\/patients"],
"uri": ["string", "http:\/\/localhost:8000\/api\/patients"],
"api_denormalize": ["boolean", true],
"cache_key": ["string", "e83f0aaf1c78a8d5386bc220724081e1"]
}]
]
}, {
"namespace": "ApiPlatform\\Core\\Serializer",
"short_class": "ItemNormalizer",
"class": "ApiPlatform\\Core\\Serializer\\ItemNormalizer",
"type": "-\u003E",
"function": "denormalize",
"file": "G:\\6.programacion\\from git\\Veterinaria\\vendor\\symfony\\serializer\\Serializer.php",
"line": 177,
"args": [
["string", "\/api\/diseases\/4"],
["string", "App\\Entity\\Disease"],
["string", "json"],
["array", {
"groups": ["array", [
["string", "patient"]
]],
"collection_operation_name": ["string", "post"],
"operation_type": ["string", "collection"],
"api_allow_update": ["boolean", true],
"resource_class": ["string", "App\\Entity\\PatientDisease"],
"request_uri": ["string", "\/api\/patients"],
"uri": ["string", "http:\/\/localhost:8000\/api\/patients"],
"api_denormalize": ["boolean", true],
"cache_key": ["string", "e83f0aaf1c78a8d5386bc220724081e1"]
}]
]
}, {
"namespace": "Symfony\\Component\\Serializer",
"short_class": "Serializer",
"class": "Symfony\\Component\\Serializer\\Serializer",
"type": "-\u003E",
"function": "denormalize",
"file": "G:\\6.programacion\\from git\\Veterinaria\\vendor\\symfony\\serializer\\Normalizer\\AbstractObjectNormalizer.php",
"line": 334,
"args": [
["string", "\/api\/diseases\/4"],
["string", "App\\Entity\\Disease"],
["string", "json"],
["array", {
"groups": ["array", [
["string", "patient"]
]],
"collection_operation_name": ["string", "post"],
"operation_type": ["string", "collection"],
"api_allow_update": ["boolean", true],
"resource_class": ["string", "App\\Entity\\PatientDisease"],
"request_uri": ["string", "\/api\/patients"],
"uri": ["string", "http:\/\/localhost:8000\/api\/patients"],
"api_denormalize": ["boolean", true],
"cache_key": ["string", "e83f0aaf1c78a8d5386bc220724081e1"]
}]
]
}, {
"namespace": "Symfony\\Component\\Serializer\\Normalizer",
"short_class": "AbstractObjectNormalizer",
"class": "Symfony\\Component\\Serializer\\Normalizer\\AbstractObjectNormalizer",
"type": "-\u003E",
"function": "validateAndDenormalize",
"file": "G:\\6.programacion\\from git\\Veterinaria\\vendor\\symfony\\serializer\\Normalizer\\AbstractObjectNormalizer.php",
"line": 259,
"args": [
["string", "App\\Entity\\PatientDisease"],
["string", "disease"],
["string", "\/api\/diseases\/4"],
["string", "json"],
["array", {
"groups": ["array", [
["string", "patient"]
]],
"collection_operation_name": ["string", "post"],
"operation_type": ["string", "collection"],
"api_allow_update": ["boolean", true],
"resource_class": ["string", "App\\Entity\\PatientDisease"],
"request_uri": ["string", "\/api\/patients"],
"uri": ["string", "http:\/\/localhost:8000\/api\/patients"],
"api_denormalize": ["boolean", true],
"cache_key": ["string", "e83f0aaf1c78a8d5386bc220724081e1"]
}]
]
}, {
"namespace": "Symfony\\Component\\Serializer\\Normalizer",
"short_class": "AbstractObjectNormalizer",
"class": "Symfony\\Component\\Serializer\\Normalizer\\AbstractObjectNormalizer",
"type": "-\u003E",
"function": "denormalize",
"file": "G:\\6.programacion\\from git\\Veterinaria\\vendor\\symfony\\serializer\\Serializer.php",
"line": 177,
"args": [
["array", {
"patient": ["array", []],
"date": ["string", "2018-11-27T13:03:00.000Z"],
"disease": ["string", "\/api\/diseases\/4"]
}],
["string", "App\\Entity\\PatientDisease"],
["string", "json"],
["array", {
"groups": ["array", [
["string", "patient"]
]],
"collection_operation_name": ["string", "post"],
"operation_type": ["string", "collection"],
"api_allow_update": ["boolean", true],
"resource_class": ["string", "App\\Entity\\PatientDisease"],
"request_uri": ["string", "\/api\/patients"],
"uri": ["string", "http:\/\/localhost:8000\/api\/patients"],
"api_denormalize": ["boolean", true],
"cache_key": ["string", "e83f0aaf1c78a8d5386bc220724081e1"]
}]
]
}, {
"namespace": "Symfony\\Component\\Serializer",
"short_class": "Serializer",
"class": "Symfony\\Component\\Serializer\\Serializer",
"type": "-\u003E",
"function": "denormalize",
"file": "G:\\6.programacion\\from git\\Veterinaria\\vendor\\api-platform\\core\\src\\Serializer\\AbstractItemNormalizer.php",
"line": 307,
"args": [
["array", {
"patient": ["array", []],
"date": ["string", "2018-11-27T13:03:00.000Z"],
"disease": ["string", "\/api\/diseases\/4"]
}],
["string", "App\\Entity\\PatientDisease"],
["string", "json"],
["array", {
"groups": ["array", [
["string", "patient"]
]],
"collection_operation_name": ["string", "post"],
"operation_type": ["string", "collection"],
"api_allow_update": ["boolean", true],
"resource_class": ["string", "App\\Entity\\PatientDisease"],
"request_uri": ["string", "\/api\/patients"],
"uri": ["string", "http:\/\/localhost:8000\/api\/patients"],
"api_denormalize": ["boolean", true],
"cache_key": ["string", "e83f0aaf1c78a8d5386bc220724081e1"]
}]
]
}, {
"namespace": "ApiPlatform\\Core\\Serializer",
"short_class": "AbstractItemNormalizer",
"class": "ApiPlatform\\Core\\Serializer\\AbstractItemNormalizer",
"type": "-\u003E",
"function": "denormalizeRelation",
"file": "G:\\6.programacion\\from git\\Veterinaria\\vendor\\api-platform\\core\\src\\Serializer\\AbstractItemNormalizer.php",
"line": 272,
"args": [
["string", "patientDiseases"],
["object", "ApiPlatform\\Core\\Metadata\\Property\\PropertyMetadata"],
["string", "App\\Entity\\PatientDisease"],
["array", {
"patient": ["array", []],
"date": ["string", "2018-11-27T13:03:00.000Z"],
"disease": ["string", "\/api\/diseases\/4"]
}],
["string", "json"],
["array", {
"groups": ["array", [
["string", "patient"]
]],
"collection_operation_name": ["string", "post"],
"operation_type": ["string", "collection"],
"api_allow_update": ["boolean", true],
"resource_class": ["string", "App\\Entity\\PatientDisease"],
"request_uri": ["string", "\/api\/patients"],
"uri": ["string", "http:\/\/localhost:8000\/api\/patients"],
"api_denormalize": ["boolean", true],
"cache_key": ["string", "e83f0aaf1c78a8d5386bc220724081e1"]
}]
]
}, {
"namespace": "ApiPlatform\\Core\\Serializer",
"short_class": "AbstractItemNormalizer",
"class": "ApiPlatform\\Core\\Serializer\\AbstractItemNormalizer",
"type": "-\u003E",
"function": "denormalizeCollection",
"file": "G:\\6.programacion\\from git\\Veterinaria\\vendor\\api-platform\\core\\src\\Serializer\\AbstractItemNormalizer.php",
"line": 204,
"args": [
["string", "patientDiseases"],
["object", "ApiPlatform\\Core\\Metadata\\Property\\PropertyMetadata"],
["object", "Symfony\\Component\\PropertyInfo\\Type"],
["string", "App\\Entity\\PatientDisease"],
["array", [
["array", {
"patient": ["array", []],
"date": ["string", "2018-11-27T13:03:00.000Z"],
"disease": ["string", "\/api\/diseases\/4"]
}]
]],
["string", "json"],
["array", {
"groups": ["array", [
["string", "patient"]
]],
"collection_operation_name": ["string", "post"],
"operation_type": ["string", "collection"],
"api_allow_update": ["boolean", false],
"resource_class": ["string", "App\\Entity\\Patient"],
"request_uri": ["string", "\/api\/patients"],
"uri": ["string", "http:\/\/localhost:8000\/api\/patients"],
"api_denormalize": ["boolean", true],
"cache_key": ["string", "e83f0aaf1c78a8d5386bc220724081e1"]
}]
]
}, {
"namespace": "ApiPlatform\\Core\\Serializer",
"short_class": "AbstractItemNormalizer",
"class": "ApiPlatform\\Core\\Serializer\\AbstractItemNormalizer",
"type": "-\u003E",
"function": "setAttributeValue",
"file": "G:\\6.programacion\\from git\\Veterinaria\\vendor\\symfony\\serializer\\Normalizer\\AbstractObjectNormalizer.php",
"line": 261,
"args": [
["object", "App\\Entity\\Patient"],
["string", "patientDiseases"],
["array", [
["array", {
"patient": ["array", []],
"date": ["string", "2018-11-27T13:03:00.000Z"],
"disease": ["string", "\/api\/diseases\/4"]
}]
]],
["string", "json"],
["array", {
"groups": ["array", [
["string", "patient"]
]],
"collection_operation_name": ["string", "post"],
"operation_type": ["string", "collection"],
"api_allow_update": ["boolean", false],
"resource_class": ["string", "App\\Entity\\Patient"],
"request_uri": ["string", "\/api\/patients"],
"uri": ["string", "http:\/\/localhost:8000\/api\/patients"],
"api_denormalize": ["boolean", true],
"cache_key": ["string", "e83f0aaf1c78a8d5386bc220724081e1"]
}]
]
}, {
"namespace": "Symfony\\Component\\Serializer\\Normalizer",
"short_class": "AbstractObjectNormalizer",
"class": "Symfony\\Component\\Serializer\\Normalizer\\AbstractObjectNormalizer",
"type": "-\u003E",
"function": "denormalize",
"file": "G:\\6.programacion\\from git\\Veterinaria\\vendor\\api-platform\\core\\src\\Serializer\\AbstractItemNormalizer.php",
"line": 132,
"args": [
["array", {
"name": ["string", "perro"],
"age": ["integer", 8],
"specie": ["string", "\/api\/species\/1"],
"breed": ["string", "\/api\/breeds\/1"],
"birthdate": ["string", "2018-11-07T13:03:00.000Z"],
"entrydate": ["string", "2018-11-23T13:03:03.182Z"],
"gender": ["string", "\/api\/genders\/1"],
"temperament": ["string", "\/api\/temperaments\/1"],
"chip": ["string", "asdasd2asd"],
"coatType": ["string", "\/api\/coat_types\/1"],
"coatColor": ["string", "\/api\/coat_colors\/1"],
"details": ["string", "m.cxvczxjkcxzvjklczv"],
"status": ["string", "\/api\/status_patients\/1"],
"client": ["array", {
"name": ["string", "Juan"],
"lastName": ["string", "Alberto"],
"secondSurname": ["string", "Asdasd"],
"email": ["string", "asdasd@asdasd.as"],
"phone1": ["string", "234234"],
"phone2": ["string", "24234"],
"clientType": ["string", "\/api\/client_types\/1"],
"sector": ["string", "\/api\/sectors\/1"],
"identificationCard": ["string", "98989898989"],
"address": ["string", "sdfsdfsdfs sdf sd5f sd"]
}],
"isActive": ["boolean", true],
"surgeries": ["array", [
["array", {
"name": ["string", "sdfa fsdf"],
"date": ["string", "2018-11-30T13:03:00.000Z"],
"patient": ["array", []]
}],
["array", {
"name": ["string", "sdfa fsdf"],
"date": ["string", "2018-11-30T13:03:00.000Z"],
"patient": ["array", []]
}],
["array", {
"name": ["string", "sdfa fsdf"],
"date": ["string", "2018-11-30T13:03:00.000Z"],
"patient": ["array", []]
}],
["array", {
"name": ["string", "sdfa fsdf"],
"date": ["string", "2018-11-30T13:03:00.000Z"],
"patient": ["array", []]
}]
]],
"patientDiseases": ["array", [
["array", {
"patient": ["array", []],
"date": ["string", "2018-11-27T13:03:00.000Z"],
"disease": ["string", "\/api\/diseases\/4"]
}]
]]
}],
["string", "App\\Entity\\Patient"],
["string", "json"],
Как вы можете видеть, IRI присутствует в запросе в каждом объекте массива, но API-платформа все еще вызывает ошибку Invalid IRI.
Объекты настроены с опцией сохранения каскада
Есть ли у вас какие-либо советы о том, как мне разрешить эту ситуацию?
Заранее спасибо