Hacker News new | ask | show | jobs
by aslom 3710 days ago
I agree with the argument: developers like reading web pages that describe how to use API, covering rationale of API design, gotchas, code samples.

However, what if the specs were able to capture what is in such human-readable pages (for example https://docs.cloudant.com/)? What if API spec could be automatically derived out of HTML pages? Embed some metadata in HTML page and then we have both cake (human-readable) and eat it (machine-readable)?

3 comments

That sounds very much like [API Blueprints](https://apiblueprint.org/), which [Apiary](https://apiary.io/) back. I tried to get the organisation I work for to standardise on them (being able to run tests from a versioned API specification seemed like a fantastic way to hit two birds with one stone), but sadly, couldn't convince enough people.
It also sounds like Swagger + OpenAPIs: https://openapis.org
What were the reasons people brought up against doing this?
Mostly inertia. We're a large-ish company; I work in a remote office away from the majority of dev, and technical direction needs marketing.

We ended up using Swagger, which doesn't solve as many of our problems (having documentation generated from code isn't as robust from a testing POV, particularly when your RESTful API is versioned), but my "perfect" is the enemy of the company's "good" :).

I actually have two related projects here:

Scrape HTML to swagger: https://github.com/bobby-brennan/scrape-to-swagger

Swagger to HTML docs: https://github.com/lucybot/lucy-console

We also have a commercial version of the latter which you can see at any-api.com

Cool projects, thanks for pointing them out! So, the scrape-html-to Swagger one would basically allow you to keep Swagger up to date as you change the human-readable API documentation? In that case, someone still has to make sure the API documentation is in sync with the source code, right?
GraphQL accomplishes this pretty well. Graphiql is a brilliant example of human and machine readable API documentation.