Module: OpenStax::Api::Apipie::ClassMethods
- Defined in:
- lib/openstax/api/apipie.rb
Instance Method Summary collapse
- #api_example(options = {}) ⇒ Object
- #json_schema(representer, options = {}) ⇒ Object
-
#representer(representer) ⇒ Object
A hack at a conversion from a Representer to a series of Apipie declarations Can call it like any Apipie DSL method, .
Instance Method Details
#api_example(options = {}) ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/openstax/api/apipie.rb', line 17 def api_example(={}) return if Rails.env.test? raise IllegalArgument, "must supply a :url parameter" if ![:url_base] url_base = [:url_base].is_a?(Symbol) ? UrlGenerator.new.send([:url_base], protocol: 'https') : [:url_base].to_s "#{url_base}/#{[:url_end] || ''}" end |
#json_schema(representer, options = {}) ⇒ Object
28 29 30 |
# File 'lib/openstax/api/apipie.rb', line 28 def json_schema(representer, ={}) RepresentableSchemaPrinter.json(representer, ) end |
#representer(representer) ⇒ Object
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 ...
39 40 41 42 43 44 |
# File 'lib/openstax/api/apipie.rb', line 39 def representer(representer) representer.representable_attrs.each do |attr| schema_info = attr.[:schema_info] || {} param attr.name, (attr.[:type] || Object), required: schema_info[:required] end end |