richhollis/swagger-docs — pull request #22 by stevschmid (2014-02-13 14:15:19+00:00)
Title: Filter out path parameters if parameter is not in path

Example:
```ruby
# config/routes.rb
resources :users

resources :teams do
resources :users
end

# app/controllers/users_controller.rb
swagger_api :index do
param :path, :team_id, :integer, :optional, 'List users only by this team'
end
def index
@users = User.all
@users = @users.where(team_id: params[:team_id]) if params[:team_id].present?
respond_with(@users)
end
```

_swagger-docs_ currently generates the ``team_id`` parameter for both ``/users`` and ``/team/:team_id/users``. According to the [Swagger Documentation](https://github.com/wordnik/swagger-core/wiki/Parameters), a path parameter
> must correspond to the associated path segment from the path field in the api object

This PR filters out path parameters when the parameter is not present in the API endpoint. In the example above, _swagger-docs_ would then only generate the ``team_id`` parameter for ``/team/:team_id/users``