We are using rspec_api_documentation
and managed to generate the documentation for the 2 versions we have so far with the following code:
RspecApiDocumentation.configure do |config|
config.docs_dir = Rails.root.join('doc', 'api', 'all')
config.define_group :v1 do |config|
config.filter = :v1
config.docs_dir = Rails.root.join('doc', 'api', 'v1')
config.api_name = 'API V1'
end
config.define_group :v2 do |config|
config.filter = :v2
config.docs_dir = Rails.root.join('doc', 'api', 'v2')
config.api_name = 'API V2'
end
end
We are using apitome
to render these docs, however, we haven't been able to find a way to mount the routes for the 2 versions of the API 2 so far.
Any ideas?
Answering my own question in case it helps others.
Define your api versions as constants
Define document groups for each version and output json files on separate folders
Use the document groups when coding your specs
Comment out
doc_path
andmount_at
fromconfig/initializers/apitome.rb
Define a route constraint which sets them
Mount your routes using that constraint, you can optionally set a default version
Regenerate your documentation
Restart your server