Skip to content

pacificcoastaquarium/discovery_api_dart_client_generator

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

discovery_api_client_generator

Build Status

Description

Dart application to create Dart API Client Libraries based on discovery documents

Examples for how to use the generated client libraries can be found here: https://github.com/dart-gde/dart_api_client_examples

Usage

   generate.dart -a <API> -v <Version> -o <Directory> (to load from Google Discovery API)
or generate.dart -u <URL> -o <Directory> (to load discovery document from specified URL)
or generate.dart -i <File> -o <Directory> (to load discovery document from local file)
or generate.dart --all -o <Directory> (to create libraries for all Google APIs)

-a, --api          Short name of the Google API (plus, drive, ...)
-v, --version      Google API version (v1, v2, v1alpha, ...)
-i, --input        Local Discovery document file
-u, --url          URL of a Discovery document
-p, --prefix       Prefix for library name (defaults to "google")
    --all          Create client libraries for all Google APIs
-o, --output       Output Directory

    --date         Create sub folder with current date (otherwise files might be overwritten)
    --check        Check for changes against existing version if available
    --force        Force client version update even if no changes

-h, --help         Display this information and exit

Clone dart-gde/discovery_api_dart_client_generator

git clone https://github.com/dart-gde/discovery_api_dart_client_generator
cd discovery_api_dart_client_generator
pub install

Generate your client library

URL='https://my-app-id.appspot.com/_ah/api/discovery/v1/apis/greeting/v1/rest'
curl -s -o greetings.rpc.discovery $URL
bin/generate.dart --no-prefix -i greetings.rpc.discovery -o ../

N.B. At present, you can't map your endpoint URL to a custom domain. Bossylobster wrote: "It's a non-trivial networking problem and something Google certainly plan on supporting in the future. Keep in mind, Cloud Endpoints is a combination or App Engine and Google's API Infrastructure."

Now you just have to add your endpoints client library to your dart application (assuming it is in the parent directory.)

cd ../my-app_dart/
cat >>pubspec.yaml <<EOF
  my-app-id_v1_api:
  path: ../dart_my-app-id_v1_api_client
EOF

About

Create API Client libraries based on the API's Discovery documentation

Resources

License

Stars

Watchers

Forks

Packages

No packages published