Live data from Hacker News

RAML – RESTful API modeling language

raml.org

51–59 of 59 posts

Re: RAML – RESTful API modeling language

#51

Earlier quoted context omitted.

How does this miss the point of REST?

> How does this miss the point of REST? Because if it didn't, the full API description language would be: api-root: Or, for a pedantically detailed version: api-root: media-types: - -

Sure, for consuming the API - but does RAML have to be used this way? Couldn't RAML be used to generate test expectations or even (with tooling that probably doesn't exist) actually generate the API itself?

Re: RAML – RESTful API modeling language

#52

Earlier quoted context omitted.

> How does this miss the point of REST? Because if it didn't, the full API description language would be: api-root: Or, for a pedantically detailed version: api-root: media-types: - -

Are there any extant REST API's for which one could programmatically generate a client library based purely upon the root URL and media types?

> Are there any extant REST API's for which one could programmatically generate a client library based purely upon the root URL and media types?

For a truly RESTful API, the question you ask is somewhat incoherent. A client for a RESTful API consists of two key sets of components: functionality for sending and receiving resource representations to and from locations identified by URIs, and functionality for handling resource representations of particular media types. Assuming you have those, you don't need to "programmatically generate a client library" with the particular base URL of a particular API root, you access a URL that provides resources of any of the supported media types and your off to the races without programmatically generating anything.

Is this possible in practice for real implementations of RESTful principles? Yes, including the one that motivated the articulation of the REST principles, the WWW.

Is REST appropriate for all APIs? Maybe, maybe not. But its probably not useful to anyone to just call every web service that uses HTTP and isn't SOAP "RESTful".

Re: RAML – RESTful API modeling language

#53

Earlier quoted context omitted.

It describes how to construct URLs to get from one state to another (e.g. from a base URL to a list of songs, or from the list to an individual song). REST URLs are supposed to be opaque. A RESTful resource should provide links to its related resources for the user agent to navigate. There's nothing wrong with what the author is trying to do, but it's nothing to do with REST.

Oops. That's one detail I missed in all those API tutorials. Thanks.

The canonical source is Roy Fielding's thesis, in particular chapters 5 and 6.

https://www.ics.uci.edu/~fielding/pubs/dissertation/top.htm

Re: RAML – RESTful API modeling language

#54

Earlier quoted context omitted.

How does this miss the point of REST?

> How does this miss the point of REST? Because if it didn't, the full API description language would be: api-root: Or, for a pedantically detailed version: api-root: media-types: - -

Devil's advocate: "api-root: http://example.org/foo.raml" fits that bill.

Re: RAML – RESTful API modeling language

#56

The APIs modeled by this language are not RESTful: in fact, the use of this type of WSDL-like description is the antithesis of the hypertext-centric core concept of REST. Calling this a "RESTful API modeling language" is like calling a water cannon a flamethrower. If we're going to call this RESTful, we might as well call SOAP RESTful.

Indeed. REST has come to mean almost the antithesis of what it was created to mean. Roy Fielding wrote about this topic, clarifying common misconceptions and what REST APIs are not:

http://roy.gbiv.com/untangled/2008/rest-apis-must-be-hyperte...

> A REST API should be entered with no prior knowledge beyond the initial URI (bookmark) and set of standardized media types that are appropriate for the intended audience (i.e., expected to be understood by any client that might use the API). From that point on, all application state transitions must be driven by client selection of server-provided choices that are present in the received representations or implied by the user’s manipulation of those representations. The transitions may be determined (or limited by) the client’s knowledge of media types and resource communication mechanisms, both of which may be improved on-the-fly (e.g., code-on-demand). [Failure here implies that out-of-band information is driving interaction instead of hypertext.]

The need for a document like this in the first place demonstrates that the API is not REST. These systems are simply ad hoc, partially specified RPC systems operating over HTTP.

I've almost given up caring about what REST means due to endless debates and misunderstandings about this. REST just means any HTTP-based API where operations and inputs/outputs are modeled with HTTP fields these days.

Re: RAML – RESTful API modeling language

#57
post #4

Very cool, it feels like WSDL for REST EDIT: spelling

True REST shouldn't require a WSDL-like interface. The semantics of the graph it describes should be enough. This model, however, has yet to be fully realised; largely because of the large upfront cost in R&D. At my work, we are trying to develop in this area, but it's slow going.

We're playing around with related ideas here [0]. It's understandably slow-going, because it's a hard problem to make a system 1) respond correctly to highly-specified custom queries, 2) easy to use and 3) scalable/performant.

[0] https://github.com/Mec-iS/mild-QL/issues/3

Re: RAML – RESTful API modeling language

#58

It might be nice if this was described in an existing data format (YAML, anyone) as a particular form of structure, rather than inventing a new data format.

What do you think about API Blueprint [1]? It is based on Markdown. [1]: https://apiblueprint.org

I think Markdown is generally unsuitable as a data format for machines.

YAML strikes a nice balance between machines and people, but I wouldn't want to write a blog post in it.

Markdown is great for blog posts, but APIs are terse.

Re: RAML – RESTful API modeling language

#59
post #43

It might be nice if this was described in an existing data format (YAML, anyone) as a particular form of structure, rather than inventing a new data format.

RAML is essentially a YAML with a specific schema. Tell your IDE to treat .raml files as .yaml and all the syntax highlighting, etc will work perfect

Ah, that makes a lot more sense then.

It appeared to have weirdness from the homepage:

  - secured: !include http://remote-host/secured.yml
/songs:

Which is invalid YAML.

It turns out this is probably an unfortunate word-wrap in the page, where a non-wrapping text field would better convey the format.

Post reply on HN