Sha256: 87717c9a266791e4960064b40e7f0bfee154b3e6cb7bc58ec993f6a797b9eb05

Contents?: true

Size: 1.4 KB

Versions: 5

Compression:

Stored size: 1.4 KB

Contents

# frozen_string_literal: true

module Nexmo
  module OAS
    module Renderer
      module Presenters
        module ResponseTab
          class Panel
            attr_reader :index

            def initialize(schema:, index:, format:, content:, endpoint:, theme_light: nil) # rubocop:disable Metrics/ParameterLists
              @schema  = schema
              @index   = index
              @format  = format
              @content = content
              @endpoint = endpoint
              @theme_light = theme_light
            end

            def css_classes
              classes = ['Vlt-tabs__panel']
              classes << 'Vlt-tabs__panel_active' if @index.zero?
              classes.join(' ')
            end

            def content
              if @content.is_a?(Nexmo::OAS::Renderer::Presenters::ContentSwitcher)
                return @content.render
              end

              if @content == :responses
                Nexmo::OAS::Renderer::ResponseParserDecorator
                  .new(@schema)
                  .html(@format, xml_options: @schema['xml'], theme_light: @theme_light)
              else
                [:'open_api/_response_fields', locals: {
                  schema: @schema,
                  index: @index,
                  format: @format,
                  endpoint: @endpoint,
                }]
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
nexmo-oas-renderer-2.7.2 lib/nexmo/oas/renderer/presenters/response_tab/panel.rb
nexmo-oas-renderer-2.7.1 lib/nexmo/oas/renderer/presenters/response_tab/panel.rb
nexmo-oas-renderer-2.7.0 lib/nexmo/oas/renderer/presenters/response_tab/panel.rb
nexmo-oas-renderer-2.6.0 lib/nexmo/oas/renderer/presenters/response_tab/panel.rb
nexmo-oas-renderer-2.5.0 lib/nexmo/oas/renderer/presenters/response_tab/panel.rb