module OpenStax::Api::Apipie::ClassMethods
Public Instance Methods
api_example(options={})
click to toggle source
# File lib/openstax/api/apipie.rb, line 17 def api_example(options={}) return if Rails.env.test? raise IllegalArgument, "must supply a :url parameter" if !options[:url_base] url_base = options[:url_base].is_a?(Symbol) ? UrlGenerator.new.send(options[:url_base], protocol: 'https') : options[:url_base].to_s "#{url_base}/#{options[:url_end] || ''}" end
json_schema(representer, options={})
click to toggle source
# File lib/openstax/api/apipie.rb, line 28 def json_schema(representer, options={}) RepresentableSchemaPrinter.json(representer, options) end
representer(representer)
click to toggle source
A hack at a conversion from a Representer to a series of Apipie
declarations Can call it like any Apipie
DSL method,
example "blah" representer Api::V1::ExerciseRepresenter def update ...
# File lib/openstax/api/apipie.rb, line 39 def representer(representer) representer.representable_attrs.each do |attr| schema_info = attr.options[:schema_info] || {} param attr.name, (attr.options[:type] || Object), required: schema_info[:required] end end