Skip to content

Defining a catch-all after multiple versions of an endpoint hide endpoints after the first definition #1721

@zherr

Description

@zherr

Given the following test:

shared_examples_for 'versioning' do
  context 'with different versions for the same endpoint' do
    context 'catch-all' do
      before do
        subject.version 'v1', macro_options
        subject.get 'version' do
          'v1'
        end

        subject.format :txt
        subject.version 'v2', macro_options
        subject.get 'version' do
          'v2'
        end

        subject.route :any, '*path' do
          error!('Not Found', 404)
        end
      end

      it 'finds v1 of the endpoint' do
        versioned_get '/version', 'v1', macro_options
        expect(last_response.status).to eq(200)
        expect(last_response.body).to eq('v1')
      end

      it 'finds v2 of the endpoint' do 
        versioned_get '/version', 'v2', macro_options
        expect(last_response.status).to eq(200) # >>>>> This fails! Results in 404 <<<<<
        expect(last_response.body).to eq('v2')
      end
    end
  end
end

For even more context, see: master...zherr:multiple-endpoint-catchall

Before digging deeper into a fix I would like to gather feedback from contributors on whether this appears to be a bug, or if this behavior intentional.

Happy holidays!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions