Module: Openapi3Parser::NodeFactory::ObjectFactory::Dsl

Included in:
Openapi3Parser::NodeFactory::Object
Defined in:
lib/openapi3_parser/node_factory/object_factory/dsl.rb

Instance Method Summary collapse

Instance Method Details

#allow_extensionsObject



20
21
22
# File 'lib/openapi3_parser/node_factory/object_factory/dsl.rb', line 20

def allow_extensions
  @allow_extensions = true
end

#allowed_extensions?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/openapi3_parser/node_factory/object_factory/dsl.rb', line 24

def allowed_extensions?
  @allow_extensions == true
end

#field(name, **options) ⇒ Object



11
12
13
14
# File 'lib/openapi3_parser/node_factory/object_factory/dsl.rb', line 11

def field(name, **options)
  @field_configs ||= {}
  @field_configs[name] = FieldConfig.new(options)
end

#field_configsObject



16
17
18
# File 'lib/openapi3_parser/node_factory/object_factory/dsl.rb', line 16

def field_configs
  @field_configs || {}
end

#mutually_exclusive(*fields, required: false) ⇒ Object



28
29
30
31
32
33
# File 'lib/openapi3_parser/node_factory/object_factory/dsl.rb', line 28

def mutually_exclusive(*fields, required: false)
  @mutually_exclusive ||= []
  @mutually_exclusive << OpenStruct.new(
    fields: fields, required: required
  )
end

#mutually_exclusive_fieldsObject



35
36
37
# File 'lib/openapi3_parser/node_factory/object_factory/dsl.rb', line 35

def mutually_exclusive_fields
  @mutually_exclusive || []
end

#validate(*items, &block) ⇒ Object



39
40
41
42
# File 'lib/openapi3_parser/node_factory/object_factory/dsl.rb', line 39

def validate(*items, &block)
  @validations = (@validations || []).concat(items)
  @validations << block if block
end

#validationsObject



44
45
46
# File 'lib/openapi3_parser/node_factory/object_factory/dsl.rb', line 44

def validations
  @validations || []
end