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

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

Defined Under Namespace

Classes: MutuallyExclusiveField

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
27
28
29
30
# File 'lib/openapi3_parser/node_factory/object_factory/dsl.rb', line 24

def allowed_extensions?
  if instance_variable_defined?(:@allow_extensions)
    @allow_extensions == true
  else
    false
  end
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



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

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

#mutually_exclusive_fieldsObject



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

def mutually_exclusive_fields
  @mutually_exclusive_fields ||= []
end

#validate(*items, &block) ⇒ Object



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

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

#validationsObject



50
51
52
# File 'lib/openapi3_parser/node_factory/object_factory/dsl.rb', line 50

def validations
  @validations ||= []
end