Skip to content

Instantly share code, notes, and snippets.

@roolo
Created November 5, 2013 14:58
Show Gist options
  • Select an option

  • Save roolo/7320300 to your computer and use it in GitHub Desktop.

Select an option

Save roolo/7320300 to your computer and use it in GitHub Desktop.
Sinatra basic documentation for API. This code as it is generates code for Markdown
after do
TEST_DOCUMENTATION_FILE << "\n## %s %s"%[request.request_method,request.path_info]
TEST_DOCUMENTATION_FILE << "\n### Request"
TEST_DOCUMENTATION_FILE << "\n "+JSON.pretty_generate(
JSON.parse(request.POST.to_json)
).gsub(/\n/, "\n ")
TEST_DOCUMENTATION_FILE << "\n### Response"
response_formatted = JSON.pretty_generate(
JSON.parse(response.body.first)
).gsub(/\n/, "\n ")
TEST_DOCUMENTATION_FILE << "\n "+response_formatted
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment