Class: Nexmo::OAS::Renderer::Presenters::OpenApiSpecification

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/nexmo/oas/renderer/presenters/open_api_specification.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(definition_name:, expand_responses:) ⇒ OpenApiSpecification

Returns a new instance of OpenApiSpecification.



22
23
24
25
26
27
# File 'lib/nexmo/oas/renderer/presenters/open_api_specification.rb', line 22

def initialize(definition_name:, expand_responses:)
  @definition_name  = definition_name
  @expand_responses = expand_responses
  @versions         = Versions.new(definition_name)
  @groups           = Groups.new(definition)
end

Instance Attribute Details

#definition_nameObject (readonly)

Returns the value of attribute definition_name.



17
18
19
# File 'lib/nexmo/oas/renderer/presenters/open_api_specification.rb', line 17

def definition_name
  @definition_name
end

Instance Method Details

#auto_expand_responsesObject



45
46
47
# File 'lib/nexmo/oas/renderer/presenters/open_api_specification.rb', line 45

def auto_expand_responses
  @expand_responses
end

#definitionObject



41
42
43
# File 'lib/nexmo/oas/renderer/presenters/open_api_specification.rb', line 41

def definition
  @definition ||= OpenApiDefinitionResolver.find(@definition_name)
end

#definition_errorsObject



33
34
35
36
37
38
39
# File 'lib/nexmo/oas/renderer/presenters/open_api_specification.rb', line 33

def definition_errors
  return unless errors?

  @definition_errors ||= Nexmo::Markdown::Renderer.new.call(
    File.read("#{API.oas_path}/../../errors/#{@definition_name}.md")
  )
end

#errors?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/nexmo/oas/renderer/presenters/open_api_specification.rb', line 29

def errors?
  File.exist?("#{API.oas_path}/../../errors/#{@definition_name}.md")
end

#formatsObject



49
50
51
# File 'lib/nexmo/oas/renderer/presenters/open_api_specification.rb', line 49

def formats
  @formats ||= ResponseFormat.to_dropdown(endpoints.flat_map(&:formats).uniq)
end