Hi!
I have a question about packaging of API products related to how proxies are implemented. It’s about a potential conflict between a functional grouping (API Product) and a resource based grouping (API proxy).
It seems a good practice + in line with REST, to group operations in a proxy based on the concept of resources, e.g. implement all operations related to /products in one proxy, or all operations related to /users in another proxy.
API Products requirements
When defining an API Product the first step is to include all the proxies which contains the operations that should be part of the API Product. Let’s for example assume that the API Product should contain 2 operations from /users (which holds a total of 10 operations), and 4 operations from /products (which holds a total of 15 operations).
Point being made: an API Product needs to contain/expose a subset of operations implemented in different proxies.
A constrain when defining products is that the base-path is defined as the path component that uniquely identifies the API proxy - hence the base-path must always be unique.
Setting up API proxy
When building a proxy, it’s required to find out a unique base-path for my proxy. Let’s say it is: domain-X/users.
Now I want to implement support for getting a list of all users, i.e. GET /users
Next is to decide how the call should be routed internally in the proxy. Let´s assume I set the match to be “/users” within the proxy. To get a list of users I would call:
GET http://api.com/ domain-X/users/users
That´s a really ugly URL! A design requirement coming from REST, is that I want the path to look like this http://api.com/ domain-X/users hence I don´t want to introduce extra/additional levels in my API (e.g. GET /users/users).
Since “/users” already is part of my base-path, I need to route requests that doesn´t contain any further qualification (a part from the base-path) to the flow responsible for getting a list of users. So, in practise I want to get a list of users when I call URL + base-path.
API Product – practical example
So, I’ll add the “/users” and “/products” proxies in the API Product design section.
Now, let’s assume my API Product should contain operations GET /users and GET /products/{product-id}:
GET http://api.com/domain-X/users
GET http://api.com/domain-X/products/{product-id}
But I don´t want to expose any other operations implemented in neither the domain-X/users nor domain-X/products proxies.
The “resource path” restriction when designing an API Product only supports restriction at paths “within” the proxy (referred to as proxy path suffix) . Hence not possible to use a combination of base-path + path-suffix to qualify/determine the scope (what should be part of) the API Product.
The practical implications of this limitation is that if the resource path is set to “/”, the API consumer could access both GET /users and GET /products - the later which I don´t want to expose access to.
Is there is way to fully decouple API Product design from API proxy implementation?