Sha256: b465551feffd19947db4e1506436b520611ee17ebac56044b6bff546ebe02ebf

Contents?: true

Size: 914 Bytes

Versions: 1

Compression:

Stored size: 914 Bytes

Contents

# frozen_string_literal: true

require 'spec_helper'

describe '#427 nested entity given as string' do
  let(:app) do
    Class.new(Grape::API) do
      namespace :issue_427 do
        module Permission
          class WithoutRole < Grape::Entity
            expose :id
            expose :description
          end
        end

        class RoleEntity < Grape::Entity
          expose :id
          expose :description
          expose :role
          expose :permissions, using: 'Permission::WithoutRole'
        end
        desc 'Get a list of roles',
             success: RoleEntity
        get '/' do
          present [], with: RoleEntity
        end
      end

      add_swagger_documentation format: :json
    end
  end

  subject do
    get '/swagger_doc'
    JSON.parse(last_response.body)['definitions']
  end

  specify { expect(subject.keys).to include 'RoleEntity', 'Permission::WithoutRole' }
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
grape-swagger-1.1.0 spec/issues/427_entity_as_string_spec.rb