Class: GrapeOAS::Exporter::OAS2::Parameter

Inherits:
Object
  • Object
show all
Defined in:
lib/grape_oas/exporter/oas2/parameter.rb

Constant Summary collapse

PRIMITIVE_MAPPINGS =
{
  Constants::SchemaTypes::INTEGER => { type: Constants::SchemaTypes::INTEGER, format: "int32" },
  "long" => { type: Constants::SchemaTypes::INTEGER, format: "int64" },
  "float" => { type: Constants::SchemaTypes::NUMBER, format: "float" },
  "double" => { type: Constants::SchemaTypes::NUMBER, format: "double" },
  "byte" => { type: Constants::SchemaTypes::STRING, format: "byte" },
  "date" => { type: Constants::SchemaTypes::STRING, format: "date" },
  "dateTime" => { type: Constants::SchemaTypes::STRING, format: "date-time" },
  "binary" => { type: Constants::SchemaTypes::STRING, format: "binary" },
  "password" => { type: Constants::SchemaTypes::STRING, format: "password" },
  "email" => { type: Constants::SchemaTypes::STRING, format: "email" },
  "uuid" => { type: Constants::SchemaTypes::STRING, format: "uuid" }
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(operation, ref_tracker = nil, nullable_strategy: nil) ⇒ Parameter

Returns a new instance of Parameter.



21
22
23
24
25
# File 'lib/grape_oas/exporter/oas2/parameter.rb', line 21

def initialize(operation, ref_tracker = nil, nullable_strategy: nil)
  @op = operation
  @ref_tracker = ref_tracker
  @nullable_strategy = nullable_strategy
end

Instance Method Details

#buildObject



27
28
29
30
31
# File 'lib/grape_oas/exporter/oas2/parameter.rb', line 27

def build
  params = Array(@op.parameters).map { |param| build_parameter(param) }
  params << build_body_parameter(@op.request_body) if @op.request_body
  params
end