Skip to content
Permalink
Browse files

Generate non-preferred APIs by default

Warn instead of failing on Discovery URL requests that error. Some
URLs on the Discovery index return 404s, so skipping them saves trouble.
  • Loading branch information...
googleapis-publisher authored and saicheems committed Aug 25, 2017
1 parent f93e0a0 commit 4759ffb5ddfe1c24dfc16859c00483bc1d3a4e57
Showing with 8 additions and 6 deletions.
  1. +6 −2 bin/generate-api
  2. +2 −4 script/generate
@@ -28,7 +28,6 @@ module Google
desc 'gen OUTDIR', 'Generate ruby API from an API description'
method_options url: :array, file: :array, from_discovery: :boolean, preferred_only: :boolean,
verbose: :boolean, names: :string, names_out: :string
method_option :preferred_only, default: true
def gen(dir)
ensure_active_support
require 'google/apis/generator'
@@ -55,7 +54,12 @@ module Google
no_commands do
def generate_from_url(urls)
Array(urls).each do |url|
json = discovery.http(:get, url)
begin
json = discovery.http(:get, url)
rescue Google::Apis::ClientError
warn sprintf('Failed request, skipping %s', url)
next
end
generate_api(json)
end
end
@@ -8,9 +8,7 @@ URLS=(https://content.googleapis.com/discovery/v1/apis/appsmarket/v2/rest \
https://content.googleapis.com/discovery/v1/apis/youtubePartner/v1/rest \
https://content.googleapis.com/discovery/v1/apis/compute/beta/rest \
https://developers.google.com/my-business/samples/mybusiness_google_rest_v3.json \
https://monitoring.googleapis.com/\$discovery/rest?version=v3 \
https://www.googleapis.com/discovery/v1/apis/admin/datatransfer_v1/rest \
https://www.googleapis.com/discovery/v1/apis/admin/directory_v1/rest
https://monitoring.googleapis.com/\$discovery/rest?version=v3
)

echo 'a' | bundle exec bin/generate-api gen generated --from_discovery=true --names_out=$DIR/api_names_out.yaml --url=${URLS[*]}
echo 'a' | bundle exec bin/generate-api gen generated --from-discovery --no-preferred-only --names-out=$DIR/api_names_out.yaml --url=${URLS[*]}

0 comments on commit 4759ffb

Please sign in to comment.
You can’t perform that action at this time.