Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to set either one parameter be required? #126

Open
02040402 opened this issue Jul 23, 2019 · 1 comment
Open

How to set either one parameter be required? #126

02040402 opened this issue Jul 23, 2019 · 1 comment

Comments

@02040402
Copy link

This way can set the special parameter required:

parameter do
  key :name, :id
  key :in, :path
  key :description, 'ID of pet to fetch'
  key :required, true
  key :type, :integer
  key :format, :int64
end

But if I want to let one of two parameters(either one is ok) be required as:

parameter do
  key :name, :id
  key :in, :path
  key :description, 'ID of pet to fetch'
  key :required, true
  key :type, :integer
  key :format, :int64
end

parameter do
  key :name, :user_id
  key :in, :path
  key :description, 'User ID of pet to fetch'
  key :required, true
  key :type, :integer
  key :format, :int64
end

Since each of them has key :required, true themselves. How to do in this case?

@hcyildirim
Copy link

hcyildirim commented Sep 30, 2020

Hey, did you find a solution?

UPDATE: I've solved mine like this:

 one_of do
     key :required, %i[id]
 end

 one_of do
     key :required, %i[product_id]
 end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants