rspec_api_documentation icon indicating copy to clipboard operation
rspec_api_documentation copied to clipboard

Prefix for request paths

Open kylemacey opened this issue 9 years ago • 2 comments

We use an API that is connected to by specifying a version in the path /api/v1/users.

I'd like to simplify the way the documentation is generated, making it look a little cleaner by not always including api/v1 in each header. We can document how to specify a version in the root of the documentation

For example, I want to be able to write my tests like this:

get "/api/v1/users" do

But generate documentation that looks like this:

image

Maybe in the resource declaration, I could do

resource "Users", prefix: "/api/v1" do

Maybe even then, we could still use the shorthand for the requests?

resource "Users", prefix: "/api/v1" do
  get "/users" do

I'm not sure which makes more sense, or if there's already a way to do something like this.

kylemacey avatar Dec 05 '16 22:12 kylemacey

I think the following would make sense.

get "/api/v1/users", name: "/users" do
  # ...
end

After https://github.com/zipmark/rspec_api_documentation/pull/313 is merged, you'll be able to do:

get "/users", route_uri: "/api/v1/users" do
  # ...
end

kurko avatar Dec 06 '16 16:12 kurko

I see #313 was merged, but I tried using route_uri (and name) and neither is working. Is there a way to rename an API path?

JakeDluhy avatar Jul 25 '19 21:07 JakeDluhy