メイン アプリからサブクラス化する必要はありません。メイン アプリ内に個別の Grape::API サブクラスをマウントするだけです。もちろん、これらのクラスを個別のファイルで定義し、requireアプリに必要なすべてのルート、エンティティ、およびヘルパーをロードするために使用できます。「ドメイン オブジェクト」ごとに 1 つのミニアプリを作成しapp.rb、それらを にロードすると便利であることがわかりました。次のようになります。
  # I put the big list of requires in another file . . 
  require 'base_requires'
  class MyApp < Grape::API
    prefix      'api'
    version     'v2'
    format      :json
    # Helpers are modules which can have their own files of course
    helpers APIAuthorisation
    # Each of these routes deals with a particular sort of API object
    group( :foo ) { mount APIRoutes::Foo }
    group( :bar ) { mount APIRoutes::Bar }
  end
私はかなり恣意的にファイルをフォルダーに配置します。
# Each file here defines a subclass of Grape::API
/routes/foo.rb 
# Each file here defines a subclass of Grape::Entity
/entities/foo.rb
# Files here marshal together functions from gems, the model and elsewhere for easy use
/helpers/authorise.rb
おそらく Rails をエミュレート/models/し、ActiveRecord または DataMapper の定義を保持するフォルダーなどを用意しますが、たまたま現在のプロジェクトでは別のパターンで提供されています。
私のルートのほとんどは非常に基本的に見えます。関連するヘルパー メソッドを呼び出し、それに基づいてエンティティを提示するだけです。たとえば/routes/foo.rb、次のようになります。
module APIRoutes
  class Foo < Grape::API
    helpers APIFooHelpers
    get :all do
      present get_all_users_foos, :with => APIEntity::Foo
    end
    group "id/:id" do
      before do
        @foo = Model::Foo.first( :id => params[:id] )
        error_if_cannot_access! @foo
      end
      get do
        present @foo, :with => APIEntity::Foo, :type => :full
      end
      put do
        update_foo( @foo, params )
        present @foo, :with => APIEntity::Foo, :type => :full
      end
      delete do
        delete_foo @foo
        true
      end
    end # group "id/:id"
  end # class Foo
end # module APIRoutes