Class: MockServer::Body

Inherits:
Object
  • Object
show all
Defined in:
lib/mockserver/models.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type: nil, string: nil, xml: nil, json: nil, regex: nil, json_path: nil, xpath: nil, base64_bytes: nil, not_body: nil, content_type: nil, charset: nil, file_path: nil, template_type: nil, body_all_of: nil, sub_string: nil, match_type: nil, match_numbers_as_strings: nil, json_schema: nil, parameter_styles: nil, xml_schema: nil, parameters: nil, module_name: nil, optional: nil) ⇒ Body

Returns a new instance of Body.



450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
# File 'lib/mockserver/models.rb', line 450

def initialize(type: nil, string: nil, xml: nil, json: nil, regex: nil, json_path: nil, xpath: nil,
               base64_bytes: nil, not_body: nil, content_type: nil, charset: nil,
               file_path: nil, template_type: nil, body_all_of: nil,
               sub_string: nil, match_type: nil, match_numbers_as_strings: nil,
               json_schema: nil, parameter_styles: nil, xml_schema: nil,
               parameters: nil, module_name: nil, optional: nil)
  @type = type
  @string = string
  @xml = xml
  @json = json
  @regex = regex
  @json_path = json_path
  @xpath = xpath
  @base64_bytes = base64_bytes
  @not_body = not_body
  @content_type = content_type
  @charset = charset
  @file_path = file_path
  @template_type = template_type
  @body_all_of = body_all_of
  @sub_string = sub_string
  @match_type = match_type
  @match_numbers_as_strings = match_numbers_as_strings
  @json_schema = json_schema
  @parameter_styles = parameter_styles
  @xml_schema = xml_schema
  @parameters = parameters
  @module_name = module_name
  @optional = optional
end

Instance Attribute Details

#base64_bytesObject

sub_string / match_type / match_numbers_as_strings / json_schema / parameter_styles / xml_schema / parameters / module_name / optional are the per-type matcher sub-fields carried by the server body DTOs (StringBodyDTO.subString, JsonBodyDTO.matchType/matchNumbersAsStrings, JsonSchemaBodyDTO.jsonSchema/parameterStyles, XmlSchemaBodyDTO.xmlSchema, ParameterBodyDTO.parameters, WasmBodyDTO.moduleName, BodyDTO.optional). xml carries the XML body's own xml wire key (XmlBodyDTO.xml). It is distinct from string: the legacy Body.xml(...) factory populates string (pinned by a test), whereas a server-produced XML body serialises its content under xml.



445
446
447
# File 'lib/mockserver/models.rb', line 445

def base64_bytes
  @base64_bytes
end

#body_all_ofObject

sub_string / match_type / match_numbers_as_strings / json_schema / parameter_styles / xml_schema / parameters / module_name / optional are the per-type matcher sub-fields carried by the server body DTOs (StringBodyDTO.subString, JsonBodyDTO.matchType/matchNumbersAsStrings, JsonSchemaBodyDTO.jsonSchema/parameterStyles, XmlSchemaBodyDTO.xmlSchema, ParameterBodyDTO.parameters, WasmBodyDTO.moduleName, BodyDTO.optional). xml carries the XML body's own xml wire key (XmlBodyDTO.xml). It is distinct from string: the legacy Body.xml(...) factory populates string (pinned by a test), whereas a server-produced XML body serialises its content under xml.



445
446
447
# File 'lib/mockserver/models.rb', line 445

def body_all_of
  @body_all_of
end

#charsetObject

sub_string / match_type / match_numbers_as_strings / json_schema / parameter_styles / xml_schema / parameters / module_name / optional are the per-type matcher sub-fields carried by the server body DTOs (StringBodyDTO.subString, JsonBodyDTO.matchType/matchNumbersAsStrings, JsonSchemaBodyDTO.jsonSchema/parameterStyles, XmlSchemaBodyDTO.xmlSchema, ParameterBodyDTO.parameters, WasmBodyDTO.moduleName, BodyDTO.optional). xml carries the XML body's own xml wire key (XmlBodyDTO.xml). It is distinct from string: the legacy Body.xml(...) factory populates string (pinned by a test), whereas a server-produced XML body serialises its content under xml.



445
446
447
# File 'lib/mockserver/models.rb', line 445

def charset
  @charset
end

#content_typeObject

sub_string / match_type / match_numbers_as_strings / json_schema / parameter_styles / xml_schema / parameters / module_name / optional are the per-type matcher sub-fields carried by the server body DTOs (StringBodyDTO.subString, JsonBodyDTO.matchType/matchNumbersAsStrings, JsonSchemaBodyDTO.jsonSchema/parameterStyles, XmlSchemaBodyDTO.xmlSchema, ParameterBodyDTO.parameters, WasmBodyDTO.moduleName, BodyDTO.optional). xml carries the XML body's own xml wire key (XmlBodyDTO.xml). It is distinct from string: the legacy Body.xml(...) factory populates string (pinned by a test), whereas a server-produced XML body serialises its content under xml.



445
446
447
# File 'lib/mockserver/models.rb', line 445

def content_type
  @content_type
end

#file_pathObject

sub_string / match_type / match_numbers_as_strings / json_schema / parameter_styles / xml_schema / parameters / module_name / optional are the per-type matcher sub-fields carried by the server body DTOs (StringBodyDTO.subString, JsonBodyDTO.matchType/matchNumbersAsStrings, JsonSchemaBodyDTO.jsonSchema/parameterStyles, XmlSchemaBodyDTO.xmlSchema, ParameterBodyDTO.parameters, WasmBodyDTO.moduleName, BodyDTO.optional). xml carries the XML body's own xml wire key (XmlBodyDTO.xml). It is distinct from string: the legacy Body.xml(...) factory populates string (pinned by a test), whereas a server-produced XML body serialises its content under xml.



445
446
447
# File 'lib/mockserver/models.rb', line 445

def file_path
  @file_path
end

#jsonObject

sub_string / match_type / match_numbers_as_strings / json_schema / parameter_styles / xml_schema / parameters / module_name / optional are the per-type matcher sub-fields carried by the server body DTOs (StringBodyDTO.subString, JsonBodyDTO.matchType/matchNumbersAsStrings, JsonSchemaBodyDTO.jsonSchema/parameterStyles, XmlSchemaBodyDTO.xmlSchema, ParameterBodyDTO.parameters, WasmBodyDTO.moduleName, BodyDTO.optional). xml carries the XML body's own xml wire key (XmlBodyDTO.xml). It is distinct from string: the legacy Body.xml(...) factory populates string (pinned by a test), whereas a server-produced XML body serialises its content under xml.



445
446
447
# File 'lib/mockserver/models.rb', line 445

def json
  @json
end

#json_pathObject

sub_string / match_type / match_numbers_as_strings / json_schema / parameter_styles / xml_schema / parameters / module_name / optional are the per-type matcher sub-fields carried by the server body DTOs (StringBodyDTO.subString, JsonBodyDTO.matchType/matchNumbersAsStrings, JsonSchemaBodyDTO.jsonSchema/parameterStyles, XmlSchemaBodyDTO.xmlSchema, ParameterBodyDTO.parameters, WasmBodyDTO.moduleName, BodyDTO.optional). xml carries the XML body's own xml wire key (XmlBodyDTO.xml). It is distinct from string: the legacy Body.xml(...) factory populates string (pinned by a test), whereas a server-produced XML body serialises its content under xml.



445
446
447
# File 'lib/mockserver/models.rb', line 445

def json_path
  @json_path
end

#json_schemaObject

sub_string / match_type / match_numbers_as_strings / json_schema / parameter_styles / xml_schema / parameters / module_name / optional are the per-type matcher sub-fields carried by the server body DTOs (StringBodyDTO.subString, JsonBodyDTO.matchType/matchNumbersAsStrings, JsonSchemaBodyDTO.jsonSchema/parameterStyles, XmlSchemaBodyDTO.xmlSchema, ParameterBodyDTO.parameters, WasmBodyDTO.moduleName, BodyDTO.optional). xml carries the XML body's own xml wire key (XmlBodyDTO.xml). It is distinct from string: the legacy Body.xml(...) factory populates string (pinned by a test), whereas a server-produced XML body serialises its content under xml.



445
446
447
# File 'lib/mockserver/models.rb', line 445

def json_schema
  @json_schema
end

#match_numbers_as_stringsObject

sub_string / match_type / match_numbers_as_strings / json_schema / parameter_styles / xml_schema / parameters / module_name / optional are the per-type matcher sub-fields carried by the server body DTOs (StringBodyDTO.subString, JsonBodyDTO.matchType/matchNumbersAsStrings, JsonSchemaBodyDTO.jsonSchema/parameterStyles, XmlSchemaBodyDTO.xmlSchema, ParameterBodyDTO.parameters, WasmBodyDTO.moduleName, BodyDTO.optional). xml carries the XML body's own xml wire key (XmlBodyDTO.xml). It is distinct from string: the legacy Body.xml(...) factory populates string (pinned by a test), whereas a server-produced XML body serialises its content under xml.



445
446
447
# File 'lib/mockserver/models.rb', line 445

def match_numbers_as_strings
  @match_numbers_as_strings
end

#match_typeObject

sub_string / match_type / match_numbers_as_strings / json_schema / parameter_styles / xml_schema / parameters / module_name / optional are the per-type matcher sub-fields carried by the server body DTOs (StringBodyDTO.subString, JsonBodyDTO.matchType/matchNumbersAsStrings, JsonSchemaBodyDTO.jsonSchema/parameterStyles, XmlSchemaBodyDTO.xmlSchema, ParameterBodyDTO.parameters, WasmBodyDTO.moduleName, BodyDTO.optional). xml carries the XML body's own xml wire key (XmlBodyDTO.xml). It is distinct from string: the legacy Body.xml(...) factory populates string (pinned by a test), whereas a server-produced XML body serialises its content under xml.



445
446
447
# File 'lib/mockserver/models.rb', line 445

def match_type
  @match_type
end

#module_nameObject

sub_string / match_type / match_numbers_as_strings / json_schema / parameter_styles / xml_schema / parameters / module_name / optional are the per-type matcher sub-fields carried by the server body DTOs (StringBodyDTO.subString, JsonBodyDTO.matchType/matchNumbersAsStrings, JsonSchemaBodyDTO.jsonSchema/parameterStyles, XmlSchemaBodyDTO.xmlSchema, ParameterBodyDTO.parameters, WasmBodyDTO.moduleName, BodyDTO.optional). xml carries the XML body's own xml wire key (XmlBodyDTO.xml). It is distinct from string: the legacy Body.xml(...) factory populates string (pinned by a test), whereas a server-produced XML body serialises its content under xml.



445
446
447
# File 'lib/mockserver/models.rb', line 445

def module_name
  @module_name
end

#not_bodyObject

sub_string / match_type / match_numbers_as_strings / json_schema / parameter_styles / xml_schema / parameters / module_name / optional are the per-type matcher sub-fields carried by the server body DTOs (StringBodyDTO.subString, JsonBodyDTO.matchType/matchNumbersAsStrings, JsonSchemaBodyDTO.jsonSchema/parameterStyles, XmlSchemaBodyDTO.xmlSchema, ParameterBodyDTO.parameters, WasmBodyDTO.moduleName, BodyDTO.optional). xml carries the XML body's own xml wire key (XmlBodyDTO.xml). It is distinct from string: the legacy Body.xml(...) factory populates string (pinned by a test), whereas a server-produced XML body serialises its content under xml.



445
446
447
# File 'lib/mockserver/models.rb', line 445

def not_body
  @not_body
end

#optionalObject

sub_string / match_type / match_numbers_as_strings / json_schema / parameter_styles / xml_schema / parameters / module_name / optional are the per-type matcher sub-fields carried by the server body DTOs (StringBodyDTO.subString, JsonBodyDTO.matchType/matchNumbersAsStrings, JsonSchemaBodyDTO.jsonSchema/parameterStyles, XmlSchemaBodyDTO.xmlSchema, ParameterBodyDTO.parameters, WasmBodyDTO.moduleName, BodyDTO.optional). xml carries the XML body's own xml wire key (XmlBodyDTO.xml). It is distinct from string: the legacy Body.xml(...) factory populates string (pinned by a test), whereas a server-produced XML body serialises its content under xml.



445
446
447
# File 'lib/mockserver/models.rb', line 445

def optional
  @optional
end

#parameter_stylesObject

sub_string / match_type / match_numbers_as_strings / json_schema / parameter_styles / xml_schema / parameters / module_name / optional are the per-type matcher sub-fields carried by the server body DTOs (StringBodyDTO.subString, JsonBodyDTO.matchType/matchNumbersAsStrings, JsonSchemaBodyDTO.jsonSchema/parameterStyles, XmlSchemaBodyDTO.xmlSchema, ParameterBodyDTO.parameters, WasmBodyDTO.moduleName, BodyDTO.optional). xml carries the XML body's own xml wire key (XmlBodyDTO.xml). It is distinct from string: the legacy Body.xml(...) factory populates string (pinned by a test), whereas a server-produced XML body serialises its content under xml.



445
446
447
# File 'lib/mockserver/models.rb', line 445

def parameter_styles
  @parameter_styles
end

#parametersObject

sub_string / match_type / match_numbers_as_strings / json_schema / parameter_styles / xml_schema / parameters / module_name / optional are the per-type matcher sub-fields carried by the server body DTOs (StringBodyDTO.subString, JsonBodyDTO.matchType/matchNumbersAsStrings, JsonSchemaBodyDTO.jsonSchema/parameterStyles, XmlSchemaBodyDTO.xmlSchema, ParameterBodyDTO.parameters, WasmBodyDTO.moduleName, BodyDTO.optional). xml carries the XML body's own xml wire key (XmlBodyDTO.xml). It is distinct from string: the legacy Body.xml(...) factory populates string (pinned by a test), whereas a server-produced XML body serialises its content under xml.



445
446
447
# File 'lib/mockserver/models.rb', line 445

def parameters
  @parameters
end

#regexObject

sub_string / match_type / match_numbers_as_strings / json_schema / parameter_styles / xml_schema / parameters / module_name / optional are the per-type matcher sub-fields carried by the server body DTOs (StringBodyDTO.subString, JsonBodyDTO.matchType/matchNumbersAsStrings, JsonSchemaBodyDTO.jsonSchema/parameterStyles, XmlSchemaBodyDTO.xmlSchema, ParameterBodyDTO.parameters, WasmBodyDTO.moduleName, BodyDTO.optional). xml carries the XML body's own xml wire key (XmlBodyDTO.xml). It is distinct from string: the legacy Body.xml(...) factory populates string (pinned by a test), whereas a server-produced XML body serialises its content under xml.



445
446
447
# File 'lib/mockserver/models.rb', line 445

def regex
  @regex
end

#stringObject

sub_string / match_type / match_numbers_as_strings / json_schema / parameter_styles / xml_schema / parameters / module_name / optional are the per-type matcher sub-fields carried by the server body DTOs (StringBodyDTO.subString, JsonBodyDTO.matchType/matchNumbersAsStrings, JsonSchemaBodyDTO.jsonSchema/parameterStyles, XmlSchemaBodyDTO.xmlSchema, ParameterBodyDTO.parameters, WasmBodyDTO.moduleName, BodyDTO.optional). xml carries the XML body's own xml wire key (XmlBodyDTO.xml). It is distinct from string: the legacy Body.xml(...) factory populates string (pinned by a test), whereas a server-produced XML body serialises its content under xml.



445
446
447
# File 'lib/mockserver/models.rb', line 445

def string
  @string
end

#sub_stringObject

sub_string / match_type / match_numbers_as_strings / json_schema / parameter_styles / xml_schema / parameters / module_name / optional are the per-type matcher sub-fields carried by the server body DTOs (StringBodyDTO.subString, JsonBodyDTO.matchType/matchNumbersAsStrings, JsonSchemaBodyDTO.jsonSchema/parameterStyles, XmlSchemaBodyDTO.xmlSchema, ParameterBodyDTO.parameters, WasmBodyDTO.moduleName, BodyDTO.optional). xml carries the XML body's own xml wire key (XmlBodyDTO.xml). It is distinct from string: the legacy Body.xml(...) factory populates string (pinned by a test), whereas a server-produced XML body serialises its content under xml.



445
446
447
# File 'lib/mockserver/models.rb', line 445

def sub_string
  @sub_string
end

#template_typeObject

sub_string / match_type / match_numbers_as_strings / json_schema / parameter_styles / xml_schema / parameters / module_name / optional are the per-type matcher sub-fields carried by the server body DTOs (StringBodyDTO.subString, JsonBodyDTO.matchType/matchNumbersAsStrings, JsonSchemaBodyDTO.jsonSchema/parameterStyles, XmlSchemaBodyDTO.xmlSchema, ParameterBodyDTO.parameters, WasmBodyDTO.moduleName, BodyDTO.optional). xml carries the XML body's own xml wire key (XmlBodyDTO.xml). It is distinct from string: the legacy Body.xml(...) factory populates string (pinned by a test), whereas a server-produced XML body serialises its content under xml.



445
446
447
# File 'lib/mockserver/models.rb', line 445

def template_type
  @template_type
end

#typeObject

sub_string / match_type / match_numbers_as_strings / json_schema / parameter_styles / xml_schema / parameters / module_name / optional are the per-type matcher sub-fields carried by the server body DTOs (StringBodyDTO.subString, JsonBodyDTO.matchType/matchNumbersAsStrings, JsonSchemaBodyDTO.jsonSchema/parameterStyles, XmlSchemaBodyDTO.xmlSchema, ParameterBodyDTO.parameters, WasmBodyDTO.moduleName, BodyDTO.optional). xml carries the XML body's own xml wire key (XmlBodyDTO.xml). It is distinct from string: the legacy Body.xml(...) factory populates string (pinned by a test), whereas a server-produced XML body serialises its content under xml.



445
446
447
# File 'lib/mockserver/models.rb', line 445

def type
  @type
end

#xmlObject

sub_string / match_type / match_numbers_as_strings / json_schema / parameter_styles / xml_schema / parameters / module_name / optional are the per-type matcher sub-fields carried by the server body DTOs (StringBodyDTO.subString, JsonBodyDTO.matchType/matchNumbersAsStrings, JsonSchemaBodyDTO.jsonSchema/parameterStyles, XmlSchemaBodyDTO.xmlSchema, ParameterBodyDTO.parameters, WasmBodyDTO.moduleName, BodyDTO.optional). xml carries the XML body's own xml wire key (XmlBodyDTO.xml). It is distinct from string: the legacy Body.xml(...) factory populates string (pinned by a test), whereas a server-produced XML body serialises its content under xml.



445
446
447
# File 'lib/mockserver/models.rb', line 445

def xml
  @xml
end

#xml_schemaObject

sub_string / match_type / match_numbers_as_strings / json_schema / parameter_styles / xml_schema / parameters / module_name / optional are the per-type matcher sub-fields carried by the server body DTOs (StringBodyDTO.subString, JsonBodyDTO.matchType/matchNumbersAsStrings, JsonSchemaBodyDTO.jsonSchema/parameterStyles, XmlSchemaBodyDTO.xmlSchema, ParameterBodyDTO.parameters, WasmBodyDTO.moduleName, BodyDTO.optional). xml carries the XML body's own xml wire key (XmlBodyDTO.xml). It is distinct from string: the legacy Body.xml(...) factory populates string (pinned by a test), whereas a server-produced XML body serialises its content under xml.



445
446
447
# File 'lib/mockserver/models.rb', line 445

def xml_schema
  @xml_schema
end

#xpathObject

sub_string / match_type / match_numbers_as_strings / json_schema / parameter_styles / xml_schema / parameters / module_name / optional are the per-type matcher sub-fields carried by the server body DTOs (StringBodyDTO.subString, JsonBodyDTO.matchType/matchNumbersAsStrings, JsonSchemaBodyDTO.jsonSchema/parameterStyles, XmlSchemaBodyDTO.xmlSchema, ParameterBodyDTO.parameters, WasmBodyDTO.moduleName, BodyDTO.optional). xml carries the XML body's own xml wire key (XmlBodyDTO.xml). It is distinct from string: the legacy Body.xml(...) factory populates string (pinned by a test), whereas a server-produced XML body serialises its content under xml.



445
446
447
# File 'lib/mockserver/models.rb', line 445

def xpath
  @xpath
end

Class Method Details

.all_of(*bodies) ⇒ Object

Combine several body matchers into a single ALL_OF matcher; all of the supplied sub-bodies must match the request body. Each sub-body is any existing body matcher (e.g. Body.json_path, Body.regex) and is serialised through the normal body-serialisation path.



566
567
568
# File 'lib/mockserver/models.rb', line 566

def self.all_of(*bodies)
  new(type: 'ALL_OF', body_all_of: bodies.flatten)
end

.exact(value) ⇒ Object



554
555
556
# File 'lib/mockserver/models.rb', line 554

def self.exact(value)
  new(type: 'STRING', string: value)
end

.file(file_path, content_type: nil, template_type: nil) ⇒ Object



606
607
608
# File 'lib/mockserver/models.rb', line 606

def self.file(file_path, content_type: nil, template_type: nil)
  new(type: 'FILE', file_path: file_path, content_type: content_type, template_type: template_type)
end

.from_hash(data) ⇒ Object



511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
# File 'lib/mockserver/models.rb', line 511

def self.from_hash(data)
  return nil if data.nil?

  all_of = data['bodyAllOf']
  new(
    type:          data['type'],
    string:        data['string'],
    xml:           data['xml'],
    json:          data['json'],
    regex:         data['regex'],
    json_path:     data['jsonPath'],
    xpath:         data['xpath'],
    base64_bytes:  data['base64Bytes'],
    not_body:      data['not'],
    content_type:  data['contentType'],
    charset:       data['charset'],
    file_path:     data['filePath'],
    template_type: data['templateType'],
    sub_string:               data['subString'],
    match_type:               data['matchType'],
    match_numbers_as_strings: data['matchNumbersAsStrings'],
    json_schema:              data['jsonSchema'],
    parameter_styles:         data['parameterStyles'],
    xml_schema:               data['xmlSchema'],
    parameters:               data['parameters'],
    module_name:              data['moduleName'],
    optional:                 data['optional'],
    body_all_of:   all_of&.map { |b| MockServer.deserialize_body(b) }
  )
end

.graphql(query, operation_name: nil, variables_schema: nil) ⇒ Object



614
615
616
# File 'lib/mockserver/models.rb', line 614

def self.graphql(query, operation_name: nil, variables_schema: nil)
  GraphQLBody.new(query: query, operation_name: operation_name, variables_schema: variables_schema)
end

.json(value) ⇒ Object



546
547
548
# File 'lib/mockserver/models.rb', line 546

def self.json(value)
  new(type: 'JSON', json: value)
end

.json_path(value) ⇒ Object



570
571
572
# File 'lib/mockserver/models.rb', line 570

def self.json_path(value)
  new(type: 'JSON_PATH', json_path: value)
end

.json_rpc(method_name, params_schema: nil) ⇒ Object



610
611
612
# File 'lib/mockserver/models.rb', line 610

def self.json_rpc(method_name, params_schema: nil)
  JsonRpcBody.new(method_name: method_name, params_schema: params_schema)
end

.json_schema(schema, parameter_styles: nil) ⇒ Object

A JSON_SCHEMA body matcher. parameter_styles is an optional { parameter-name => style } map (serialised as parameterStyles).



580
581
582
# File 'lib/mockserver/models.rb', line 580

def self.json_schema(schema, parameter_styles: nil)
  new(type: 'JSON_SCHEMA', json_schema: schema, parameter_styles: parameter_styles)
end

.parameters(parameters) ⇒ Object

A PARAMETERS (form / query) body matcher. parameters is the wire form of the parameter collection (either a { name => [values] } map or the [values] array form).



597
598
599
# File 'lib/mockserver/models.rb', line 597

def self.parameters(parameters)
  new(type: 'PARAMETERS', parameters: parameters)
end

.regex(value) ⇒ Object



550
551
552
# File 'lib/mockserver/models.rb', line 550

def self.regex(value)
  new(type: 'REGEX', regex: value)
end

.string(value) ⇒ Object



542
543
544
# File 'lib/mockserver/models.rb', line 542

def self.string(value)
  new(type: 'STRING', string: value)
end

.sub_string(value) ⇒ Object

A STRING body matcher that matches when value appears as a substring.



590
591
592
# File 'lib/mockserver/models.rb', line 590

def self.sub_string(value)
  new(type: 'STRING', string: value, sub_string: true)
end

.wasm(module_name) ⇒ Object

A WASM body matcher that delegates matching to the named WASM module.



602
603
604
# File 'lib/mockserver/models.rb', line 602

def self.wasm(module_name)
  new(type: 'WASM', module_name: module_name)
end

.xml(value) ⇒ Object



558
559
560
# File 'lib/mockserver/models.rb', line 558

def self.xml(value)
  new(type: 'XML', string: value)
end

.xml_schema(schema) ⇒ Object

An XML_SCHEMA body matcher.



585
586
587
# File 'lib/mockserver/models.rb', line 585

def self.xml_schema(schema)
  new(type: 'XML_SCHEMA', xml_schema: schema)
end

.xpath(value) ⇒ Object



574
575
576
# File 'lib/mockserver/models.rb', line 574

def self.xpath(value)
  new(type: 'XPATH', xpath: value)
end

Instance Method Details

#to_hObject



481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
# File 'lib/mockserver/models.rb', line 481

def to_h
  result = {}
  result['type']         = @type          unless @type.nil?
  result['string']       = @string        unless @string.nil?
  result['xml']          = @xml           unless @xml.nil?
  result['json']         = @json          unless @json.nil?
  result['regex']        = @regex         unless @regex.nil?
  result['jsonPath']     = @json_path     unless @json_path.nil?
  result['xpath']        = @xpath         unless @xpath.nil?
  result['base64Bytes']  = @base64_bytes  unless @base64_bytes.nil?
  result['not']          = @not_body      unless @not_body.nil?
  result['contentType']  = @content_type  unless @content_type.nil?
  result['charset']      = @charset       unless @charset.nil?
  result['filePath']     = @file_path     unless @file_path.nil?
  result['templateType'] = @template_type unless @template_type.nil?
  result['subString']    = @sub_string    unless @sub_string.nil?
  result['matchType']    = @match_type    unless @match_type.nil?
  result['matchNumbersAsStrings'] = @match_numbers_as_strings unless @match_numbers_as_strings.nil?
  result['jsonSchema']   = @json_schema   unless @json_schema.nil?
  result['parameterStyles'] = @parameter_styles unless @parameter_styles.nil?
  result['xmlSchema']    = @xml_schema    unless @xml_schema.nil?
  result['parameters']   = @parameters    unless @parameters.nil?
  result['moduleName']   = @module_name   unless @module_name.nil?
  result['optional']     = @optional      unless @optional.nil?
  unless @body_all_of.nil?
    result['bodyAllOf'] = @body_all_of.map { |b| MockServer.serialize_body(b) }
  end
  result
end

#with_template_type(template_type) ⇒ Object



618
619
620
621
# File 'lib/mockserver/models.rb', line 618

def with_template_type(template_type)
  @template_type = template_type
  self
end