Class: Swagger::Diff::Diff

Inherits:
Object
  • Object
show all
Defined in:
lib/swagger/diff/diff.rb

Instance Method Summary collapse

Constructor Details

#initialize(old, new) ⇒ Diff

Returns a new instance of Diff.



4
5
6
7
# File 'lib/swagger/diff/diff.rb', line 4

def initialize(old, new)
  @new_specification = Swagger::Diff::Specification.new(new)
  @old_specification = Swagger::Diff::Specification.new(old)
end

Instance Method Details

#compatible?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/swagger/diff/diff.rb', line 9

def compatible?
  endpoints_compatible? && requests_compatible? && responses_compatible?
end

#incompatibilitiesObject



13
14
15
16
17
# File 'lib/swagger/diff/diff.rb', line 13

def incompatibilities
  { endpoints: missing_endpoints.to_a.sort,
    request_params: incompatible_request_params,
    response_attributes: incompatible_response_attributes }
end

#incompatibilities_messageObject



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/swagger/diff/diff.rb', line 19

def incompatibilities_message
  msg = ''
  if incompatibilities[:endpoints]
    msg += incompatibilities_message_endpoints(incompatibilities[:endpoints])
  end
  if incompatibilities[:request_params]
    msg += incompatibilities_message_params(incompatibilities[:request_params])
  end
  if incompatibilities[:response_attributes]
    msg += incompatibilities_message_attributes(incompatibilities[:response_attributes])
  end
  msg
end