Skip to content

Commit

Permalink
Generate non-preferred APIs by default
Browse files Browse the repository at this point in the history
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 4759ffb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
8 changes: 6 additions & 2 deletions bin/generate-api
Expand Up @@ -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'
Expand All @@ -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
Expand Down
6 changes: 2 additions & 4 deletions script/generate
Expand Up @@ -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.