Problem overriding REST API in plugin

Added by Alexey Komarov over 4 years ago

I have problem writing plugin which overrides REST API view. I wrote new api.rsb file and put it in my plugin folder with respect to the original path. Redmine was expected to load and use overridden API view, but it continued to load the old one.

My plugin folder structure:

plugins\custom_api\app\views\users\show.api.rsb
plugins\custom_api\init.rb

My `init.rb`:

require 'redmine'

Redmine::Plugin.register :redmine_custom_api_plugin do
  name 'Custom API Plugin'
  author 'Name'
  description 'Description'
  version '0.1'
end

Environment:

Environment:
  Redmine version                          2.3.1.stable
  Ruby version                             1.9.3 (i386-mingw32)
  Rails version                            3.2.13
  Environment                              production
  Database adapter                         Mysql2
Redmine plugins:
  redmine_custom_api_plugin                0.1

What am I doing wrong? How to override Redmine API without patching original sources?

Replies (4)

RE: Problem overriding REST API in plugin - Added by Jean-Baptiste Barth over 4 years ago

Maybe it's due to the fact your plugin name (redmine_custom_api_plugin) doesn't match the directory name under plugins/ (custom_api). I think it's mandatory that the two match perfectly, try to adapt one to match the other, and your views should override just fine. If it still doesn't work then it's probably a bug, I can dig into it later.

RE: Problem overriding REST API in plugin - Added by Alexey Komarov over 4 years ago

Jean-Baptiste Barth wrote:

Maybe it's due to the fact your plugin name (redmine_custom_api_plugin) doesn't match the directory name under plugins/ (custom_api).

Thank you for reply.
Unfortunately, it does not help. I think the issue only applies to api views, because I've got another plugin overriding models which works perfectly even with name/directory mismatch.

RE: Problem overriding REST API in plugin - Added by Alexey Komarov over 4 years ago

Please help with this issue. It's a huge showstopper for me right now.

Maybe I am doing something wrong and view should be registered somewhere?

RE: Problem overriding REST API in plugin - Added by Steffen Gebert over 4 years ago

I have exactly the same problem!

This works with RM 1.4, but not with 2.2.4: https://github.com/TYPO3/rm_typo3_api/blob/master/app/views/members/index.api.rsb

(I'm adding the login of users to the output)

(1-4/4)