Comments (6)
Disclaimer: I'm the author of tesla
BaseUrlFromConfig middleware was removed because it is not needed, you can achieve the same thing using:
plug Tesla.Middleware.BaseUrl, fetch_base_url_however_you_like()
# or
plug Tesla.Middleware.BaseUrl, Application.get_env(:google, :base_uri)
Middleware arguments are evaluated at runtime so everything will work just fine.
from elixir-google-api.
**Ok, NM. Just discovered swagger codegen, and it looks like this wasn't your decision to make. **
FWIW, Tesla, like Faraday that it's based on, introduced a ton of complexity for what looked like very little value. I can see where the idea came from, since just about all web frameworks do the same thing, but for an API client, there's really just 3 concerns. Where it's going, how it's secured, and how to format the data you need to send. A pipeline model is simply overkill.
Obviously I shouldn't really care what the underlying tech is here, and perhaps with this swagger code generator you have there's something it adds. But if not, I'd personally consider dropping it in favor of using the HTTPoison.Base macro instead. Short of that, it looks like tesla needs to be flexible enough to take it's various plug parameters as function definitions, and invoke them at runtime to allow things to be configurable.
from elixir-google-api.
@teamon - I did that in my fork of the mustache templates, and it works very well, even closer to the initial intent of the author?! That of using a package specific env var. In my fork:
Tesla.build_client([
{Tesla.Middleware.BaseUrl, env_base_url()},
{Tesla.Middleware.Headers, [{"Authorization", "Bearer #{token}"}]}
])
where the env_base_url
is as simple as this:
defp env_base_url() do
Application.get_env(:{{#underscored}}{{packageName}}{{/underscored}}, :url, "{{{basePath}}}")
end
@chingor13 - please observe the use of packageName
rather than the appName
, as the latter will result in something like: :google_cloud_pub/sub_api
, an invalid Elixir Atom, of course.
from elixir-google-api.
We just released new versions of the client libraries which includes the fix from #81
from elixir-google-api.
Thanks, for the report.
It looks like BaseUrlFromConfig is being removed from Tesla so we'll need to find a different approach to allow configuring the base url.
from elixir-google-api.
So yes, these libraries are all generated via Swagger Codegen. We do maintain our own templates here, so it's possible to swap out Tesla. Originally we picked Tesla because of multipart http posts and the ease of building requests.
We do have a goal to try and create a shared core library which could encapsulate the transport and try and simplify the generated code (and allow better configuration). We could either switch to HTTPoison or provide an equivalent BaseUrlFromConfig implementation.
Alternatively, we can look to simply swap out the middleware if we're ok locking the 0.x (the middleware is being removed in 1.0), but it could conflict in the future.
from elixir-google-api.
Related Issues (20)
- WigWamWoodys HOT 1
- The task "google_apis.auth" could not be found HOT 3
- elixir-google-api broke with latest gcloud pub/sub emulator 0.7.1
- Speech: support v1p1beta1 HOT 2
- The Hex Docs are not being built HOT 2
- STOP GENERATING THOUSANDS OF MODULES!!! HOT 7
- Recommend configuration of Tesla adapter in README
- Copying Object in GCS
- Retail version does not match the doc HOT 5
- google_api_play_integrity package is not available on hex.pm HOT 1
- Version 0.25.0 of `dfa_reporting` is missing on hex.pm
- Synthesis failed for CloudIot HOT 1
- Is this still being maintained? HOT 1
- Synthesis failed for IDS HOT 33
- Is the new Google Identity's API available in this library? HOT 1
- GoogleCloudMlV1_PredictRequest Mount Wrong URL HOT 1
- Empty API References Page for v0.16.1 release for Google API {Spanner, Notebooks, Manufacturers} HOT 1
- Synthesis failed for Transcoder HOT 10
- is batch uploads supported? HOT 1
- dfareporting v4 has been released HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from elixir-google-api.