Earlier quoted context omitted.
anything I could read to imitate that workflow ?
I haven't written anything up - maybe one day - but our stack is `ts-morph` to get some basic metadata out of our "service definition" typescript files, `ts-json-schema-generator` to go from there to JSON Schema, `quicktype-core` to go to other languages. Schema validation and type generation vary by language. When we need to validate schemas in JS/TS land, we're using `ajv`. Our generation step exports the JSON Sche…
Most RESTful APIs aren't really RESTful
511–520 of 580 posts
Re: Most RESTful APIs aren't really RESTful
#512Django Rest Framework seems to do this by default. There seems very little reason not to include links over hardcoding URLs in clients. Imagine just being able to restructure your backend and clients just follow along. No complicated migrations etc. I suspect many people just live with crappy backends because it's too difficult to coordinate the rollout of a v2 API.
However, this doesn't cover everything. There's still a ton of "out of band" information shared between client and server. Maybe there's a way to embed Swagger-style docs directly into an API and truly decouple server and client, bit it would seem to take a lot more than just using links over IDs.
Still I think there's nothing to lose by using links over IDs. Just do it on your next API (or use something like DRF that does it for you).
Re: Most RESTful APIs aren't really RESTful
#513Earlier quoted context omitted.
Most web apps today use APIs that return JSON and are called by JavaScript. Can you use REST for such services or does REST require a switch to HTML representation rendered by the server where each interaction returns new HTML page? How such HTML representation can even use PUT and DELETE verbs, as these are available only to JavaScript code? What If I design a system where API calls can be made both from the web and…
> Most web apps today use APIs that return JSON and are called by JavaScript. Can you use REST for such services You kind of could, but it's a bad idea. A core tenet of the REST architecture is that it supports a network of independent servers that provide different services (i.e. webpages) and users can connect to any of them with a generic client (i.e. a web browser). If your mission is to build a specialized API f…
Re: Most RESTful APIs aren't really RESTful
#514Earlier quoted context omitted.
> Care to list them? From the top of my head, OData. https://www.odata.org/
This is a recent project. REST happened basically in the environment where your choices were CORBA, DCOM, SOAP and other such monstrosities. Of course, REST won handily. We're not in this environment anymore, thankfully, and REST now is getting some well-deserved scrutiny.
OData officially started out in 2007. Roy Fielding's thesis was published in 2000.
Re: Most RESTful APIs aren't really RESTful
#515Earlier quoted context omitted.
> but the HATEOAS detail ends up having no practical value and creates more problems than the ones it solves. Only because we never had the tools and resources that, say, GraphQL has. And now everyone keeps re-inventing half of HTTP anyway. See this diagram https://raw.githubusercontent.com/for-GET/http-decision-diag... (docs https://github.com/for-GET/http-decision-diagram/tree/master... ) and this: https://github.c…
> Only because we never had the tools and resources that, say, GraphQL has. GraphQL promised to solve real-world problems. What real world problems does HATEOAS addresses? None.
HATEOAS didn't need to "promise" anything since it was just describing already existing protocols and capabilities that you can see in the links I posted.
And that's how you got POST-only GraphQL which for years has been busily reinventing half of HTTP
Re: Most RESTful APIs aren't really RESTful
#516Earlier quoted context omitted.
Sometimes you need your timestamps to be in a named timezone. If I have a meeting at 9am local time next month, I probably want it to still be at 9am even if the government suddenly decided to cancel daylight time.
unless the customer you're meeting is in another timezone where the government didn't cancel daylight time
Re: Most RESTful APIs aren't really RESTful
#517Earlier quoted context omitted.
Always thought that a standard like ISO8601 which always stores the date and time in UTC but appends the local time zone would beneficial.
I don't think I ever needed something like that... Since most cases don't need local time zone, why not keep two separate fields?
"2025-07-10T09:48:27+01:00"
That contains, by my quick glance, at least 8 fields of information. I would argue the one field it does not carry but probably should is the _name_ of the timezone it is for.Re: Most RESTful APIs aren't really RESTful
#518Earlier quoted context omitted.
That API doesn’t look like REST level 3 API. For example, there’s an endpoint to create a node. It is not referenced by root or anywhere else. GetNode endpoint does include some traversal links in response, but those links are part of domain model, not part of the protocol. HAL does offer a protocol by which you enhance your domain model with links with semantics and additional resources.
these levels? https://blog.restcase.com/4-maturity-levels-of-rest-api-desi...
Re: Most RESTful APIs aren't really RESTful
#519Earlier quoted context omitted.
JSON doesn’t really have data types beyond very simple ones
> JSON doesn’t really have data types beyond very simple ones What do you think primitive types are supposed to be?
type JSON =
string |
number |
boolean |
null |
JSON[] |
{[name: string]: JSON}Re: Most RESTful APIs aren't really RESTful
#520Earlier quoted context omitted.
You have got it wrong. Let's say I build some API with different user roles. Some users can delete an object, others can only read it. The UI knows about the semantics of the operations and logical names of it, so when UI gets the object from server it can simply check, if certain operations are available, instead of encoding the permission checking on the client side. This is the discoverability. It does not imply g…
> You have got it wrong. Let's say I build some API with different user roles. Some users can delete an object, others can only read it. The UI knows about the semantics of the operations and logical names of it, so when UI gets the object from server it can simply check, if certain operations are available, instead of encoding the permission checking on the client side. Have you ever heard of HTTP's OPTIONS verb? ht…
Yes, I'm aware of this header and know the web standards well enough.
In hypermedia API you communicate to client the list of all operations in the context of the resource (note: not ON the resource), which includes not only basic CRUD but also operations on adjacent resources (e.g. on user account you may have an operation of sending a message to this user). Yes, in theory one could use OPTIONS with a non-standard response body to communicate such operations that cannot be expressed in plain HTTP verbs in Allow header.
However such solution is not practical, because it requires an extra round trip for every resource. There's a better alternative, which is to provide the list of operations with the resource using one of the common standards - HAL, JSON-LD, Siren etc. The example in my another comment in this thread is based on HAL. If you wonder what is that, look no further than at Spring - it does support HAL APIs out of the box from quite a long time. And of course there's an RFC draft and a Wikipedia article (https://en.wikipedia.org/wiki/Hypertext_Application_Language).