Sha256: e0e73b91a6de894813fb276a8e21b0aaa615918e913807d431e1ef9f3ca8c894

Contents?: true

Size: 769 Bytes

Versions: 1

Compression:

Stored size: 769 Bytes

Contents

# frozen_string_literal: true

require 'spec_helper'

describe '#878 handle optional path segments' do
  let(:app) do
    Class.new(Grape::API) do
      resource :books do
        get 'page(/one)(/:two)/three' do
          { message: 'hello world' }
        end
      end

      add_swagger_documentation
    end
  end
  let(:parameters) { subject['paths']['/books/page/{two}/three']['get']['parameters'] }

  subject do
    get '/swagger_doc'
    JSON.parse(last_response.body)
  end

  specify do
    section_param = parameters.find { |param| param['name'] == 'two' }
    expect(section_param['in']).to eq 'path'
    expect(subject['paths'].keys).to eq ['/books/page/three', '/books/page/{two}/three', '/books/page/one/three', '/books/page/one/{two}/three']
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gitlab-grape-swagger-1.5.0 spec/issues/878_optional_path_segments_spec.rb