api-blueprint icon indicating copy to clipboard operation
api-blueprint copied to clipboard

Multiple hosts or subdomains

Open pareeohnos opened this issue 10 years ago • 29 comments

I was wondering if it's currently possible to document an API where requests can come in from different subdomains, but this subdomain changes the endpoints that are available?

As an example, users can either be organisation, or office users. Each organisation and office has it's own subdomain. If I request things as an organisation, I want only certain office related endpoints to be made available. If I make requests through an office subdomain, then the rest of the API opens up.

How would I model this with API-Blueprint?

pareeohnos avatar Sep 16 '14 07:09 pareeohnos

Hey @pareeohnos, this seems like a task for an authentication / scoping and as such is probably best to resort to some sort of authentication (most likely header-based).

If I understand you correctly you have two sets of endpoints nested under different subdomains and their availability and / or content varies based on the subdomain? I am not sure how do you want to handle this without authentication (scopes), but if that is the case I would suggest to split such an API into two blueprints based on the subdomain.

Also sorry for the late reply – best if you post your questions regarding writing blueprints (and best practices) directly at Stack Overflow using the apiblueprint tag.

zdne avatar Oct 01 '14 19:10 zdne

The API itself will handle the scoping, i just wasn't sure if there was a way of handling subdomains within the API Blueprint. A future feature perhaps? :P

You understand correctly. The API is going to determine which response to provide based on what resource that subdomain belongs to. The authentication will be handled the same regardless (probably a token in the header) but the scope will be determined by the subdomain.

Are there any plans in the long run to support subdomains? This could be quite handy for other uses cases as well I think. Perhaps other may agree?

No worries, should've gone to stackoverflow but thought I'd suggest it as a feature at the same time as asking for help :)

pareeohnos avatar Oct 01 '14 20:10 pareeohnos

Are there any plans in the long run to support subdomains

Technically both HOST and FORMAT metadata are Apiary - specific. We plan to look at the HOST metadata and possibly split it into multiple components and / or move it completely in some sort of settings in Apiary (so the subdomain won't be specified in the blueprint at all).

The components can be used schemas, base URLs, CORS whitelists etc. The conceptual question is whether this is belongs to API Blueprint itself (as an API description format) or is it some sort of tooling specific metadata...

zdne avatar Oct 29 '14 14:10 zdne

:+1:

esbanarango avatar Nov 12 '14 20:11 esbanarango

I guess it would depend on how common it is to make use of a subdomain that changes the response. If it were to be part of a tools metadata, then the user would be dependent on a tool that allowed them to use this. I can't see there being a large number of API's that would require this, but even in a simpler scenario than my own, you may wish to show a different API response to a single endpoint based purely on the subdomain. If for example each user is given a subdomain of their own, if user A tried to access resource A, it should return a response, but if they try accessing resource B it should fail:

GET usera.domain.com/resources/resource-a
    200 OK

GET userb.domain.com/resources/resource-a
    403 FORBIDDEN

Without this subdomain specification, it would not be possible to accurately document this. It would only be possible to specify the different responses that it might return, but it would not show that the error response is directly linked to the subdomain of that request. That said, I'm not sure how one would clearly show the link with the subdomain.

pareeohnos avatar Nov 17 '14 09:11 pareeohnos

I'm currently working with an API that sits on multiple subdomains as well, and would be interested to see where this goes.

carpeliam avatar May 26 '15 16:05 carpeliam

:+1: subscribing

moul avatar Sep 24 '15 15:09 moul

:+1:

QuentinPerez avatar Oct 14 '15 13:10 QuentinPerez

+1 - we have multiple domains/white label websites running the same docs

jrutter avatar Apr 12 '16 16:04 jrutter

We need the ability to have a subdomain in the host which Apiary does not support.

Something like Http://{subdomain}.salesforce.com

Without this ability Apiary is of no use to us.

Very disappointing as i can pass in variable to set a folder off the end of the post but i cant pass in a variable for a subdomain into the host.

So close yet may as well be miles off target.

FYI anyone writing API's to work with Salesforce will also have this requirement.

rgilbody avatar Apr 19 '16 11:04 rgilbody

@rgilbody Thanks for the feedback.

pksunkara avatar Apr 19 '16 11:04 pksunkara

was hoping this would work


FORMAT: 1A HOST: https:

POST [//{subdoimain}.secure.force.com/services/apexrest/]

Parameters subdoimain


But when i publish it i get https:////subdomain.secure.force.com/services/apexrest/

rgilbody avatar Apr 19 '16 12:04 rgilbody

Also tried this


FORMAT: 1A HOST: https:/

POST [/{subdoimain}.secure.force.com/services/apexrest/]

Parameters subdoimain


But when i publish it i get https:///subdomain.secure.force.com/services/apexrest/

Also tried this but it is not a valid Post line


FORMAT: 1A HOST: https://

POST [{subdoimain}.secure.force.com/services/apexrest/]

Parameters subdoimain


rgilbody avatar Apr 19 '16 12:04 rgilbody

I just want to be able to do this and have the parameter in the Host and not the Post.


FORMAT: 1A HOST: https://{subdoimain}.secure.force.com

POST [/services/apexrest/]

Parameters subdoimain


rgilbody avatar Apr 19 '16 12:04 rgilbody

+1

talkoren avatar Nov 16 '16 07:11 talkoren

I vote for this feature too.

It will be great to have actions in blueprint doc that have different domains. We maintain two blueprint docs for two domains (one.domain.com and two.domain.com). But it can be merged. For us it would be prefered way.

bovin-a avatar Dec 02 '16 09:12 bovin-a

any update about this issue?

pararang avatar Feb 20 '17 03:02 pararang

any update on this issue? I need to have sub-domains in my API

katkinso avatar Nov 03 '17 20:11 katkinso

+1

alexanderscott avatar Nov 07 '17 03:11 alexanderscott

-1 I gave up 😝

paulld avatar Nov 07 '17 03:11 paulld

+1

tatiana-perry avatar Feb 20 '18 17:02 tatiana-perry

Did anyone figure out a workaround?

ronenteva avatar Mar 15 '18 07:03 ronenteva

+1

ilizunov avatar Apr 13 '18 15:04 ilizunov

+1

ZilvinasKucinskas avatar Jun 03 '19 17:06 ZilvinasKucinskas

+1

PurpleTheBest avatar Apr 06 '20 17:04 PurpleTheBest

Many API tools support multiple environments. I can use multiple variables as multiple hosts in the url and when i switch to different environment, the variables will change to different host. Is there any way to support the same feature?

shenhaofang avatar May 07 '20 04:05 shenhaofang

Is there any progress?

vojkny avatar Jul 09 '20 08:07 vojkny

from 5 years ago

I just want to be able to do this and have the parameter in the Host and not the Post.

FORMAT: 1A HOST: https://{subdoimain}.secure.force.com

POST [/services/apexrest/]

Parameters subdoimain

Any update?

rgilbody avatar Jan 12 '21 10:01 rgilbody

+1

Famin42 avatar Aug 15 '22 08:08 Famin42