apiaryio / api-blueprint

API Blueprint
https://apiblueprint.org
MIT License
8.63k stars 2.14k forks source link

Allow relative URIs #451

Open alexkreidler opened 4 years ago

alexkreidler commented 4 years ago

Right now, if I want to add a nested action to a resource, I need to do this:

## Apples [/apples]
### Get all apples [GET]
+ Response 200 (application/json)
    + Attributes (Apple)

### Pick another apple [GET /apples/pick]
+ Response 200 (application/json)
    + Attributes (Apple)

But I would like to do the following:

### Pick another apple [GET ./pick]

Which would generate the following actions: GET /apples and GET /apples/pick. I think a lot of people could find these relative URIs quite useful.

I recognize you would probably only want to allow URIs that are children/sub-paths of the resource group b/c otherwise it could get confusing, but I think this format of relative URLs makes a lot more sense for the resource-driven design that API Blueprint seems to be set on.

I don't really want to repeat the entire absolute URL if I am performing a specialized action on a deeply nested subresource.

Also, it seems a little counterintuitive that the spec allows for Action URIs which are not children of Resource URIs (e.g. I could have ## Pick Apples [GET /robot/picker/pick] underneath # Apples [/apples]). I guess there are use-cases for that as well.

I'd love thoughts on this. Also, thanks for making an awesome and flexible tool, my days of Swagger are done!