0.0
No commit activity in last 3 years
No release in over 3 years
Small lib and script to check API description in special format against test server
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.5
>= 0
>= 0

Runtime

 Project Readme

LieDetector

I created this gem to keep API description and actual API in sync. You write markdown document with data structures and request descriptions, and then you can check it against real server to check that description is really describe this server API.

All requests executed one by one, and if any of them fail we stop checking.

So, take a look at some example - current document describe a bit of GitHub API.

GitHub API Check

As you know github has public API. API you can call without authentification. Set API host:

self.http_defaults = {host: 'api.github.com', scheme: 'https', port: 443}

With Trafaret library we can define data types to check API results:

Repo = T.construct({
  id: :integer,
  name: :string,
  full_name: :string,
  # ... hundred of other fields, tired to define them
  owner: {url: :uri}
})

So now we can get info about liedetector repo, store it, and then use it for next queries:

request :repo_info, :get, '/repos/Deepwalker/liedetector' do
  status 200
  await Repo
  store :repo # we store API call result for later
end

Now we have repo info, and URI for it owner. Lets check this URI:

request :repo_owner, :get, proc { URI.parse(store[:repo][:owner][:url]).path } do
  status 200
  await :any
end

You can put proc {} in place of method, path, status, data, query and headers request args. As you see request get name, method and path, and then with block you fill other parameters.