If you already support this then sorry for this...
I am using apipie version 0.5.1.
I want to be able to support example URL generation in my docs, something like this:
api :GET, "#{$API_PIE_ROUTES[:roles_get_ssoi_roles_path]}.json", 'Request all roles for a VA Single Sign on User user as JSON.'
api :GET, "#{$API_PIE_ROUTES[:roles_get_ssoi_roles_path]}", 'Request all roles for a VA Single Sign on User user as HTML.'
description %Q{
Returns all the roles for a user
sample invocation JSON: #{$API_PIE_ROUTES[:roles_get_ssoi_roles_url]}.json?#{CGI.escape({id: :cboden}.to_query)}
sample invocation HTML: #{$API_PIE_ROUTES[:roles_get_ssoi_roles_url]}?#{CGI.escape({id: :cboden}.to_query)}
}
def get_ssoi_roles
#impl
end
In order to implement this for our project to the controllers directory I added your apipie/apipis_controller.rb to our project and made the following changes:
module Apipie
class ApipiesController < ApplicationController #inherit from our app to have the routes
include ActionView::Context
include ApipieHelper
layout Apipie.configuration.layout
skip_after_action :verify_authorized #trun off our pundit security
prepend_before_action :set_urls #feed us the routes
around_action :set_script_name
before_action :authenticate
def set_urls
if $API_PIE_ROUTES.nil? #We will assume no dynamic routes
$API_PIE_ROUTES = {}
Rails.application.routes.named_routes.helpers.to_a.each do |url_or_path|
$API_PIE_ROUTES[url_or_path] = self.send(url_or_path).to_s rescue nil
end
end
end
If you already support this then sorry for this...
I am using apipie version 0.5.1.
I want to be able to support example URL generation in my docs, something like this:
In order to implement this for our project to the controllers directory I added your apipie/apipis_controller.rb to our project and made the following changes:
But you guys can probably do it better.
Thanks,
Cris