How are dart generated libraries generated? - dart

When working with dart, you stumble upon a few generated libraries. There is a whole GitHub group with a collections of those: https://github.com/dart-google-apis
I have not yet figured out how these libraries are generated? Are they compiled from another language? Which language? And which compiler is used?

Most of Google's external APIs are described in JSON document by an API called the Discovery Service. The document is called the discovery document and provides enough information to generate a client API that can represent the APIs resources as objects and can connect over HTTP to make calls. The Dart libraries you linked to were generated this way.
You can read about the Discovery Service here: https://developers.google.com/discovery/v1/using
And the generator that those libraries used is here: https://github.com/dart-gde/discovery_api_dart_client_generator

Related

What is Swagger, Swashbuckle and Swashbuckle UI

This is my understanding:
Swagger is a notation/rules to write documentation. But why is it called a framework (like Angular/MVC)?
Swashbuckle is a program (JavaScript?) that generates the documentation (based on Swagger rules).
Swagger UI displays the documentation. It uses Swashbuckle to do this.
Is this information correct? If not can someone explain in simple terms what Swagger, Swashbuckle, and Swashbuckle UI mean?
Also, what do I lose as an API developer if I do not use this?
Swagger is a notation/rules to write documentation. But why is it called a framework(Like angular/MVC)?
It is probably called a "framework" because its' purpose is to offer a systematic way of notating the interface of any RESTful service under the OpenAPI Specification. This is a big deal to developers because the spec is overseen by the Open API Initiative under the reputable Linux Foundation.
Swashbuckle is a program(javascript ?) that generates the documentation(based on Swagger rules)
Swashbuckle is more of a package (or a library) that you can make use of in your .NET Web API projects. It's purpose, as you have correctly indicated, is to generate the Swagger spec for your project. Additionally, the Swagger UI is contained within Swashbuckle so if you are developing an API in .NET it's really a nice one-stop shop of a package. It is almost entirely written in C#, not JavaScript.
Swagger UI displays the documentation. It uses Swashbuckle to do this.
Yes, it does display the Swagger spec in a nice, human-friendly manner. However, Swashbuckle is not a necessary component for this. They are, aside from what I just said previously, completely mutually-exclusive.
Also what do I lose as an API developer, if I do not use this.
This is now entering into the realm of opinion but I'll try to be objective about it. I use Swashbuckle to assist in the creation of clients for my application APIs. After getting past the implementation learning curve (which wasn't much), this package has saved me quite a bit of time of writing the clients myself. Writing a web client is a trivial thing for small applications but enterprise-level applications have a tendency to keep growing and/or changing in complexity so it is nice to have the creation/updating of these clients completely automated.
In short, if you decide not to use it you must either resort on an alternative method of API client generation or write/update the clients yourself. If you are only developing the back end this may be completely pointless to you but it would certainly help whoever is responsible for creating the client apps that will consume your API services.
I hope these answers have been helpful. Cheers!

Why does Play only provides support for OAuth 1.0?

Aim: to authenticate to a Scala Play Framework using Google
Attempt
According to this documentation:
Version 2 is simple enough to be implemented easily without library or
helpers, so Play only provides support for OAuth 1.0.
Discussion
This and another example were found, but it seems that some classes need to be copied. I am looking for a library that can be imported and called in the classes. I do not want to copy code. According to the documentation Version 2 is simple enough to be implemented easily without library or helpers, but were could an example be found? Why does Play only provides support for OAuth 1.0?
You can use 3rd part libraries.
I prefer pac4j, it's easy to configure and use. You can use both scala and java, and you can use it in a lot of java frameworks, like Spring.
You can find other authentification libraries as well:
Authentication (Login & Registration) and Authorization (Restricted Access)

Using JS Interop from Dart server

I am trying to create a Dart server that watches a Firebase path. There is a Firebase package in Pub, it is a wrapper for the Javascript library. The instructions for installing the library say:
The firebase.js library MUST be included for the wrapper to work:
I can see how this would work with a client-side Dart application, but how can I use the Firebase Javascript library from a Dart server?
The library you reference (firebase.dart) is purely for client-side usage. For server-side usage, Firebase offers a REST API. There are helper libraries for many languages, but not for Dart as far as I know. As it's REST, it seems to be very easy to interact with Firebase endpoints to get and put data.
You'll want to set up an HttpServer, of course, and then it's a matter of interacting with the Firebase endpoints using http.put and http.read.
Firebase's server-side streaming support via its REST API seems more involved. There doesn't seem to be many Dart folks using Firebase, certainly not the server-side stuff, and so you'll just have to work through getting your server to interact as the docs explain.
(If I get to that point myself, I'll report back and share my code, though all I care to do at the moment on the server is save some data from a Facebook authentication callback URL which my server reads in. Everything else Firebase is on the client side for me.)

iOS App and youtube client

Time ago I searched informations about the integration of youtube into an ios application.
Now I need to do this again so I started looking for information on google.
After a short time are already confused.
Can I use this iOS youtube sample
or have I to use YouTube Data API (v3)?
And this?
Short answer:
The API refers to the HTTP interface for consuming Google's funcionality.
One can use these APIs by issuing HTTP requests directly, according to the
specification of the API, or by using one of the client libraries. The client libraries are a layer on top of HTTP that issue the HTTP requests and parse the responses. They give a simpler interface for invoking the API (e.g. using standard function calls in the given programming language rather than building HTTP requests) and they also simplify a lot of the complex parts such as authentication, refreshing tokens, etc.
Long answer:
An application programming interface or API is the "contract" between a provider of some functionality and the consumer of some functionality that allows both the provider and consumer of that functionality to interoperate without knowledge of the underlying implementation of the other party. This "contract" includes such things as the number and types of the inputs, the names of the inputs (if it is required to invoke the functionality), any constraints on the inputs, the expected outputs, any constraints on the outputs, failure modes, etc.
Google provides a number of HTTP-based APIs for accessing functionality from its services. Its services implement these APIs, which are consumed by issuing HTTP requests and reading the HTTP responses. HTTP is a convenient protocol to implement, because every device and language can speak HTTP; however, it is not always the most convenient to use as a developer. In many cases, the inputs and outputs you want are objects, not HTTP requests and HTTP responses. And, in many cases, matching function signatures in the language of your choosing and type-checking of inputs is more convenient than memorizing the HTTP request paths or manually serializing/deserializing your objects to HTTP requests or content sent within the request. That is where the client libraries come in. Whereas the HTTP APIs are implemented on Google's servers, the client libraries are libraries that developers include in their application and are distributed to the devices on which those applications run. The client libraries issue the HTTP requests and interpret the responses, and provide a more convenient programming language-specific wrapper, for a variety of different programming languages.
The data API link that you provided is documenting the HTTP-based API. Whereas the sample application is using the client library (which is invoking the HTTP-based API under the hood). The last link you provided, the cloud endpoints for iOS is unrelated to what you are trying to do; it is documenting a mechanism called Cloud Endpoints, a feature of App Engine, that allows developers to create their own HTTP APIs using Google's infrastructure and to auto-generate client libraries that wrap these HTTP APIs (much as Google auto-generates the client libraries for its own HTTP APIs).
Here's a sample app you can get started to build YouTube APIs on iOS.
Also there is an helper library to play YT videos in iOS.

Any working Twitter API client for Common Lisp?

I was just trying to use cl-twitter, installed it first using quicklisp and I got this error when executing examples from its documentation:
The function TWITTER:AUTHENTICATE-USER is undefined.
Is this software up to date? Or it's just that the documentation is not? Are there any other working Common Lisp libs for Twitter API?
I cannot offer a full client library, but for the authentication part of it, cl-oauth works well. See this piece of code for a usage example.

Resources