Sha256: 6a2b991f61c52ba63863b2575213fc3623f912215e94e972094f88569b159261

Contents?: true

Size: 1.76 KB

Versions: 7

Compression:

Stored size: 1.76 KB

Contents

<%
  # Handle any cases where the top level of the oneOf is an allOf
  schemas = schema.map do |s|
    if s['allOf']
      newSchema = body.handle_all_of(s)
      s.each do |k,v|
        newSchema[k] = v
      end

      next newSchema
    end
    s
  end


  panels = []

  schemas.each_with_index do |schema, index|
    if schema['properties']
      schema['properties'] = schema['properties'].map do |name, definition|
        OasParser::Property.new(self, schema, name, definition)
      end
      .sort_by do |prop|
        prop.required ? -1 : 1
      end
    end

    panels.push({
      'description' => schema['title'] || schema['description'],
      'parameters' => schema['properties'],
      'oneOf' => schema['oneOf'],
      'x-tab-id' => schema['x-tab-id'] || schema['title'].parameterize,
      'active' => index == 0
    })
  end
%>

<div class="Vlt-tabs js-format" data-format="<%= format %>">
  <div class="Vlt-tabs__header" role="tablist" aria-label="Responses">
    <% panels.each do |panel| %>
      <div role="tab" data-tab-link="<%= panel['x-tab-id'] %>" class="Vlt-tabs__link <%= panel['active'] ? 'Vlt-tabs__link_active' : '' %>">
        <%= panel['description'] %>
      </div>
    <% end %>
  </div>
  <div class="Vlt-tabs__content">
    <% panels.each do |panel| %>
      <div class="Vlt-tabs__panel <%= panel['active'] ? 'Vlt-tabs__panel_active' : '' %>">
      <%
        # Nested oneOf?
        if panel['oneOf']
          %>
          <%= erb :'open_api/_tabbed_parameters', locals: { body: body, schema: panel['oneOf'], format: format, callback: callback } %>
        <%
        else
        %>

        <%= erb :'open_api/_parameters', locals: { parameters: panel['parameters'], callback: callback } %>
      <% end %>
      </div>
    <% end %>
  </div>
</div>

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
nexmo-oas-renderer-2.2.0 lib/nexmo/oas/renderer/views/open_api/_tabbed_parameters.erb
nexmo-oas-renderer-2.1.3 lib/nexmo/oas/renderer/views/open_api/_tabbed_parameters.erb
nexmo-oas-renderer-2.1.2 lib/nexmo/oas/renderer/views/open_api/_tabbed_parameters.erb
nexmo-oas-renderer-2.1.1 lib/nexmo/oas/renderer/views/open_api/_tabbed_parameters.erb
nexmo-oas-renderer-2.1.0 lib/nexmo/oas/renderer/views/open_api/_tabbed_parameters.erb
nexmo-oas-renderer-2.0.1 lib/nexmo/oas/renderer/views/open_api/_tabbed_parameters.erb
nexmo-oas-renderer-2.0.0 lib/nexmo/oas/renderer/views/open_api/_tabbed_parameters.erb