I use Swagger  and more specifically Swagger UI  to generate interactive web-based documentation like the sample at .
But rather than relying upon source code annotations to have swagger auto-generate the documentation, or hand-writing swagger's verbose JSON structure, I created a little DSL for it as demonstrated at  and available on GitHub at .
Let me know if you have any questions about swagger-dsl. It's under-documented right now but perfectly functional. I use it often.
Initially we considered Apiary, but we wanted more flexibility and preferred to host things ourselves. And the fact that our documentation is generated automatically from the code via grape-swagger is a game changer.
My team makes uses generated Swagger API docs (via the swagger-play2 plugin), but to be honest the tooling around it is pretty half-assed. Having a machine-readable spec is a game changer, though.
I looked at swagger-codegen before createing swagger-dsl, and frankly it is pretty nice, but with respect to authoring the underlying Swagger specification document, swagger-codegen is just a direct YAML translation of the original Swagger JSON format.
In other words, swagger-codegen's YAML support is just a YAML-to-JSON transformation. It has the same redundancies and structural issues as Swagger's JSON, just in a YAML syntax.
My objective with swagger-dsl was to create a more human-oriented (more readable, less verbose, less error prone, more DRY, etc.) format for authoring those JSON documents for Swagger. It's not just JSON-as-YAML, it's a more author-oriented (as opposed to parser-oriented) way to describe the API.
JSON Schema and JSON Hyperschema are JSON-based formats for describing JSON and REST (hypermedia-driven) APIs. The formats make decent sense and can be used to generate docs, validators, client libraries, UIs, and more. http://json-schema.org/
API Blueprint is another emerging format for API description. It's written in Markdown, so it is very human-readable and -writable. It is not yet suitable for hypermedia APIs. Like JSON Schema, its tooling includes validators, client library generators, mock server generators, docs generators, etc. http://apiblueprint.org/
Swagger is a YAML-based format for specifying JSON APIs. It is meant to be created using the Swagger UI, rather than handwritten. It generates pretty docs, client software, etc. but is not suited to describing hypermedia APIs. http://swagger.io
Slate is an API documentation framework/template, designed to generate very handsome documentation pages. Its concern is more documentation than specification, and therefore doesn't concern itself with things like library or mock generation. https://github.com/tripit/slate
WADL is an API description language which describes API interactions in an XML format. It resembles WSDL. Not many people use it. http://en.wikipedia.org/wiki/Web_Application_Description_Lan...
Which of these is the best? Good question. I like JSON Hyperschema, but I am writing hypermedia APIs and the other formats here are lacking in their hypermedia support. API Blueprint is a nice format to write in a text editor and is easily read as-is or rendered from Markdown; no separate docs generator is necessary.
My recent choice, w3c track, sensible use case driven progression, growing adoption, flexible embedded or referenced meta-data as appropriate.
I've personally found great joy in being adaptive with the meta data in the responses, like presence of operations and accepted input on the operations depending upon data state and security context, something not really offered with json-schema.
Why is that? It wouldn't force/guide you to create a hypermedia APIs by default, but it could be used to document one couldn't it?
But here are few things I've learned:
* The more comprehensive the documentation gets, the the quicker it gets outdated, un-useful, or flat out pants-on-fire lying. Define what the thing does and what assumptions are made, save detail for "gotchas". Be concise.
* Start out on a white board, run through each function, what it should do, what it shouldn't. This really is a huge benefit of spec'ing out a api, just sitting there thinking about it, tons of stuff comes up and you come out with a better product in the end.
* If the format you came up with can't be put into something like a table or spreadsheet, you probably doing it wrong. Sure you can get some sort of framework that lets you create all sorts of UML and create class/function shells or what have you, but I have never found these to create value or clarity. If you are spending more than 20-30 minutes outlining even a complicated function, your probably wasting time. Use time saved to create a clear system-wide DFD.
* Don't go deep into implementation detail at this stage, but at least think about it. Some much time can be saved with a little forethought here.
The documentation they provide based on the specs looks very well designed and intuitive.
One of my favorite features about apiary was the mock backend server they use based on my API specs. So if you're doing a single page app, just write your specs then point your frontend app to the mock server they provide. This greatly simplified development process for me.
5 months in, we're happy with API Blueprint. We used to use Dredd for API validation but ran into to some limitations:
- Dredd does not perform any validation against the siren response beyond the first key level. For example, it does not validate if the class-name is user-events, or usr-events
- Dredd does not make any difference between Action parameters and Resource parameters. Then, an action POST to create user-events will have undesired url parameters. E.G: POST /user-events?take=0&skip=2 (The apib blueprint specs allows to make this difference: https://github.com/apiaryio/api-blueprint/blob/master/exampl...)
So one of our devs created a Ruby validator, https://github.com/nogates/vigia. See http://engineering.lonelyplanet.com/2014/11/18/vigia-integra... if you're interested.
This I can't confirm, presence of object keys is validated on any level.
- Dredd does not make any difference between Action parameters and Resource parameters. Then, an action POST to create user-events will have undesired url parameters. E.G: POST /user-events?take=0&skip=2
This is true, but it’s by design. In Dredd URI parameters are inherited from resource to action, but there is no way how to filter out unwanted parameters from resource under action section.
In this case I assume that `skip` and `take` parameters belong only to GET action (retrieving collection), so its imho a non-sense to discuss them on the resource level because they will be propagated to any action under that resource.
Thank you for very interesting feedback!
API Blueprint  is an open source API description format which can be used to intuitively describe an API.
MSON  is a recent addition to the above format which makes it easy to describe all kinds of complex requests and responses in the spec.
You can email me at pavan [at] apiary [dot] io if you have any more questions.
You don't need any special tools to do that although apiary comes to mind as something worthwhile.
ReadMe.io currently focuses more on the "front end" of the API. We can ingest in-line comments made with the apiDoc.js  standard, and then use that description to build an API explorer and reference docs automatically. We like apiDoc because of how concise the comments are, and because they are kept very close to the code (no extra files to maintain). It's not as common as some of the other standards mentioned here, but it's — by far — the fastest and most straightforward way to describe an API.
Edit: this is how it's implemented within ReadMe.io: http://readme-sync.readme.io/v1.0/docs
However, it's been months now, and the GitHub Sync section still says "temporarily disabled".
Is this feature really done? When can I use it?
I'm a bootstrapper and understand testing features by pretending they exist, but it's been a pretty long time...
2) Swagger is an older option that is quite verbose but has a lot of good tooling support.
3) A third tool that is pretty decent is API blueprint.
Disclosure: I did work on an open source swagger-raml converter about four months ago.
I tried RAML -- it makes sense for quick prototyping of your resources and methods, but I oculdn't see myself writing too much documentation as a giant nested YAML document.
I also tried apidoc which might make sense of you have internal documentation you wan to quickly expose. However my docs are longer than the code implementing them, so I don't like mixing them in as e.g. apidoc would require. I'd prefer lots of English in my documentation and it seems odd to conflate hints on how to use an API call as an external user with the implementation of it. Compare Sphinx-generated Python docs with some auto-generated python library documentation.
The apidoc versioning system is pretty cool, though if you are making a public REST API backwards-incompatible version changes should be avoided.
Once the format is nailed down it's easier to write documentation, and the server side code will go quickly because less time is spent iterating changes.
1. readme.io is just painful to use for larger documentations; very GUI-oriented
2. apiary is basically just annoying in every way (I really like the company so I tried 3 separate times to get myself to like their product)
3. I dismissed a couple of self-hosted options that use JS to render the information, since I find that idiotic
Slate struck a good balance between (1) syntax (2) ease of use and (3) good looks, although I wouldn't call it prefect in any of those departments.
Disclaimer: the end result looks surprisingly better than what you'd expect.
1. specify the api in json
2. apidoc generates really nice api documentation
3. apidoc generates a single-file client for the service (currently ruby or scala)
4. apidoc generates a routes file for play2
It's scala-biased at the moment because that's their tech stack, but in practice an api-first approach seems to lead to higher quality APIs compared to just hacking something together and annotating it to extract docs. Also having a really nice client without a complicated compile-time dependency graph (on the JVM) feels like a sweet spot.
There also exist an opens source project that has Swagger at its core called a127 (https://github.com/apigee-127/a127-documentation/wiki) that allows you to build enterprise-class APIs in Node.js locally and deploy to any PaaS where you can run a node app.
Disclaimer: I work with a127 project.
Ignoring the benefits of using HTTP as the request transport mechanism, this seems like another cycle of people coming up with a comprehensive but complex solution, other people getting frustrated with the complexity and developing a simpler solution, then filling in the gaps (such as documentation) until the solution is a complex patchwork of competing libraries, none clearly better than the others, leading to fragmenting of mindshare and expertise...
It uses Swagger and swagger ui extensively and can output (and soon input) Swagger specs. It creates a virtual API based on the design you create, and you can play with it from Swagger ui sandbox or any Http client.
We have a lot of cool features on the roadmap. Feel free to sign up and give it a try. Let us know what features you'd like to see. Cheers!
Does anyone know of any API specs written for websocket APIs?
I am working on creating a websocket API and would like to at least look at a few other examples.
And been working on a tool to merge the schema with actual code for Sinatra apps:
I was discussing my interest in documenting an API and then generating client libraries, API tests, and other artifacts automatically. Some relevant tools and projects were mentioned/discussed.
You define the API in comments within your code. When you run apidoc it scans your code and generates pretty documentation.
I tried various other solutions before this such as apiary.io. Apidocjs is really easy to update as it is part of your code, which also means it goes into your version control!
It is entirely free and available as a simple web app and installable as a Chrome app. Disclaimer: I work at Restlet.
Aside from that whatever tool you use, having markdown as the base source is really useful as you can then display it however you want while still quickly read it in a terminal.
I'm developing SpyREST and will be happy to discuss if you want to learn more.