question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItĀ collects links to all the places you might be looking at while hunting down a tough bug.

And, if youā€™re still stuck at the end, weā€™re happy to hop on a call to see how we can help out.

Why don't host and basePath support path templating?

See original GitHub issue

The Swagger 2 schema says that neither host nor basePath support path templating. We probalby discussed this but I donā€™t remember the exact reason and it seems like a big limitation. Itā€™s common to have parameters in either the host or in the basePath. You can at least work around the basePath limitation with excessively long paths, but there is no workaround for parameter in a host. Swagger will force you to hardcode a value.

Real-world examples:

  • Host parameter:
    • Rackspace: https://{data_center}.servers.api.rackspacecloud.com/v2/{account_id}
    • Okta: https://{your_company}.okta.com/api/v1/apps/{app_id}
    • Zendesk: https://{subdomain}.zendesk.com/api/v2/organizations.json
  • basePath parameter
    • Apigee: https://api.enterprise.apigee.com/v1/organizations/{org_name}/apis
    • Heroku: https://api.heroku.com/apps/{app_id}/addons

I think the reason may have been just:

  • We didnā€™t have a plan for global parameters (though we do define available global parameters which is likely good enough, because using a parameter in a host or basePath template could imply or require a $ref to the parameter name)
  • We just didnā€™t have enough time to put together a sample and tests before Swagger 2 was released

Itā€™s also worth noting that neither host nor basePath are required, nor are they required to resolve to the actual API (e.g. you could set your host to example.com).

Iā€™m hoping to at least get support targeted for the next spec, if not an update to this spec clarifying that host/basePath templating is not required but may be supported by some projects.

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Reactions:4
  • Comments:34 (8 by maintainers)

github_iconTop GitHub Comments

3reactions
kmceacherncommented, Jun 17, 2016

šŸ‘ Weā€™d like to provide access to Swagger UI both via a reverse proxy and by directly connecting to the host.

1reaction
olebedevcommented, May 19, 2017

@webron, could you please give the link to it ^ ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

API Host and Base Path - Swagger
REST APIs have a base URL to which the endpoint paths are appended. The base URL is defined by schemes , host and...
Read more >
Why does the Swagger 2.0 specifications allow basePath to ...
If it is not included, the API is served directly under the host. The value MUST start ... The basePath does not support...
Read more >
Understanding Path Templating - API Gateway - Google Cloud
Within API Gateway, it is possible to route incoming requests based on path templating. Path templating has three main components:.
Read more >
Set the OpenAPIbasePath property - Amazon API Gateway
If the API doesn't contain any basePath variables, the Import API feature checks the server.url string to see if it contains a path...
Read more >
Multiple Site Manager template basepath - ExpressionEngine
Make sure that path exists and can be written to (permissions ). Your host might be able to assist here as well. #3...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found