Sha256: 64dce7fa21683bc78133169d3ff444cd989830f46282c64dad4bf2e2ee8075ca

Contents?: true

Size: 1.01 KB

Versions: 4

Compression:

Stored size: 1.01 KB

Contents

# frozen_string_literal: true

module ApiResources
  class Authors
    include Praxis::EndpointDefinition

    media_type Author
    version '1.0'

    action :index do
      routing { get '' }
      params do
        attribute :fields, Praxis::Types::FieldSelector.for(Author), description: 'Fields with which to render the result.'
        attribute :filters, Praxis::Types::FilteringParams.for(Author) do
          filter 'books.name', using: %w[= != !], fuzzy: true
          filter 'id', using: %w[= !=]
        end
        attribute :order, Praxis::Extensions::Pagination::OrderingParams.for(Author) do
          by_fields :id, :name, 'books.name'
        end
      end
      response :ok, media_type: Praxis::Collection.of(Author)
    end

    action :show do
      routing { get '/:id' }

      params do
        attribute :id, description: 'ID to find'
        attribute :fields, Praxis::Types::FieldSelector.for(Author), description: 'Fields with which to render the result.'
      end
      response :ok
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
praxis-2.0.pre.33 spec/spec_app/design/resources/authors.rb
praxis-2.0.pre.32 spec/spec_app/design/resources/authors.rb
praxis-2.0.pre.31 spec/spec_app/design/resources/authors.rb
praxis-2.0.pre.30 spec/spec_app/design/resources/authors.rb