Support for path params
coryodaniel opened this issue · comments
Cory O'Daniel commented
It would be nice to have "path_params" that were a part of the request, that would be interpolated before the request was fired, instead of having to do it manually in the test.
Currently:
test "[GET] /pets/{id} (200)" do
pet = %Pet{name: "Chauncy", type: "cat"} |> Repo.insert!
transaction = @swagger
|> Apocryphal.Transaction.get("/pets/{id}", 200, @mime)
path = Regex.replace(~r/{id}/, transaction.request.uri, "#{pet.id}")
transaction
|> put_in([:request, :uri], path)
|> assert_schema
end
Proposed:
test "[GET] /pets/{id} (200)" do
pet = %Pet{name: "Chauncy", type: "cat"} |> Repo.insert!
@swagger
|> Apocryphal.Transaction.get("/pets/{id}", 200, @mime)
|> put_in([:request, :path_params], %{"id" => pet.id})
|> assert_schema
end