Praxis v0.19.0 Release Notes
Release Date: 2015-12-21 // over 8 years ago-
- ๐ Handle loading empty
MediaTypeIdentifier
values (to returnnil
) - ๐ป Doc browser now displays examples for action responses.
- Added
Controller#media_type
helper that returns themedia_type
defined for the current response, or defaults to the one defined by the controller's resource definition. - โ Added assorted extensions, all under the
Praxis::Extensions
module:FieldSelection
adds a new type,Praxis::Extensions::FieldSelection::FieldSelector
that wraps theAttributor::FieldSelector
type and improves the definition of parameters for a set of fields. Must be required explicitly from 'praxis/extensions/field_selection'.- The parsed set of fields will be available as the
fields
accessor of the loaded value. - For example, to define a parameter that should take a set of fields
for a
Person
media type, you would define a:fields
attribute in the params like:attribute :fields, FieldSelector.for(Person)
. The parsed fields in the request would then be available withrequest.params.fields.fields
. Rendering
addsrender
anddisplay
helper methods to controllers to reduce common boilerplate in producing rendered representations of media types and setting response "Content-Type" headers.Controller#render(object, include_nil: false)
loadsobject
into the the current applicableMediaType
(as fromController#media_type
) and renders it using the fields provided byController#expanded_fields
(from theFieldExpansion
extension).Controller#display(object, include_nil: false)
callsrender
(above) withobject
, assigns the result to the currentresponse.body
, sets the response's "Content-Type" header to the appropriate MediaType identifier, and returns the response.- To use this extension, include it in a controller with
include Praxis::Extensions::Rendering
. MapperSelectors
addsController#set_selectors
, which sets selectors in the controller'sidentity_map
to ensure any fields and associations necessary to render the:view
and/or:fields
params specified in the request are loaded for a given model whenidentity_map.load(model)
is called.- To use this extension, include it in a controller with
include Praxis::Extensions::MapperSelectors
, and definebefore
callbacks on relevant actions that callset_selectors
. For example:before actions: [:index, :show] { |controller| controller.set_selectors }
FieldExpansion
provides aController#expanded_fields
helper for processing:view
and/or:fields
params to determine the final set fields necessary to handle the request.- Note: This is primarily an internal extension used by the
MapperSelectors
andRendering
extensions, and is automatically included by them.
- ๐ป A slew of Doc browser improvements:
- Now uses the new JSON format for responses.
- Traits now get exposed in the doc browser.
- Now displays examples for requesting actions.
- Now correctly displays top-level collections in action payloads.
- Has improved scrolling for the sidebar.
- Displays more detailed HTML titles.
- Has been switched back to having a separate page per action, however actions are now shown in the sidebar.
- Will now display multiply nested resources in a proper hierarchy.
- ๐ Fix doc generator to only output versions in index for which we have resources (i.e. some can be nodoc!)
- ๐ Handle loading empty