zero-rails_openapi icon indicating copy to clipboard operation
zero-rails_openapi copied to clipboard

How to define a param object in a component?

Open sixties opened this issue 5 years ago • 1 comments

Hi,

Maybe a stupid newbie question: I defined an action like this:

api :show, 'return a single instance' do
   param :path, :id, Integer, :req, range: { gt: 0}, desc: 'instance id'
   resp 200, 'success', :json, data: :Instance
end`

I wanted to define the param in a component such as:

components do
  param :instance_id => [
      :path, id: {type: Integer}, desc: 'test']
end

Which gives a syntax error. Could you please give me a hint, how to define a path parameter in a components section?

Best regards,

Udo Eisenbarth

sixties avatar Jan 27 '21 09:01 sixties

Something similar we have:

components do
  query :UserIdQry    => [:user_id, String, desc: 'the user identifier']
end

and

api :index, "Description.", id: 'getData' do
  param_ref :UserIdQry
end

xhs345 avatar Dec 17 '21 03:12 xhs345