Module: Graphiti::OpenAPI::Parameters

Included in:
Action, Resource
Defined in:
app/models/graphiti/open_api/parameters.rb

Instance Method Summary collapse

Instance Method Details

#array_enum(enum, type: :string, uniq: true) ⇒ Object



19
20
21
22
23
24
25
26
27
28
# File 'app/models/graphiti/open_api/parameters.rb', line 19

def array_enum(enum, type: :string, uniq: true)
  {
    type: :array,
    items: {
      type: type,
      enum: enum,
      uniqueItems: uniq,
    },
  }
end

#parameter(name, desc: nil, **options) ⇒ Object



5
6
7
8
9
# File 'app/models/graphiti/open_api/parameters.rb', line 5

def parameter(name, desc: nil, **options)
  options.merge(name: name).tap do |parameter|
    parameter[:description] = desc if desc
  end
end

#path_parameter(name, required: true, **options) ⇒ Object



15
16
17
# File 'app/models/graphiti/open_api/parameters.rb', line 15

def path_parameter(name, required: true, **options)
  parameter(name, in: :path, required: required, **options)
end

#query_parameter(name, **options) ⇒ Object



11
12
13
# File 'app/models/graphiti/open_api/parameters.rb', line 11

def query_parameter(name, **options)
  parameter(name, in: :query, **options)
end