Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

What is the source of knowledge for the client about fields, where they can read link to the entity?

For human it's obvious that dog has an owner, so field "owner" should be used, but for code - you need to write it, "document it". So if you're going to "document" every field containing link to external resource, you'll end up with even more code, than just "documenting" API endpoints.

Also, pretty often you need multiple IDs of entities to send POST/PUT request - just to create a relation.

POST /adoption, owner_id=5, dog_id=7.

How should it look with links? Will it be issue for the server to parse them? And it's just simple case with 1 to 1 relation, sometimes you need to add sets of objects to another entity.

It's a really bad advice and after reading this I'm not sure I should trust other articles from that source.



> Also, pretty often you need multiple IDs of entities to send POST/PUT request - just to create a relation.

> How should it look with links?

Like this:

POST /adoption, owner=/people/5, dog=/pets/7

> Will it be issue for the server to parse them?

Why would it be?


Because it's more difficult than parse "5" and "7", especially when you need to parse not only numeral IDs. "More difficult" always means "more bugs" and "more vulnerabilities".

There is no single reason for this complication. The ONLY motivation author had - less knowledge about API endpoints on the client. But simultaneously it means more knowledge about the fields where links are stored, so it doesn't save nothing.


I believe "so it doesn't save nothing." should be written as "so it doesn't save anything." [0]

Feel free to ignore me.

[0] https://www.quora.com/Is-the-sentence-dont-do-nothing-correc...


thanks :)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: