Git Product home page Git Product logo

google / apis-client-generator Goto Github PK

View Code? Open in Web Editor NEW
161.0 15.0 63.0 1.1 MB

The Google APIs Client Generator is a tool for generating client libraries for APIs based on the Google API Discovery format. It is based on the same core technology Google uses to publish their API libraries. Current support is for C++, C#/.NET, Dart, Java, Java/GWT, and PHP.

License: Apache License 2.0

Shell 0.09% Python 99.91%

apis-client-generator's Introduction

#  Copyright 2011 Google, Inc.
#
#  Licensed under the Apache License, Version 2.0 (the "License");
#  you may not use this file except in compliance with the License.
#  You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
#  Unless required by applicable law or agreed to in writing, software
#  distributed under the License is distributed on an "AS IS" BASIS,
#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#  See the License for the specific language governing permissions and
#  limitations under the License.

Google APIs Code Generator
https://github.com/google/apis-client-generator/

January 29, 2019

Introduction

  This is a tool for generating client libraries from Google APIs Discovery
  documents. It builds a rich (but language neutral) model of the API and
  then invokes a language specific backend to emit the library. The language
  generators are template driven, so it is easy for a developer knowning
  language X to write templates for code in X, without having to learn much
  Python.

  The generator currently has templates for Java, C++, CSharp, GWT, PHP
  and Dart.  There may be multiple variations of each language. For each,
  the variant used by default (typically also named "default") matches the
  head of the respective base client libraries.


Warning:
  This project is maintained as a volunteer effort. There is no full time
  staffing.


Installation

Python 2.7 is required.  Python3 is not supported.

Everything can be installed quickly with easy_install or pip. E.g.:

  pip install google-apis-client-generator

The following dependencies will be installed:

  * django - https://www.djangoproject.com/
    - version 1.8
    - we only use the templating package, not the web serving features.
  * google-apputils - https://github.com/google/google-apputils/
  * google-api-python-client - https://github.com/google/google-api-python-client
  * python-gflags - https://github.com/google/python-gflags/
  * httplib2 - https://github.com/httplib2/httplib2/


Usage

To run the library generator, use the "generate_library" script.  This is
normally what you'd want to do.  E.g.:

  generate_library \
    --input=src/googleapis/codegen/testdata/moderator.v1.json \
    --language=java \
    --output_dir=/tmp/generated

To expand arbitrary templates, the "expand_templates" script is also available:

  expand_templates \
    --discovery=src/googleapis/codegen/testdata/moderator.v1.json \
    --language=any --templates=discovery_check \
    --output_dir=/tmp/generated


Contact

  Tony Aiuto ([email protected])
  Jacob Smullyan ([email protected])

apis-client-generator's People

Contributors

aiuto avatar nivs avatar surferjeffatgoogle avatar yihanzhen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

apis-client-generator's Issues

Allow Django version above > 1.11.19

Hello,

I got a Github security alert in a project related to the Django version : https://nvd.nist.gov/vuln/detail/CVE-2019-6975

Unfortunately, this library relies on a version <1.9.0dev which is impacted by this alert. Could you update the Django version ?

This is annoying in particular for pipenv users who cannot lock their Pipfile for production:

ResolutionFailure: ERROR: ERROR: Could not find a version that matches django<1.9.0dev,==1.11.20,>=1.4.0

Generated Java model class misses toString()

Hope this is the right place to post. I'm generating the Java App Engine backend client libraries in Android Studio with your latest SDK/Plugin. The Object generated says: "This code was generated by https://github.com/google/apis-client-generator/

  • (build: 2015-11-16 19:10:01 UTC)"

The backend source is very simple, simplified it event more :

@entity
public class Event {

@id
@GeneratedValue(strategy=GenerationType.IDENTITY)

private String eventName;

@OverRide
public String toString(){
return eventName;
}

However, in the file "generated-source" > "eventendpoint" > "model" > "Event.java"
the function toString() does not exist. Calling it on the Object calls of course Object.toString().
Is there any other explanation to this, other then a defect ?

API clients or Rust

First of all, I must apologize to use the bug-tracker as means to get in touch 
with the team. If I am missing the obvious here, I'd be glad if you could point 
me in the right direction, similar to what Ian on the golang nuts group 
(https://groups.google.com/forum/#!topic/golang-nuts/mGstIuQhaco) has done.

As I am currently implementing the Google API for Rust 
(https://github.com/Byron/google-apis-rs), I was wondering what your policy is 
for that. After all, it seems all APIs so far have been provided by Google 
itself, and you might have plans for Rust as well that I don't know about.
The main issue here is that I could take crate names on crates.io that you 
might intend to use later. Once a name has been taken, there is currently no 
way to remove it or change ownership, so I'd love to coordinate this with you 
(Google) before I create a mess.

There is also a related post on Reddit to discuss the matter with the Rust 
community 
(https://www.reddit.com/r/rust/comments/2yxjbp/rfc_google_rust_client_apis/).

Thank you,
Sebastian

Original issue reported on code.google.com by [email protected] on 13 Mar 2015 at 9:06

PSR compliance PHP client generator

Hi guys,

Although I really like the possibilities of this library I must admit that the generated source code is severely outdated. At least for the PHP part. Are there plans to start using namespaces and generate code that complies to the PSR coding guidelines? I don't mind to contribute.

Kind regards,
Daan

AttributeError: 'module' object has no attribute 'add_to_builtins'

After installing via pip (python 2.7.6) I keep getting this error

generate_library --input=drumroll.v1.json --language=java --output_dir=/test

Traceback (most recent call last):
File "/usr/local/bin/generate_library", line 9, in
load_entry_point('google-apis-client-generator==1.4.2', 'console_scripts', 'generate_library')()
File "/Library/Python/2.7/site-packages/googleapis/codegen/script_stubs.py", line 9, in RunGenerateLibrary
from googleapis.codegen import generate_library
File "/Library/Python/2.7/site-packages/googleapis/codegen/generate_library.py", line 35, in
from googleapis.codegen import generator_lookup
File "/Library/Python/2.7/site-packages/googleapis/codegen/generator_lookup.py", line 10, in
from googleapis.codegen import csharp_generator
File "/Library/Python/2.7/site-packages/googleapis/codegen/csharp_generator.py", line 23, in
from googleapis.codegen import api
File "/Library/Python/2.7/site-packages/googleapis/codegen/api.py", line 39, in
from googleapis.codegen import data_types
File "/Library/Python/2.7/site-packages/googleapis/codegen/data_types.py", line 24, in
from googleapis.codegen import template_objects
File "/Library/Python/2.7/site-packages/googleapis/codegen/template_objects.py", line 27, in
from googleapis.codegen.django_helpers import MarkSafe
File "/Library/Python/2.7/site-packages/googleapis/codegen/django_helpers.py", line 50, in
django_template.add_to_builtins(
AttributeError: 'module' object has no attribute 'add_to_builtins'

Unable to locally deploy generated Java client with Maven

I used the following commands:

> cd ~
> virtualenv test
> cd test
> source bin/activate
> pip install google-apis-client-generator
> curl -o discovery.json "https://monitoring.googleapis.com/\$discovery/rest?version=v3"
> generate_library --input=discovery.json --language=java --output_dir=monitoring-client-library
> mkdir repo
> cd monitoring-client-library
> mvn deploy -DaltDeploymentRepository=snapshot-repo::default::file:///$HOME/test/repo/

The error I get is
[ERROR] Failed to execute goal on project google-api-services-monitoring: Could not resolve dependencies for project com.google.apis:google-api-services-monitoring:jar:v3-rev20171115-1.22.0-SNAPSHOT: Failure to find com.google.api-client:google-api-client:jar:1.22.0-SNAPSHOT in https://oss.sonatype.org/content/repositories/snapshots was cached in the local repos

The Nexus repo manager only has 1.15-beta.

P.S. I'm new to Java and Maven so it's probable I just don't know what to modify in the generated pom.xml.

setting up Nexus 7

What steps will reproduce the problem?
1.
2.
3.

What is the expected output? What do you see instead?


What version of the product are you using? On what operating system?


Please provide any additional information below.


Original issue reported on code.google.com by [email protected] on 3 Jun 2014 at 4:43

Out of date php language variant templates

The releases page says they are up to 1.0.5-beta. 

https://github.com/google/google-api-php-client/releases

Are their any plans to update the templates to include this option?

Original issue reported on code.google.com by [email protected] on 11 Sep 2014 at 8:54

Cannot build generated Java library because of unpublished -SNAPSHOT dependencies

What steps will reproduce the problem?
1. sudo pip install google-apis-client-generator
2. generate a Java library for an API
3. mvn compile the generated code

What is the expected output? What do you see instead?

The build should work. The result is as follows:

[ERROR] Failed to execute goal on project api: Could not resolve dependencies 
for project com.strava:api:jar:v3-SNAPSHOT: Failure to find 
com.google.api-client:google-api-client:jar:1.17.0-rc-SNAPSHOT in 
https://oss.sonatype.org/content/repositories/snapshots was cached in the local 
repository, resolution will not be reattempted until the update interval of 
sonatype-nexus-snapshots has elapsed or updates are forced -> [Help 1]

What version of the product are you using? On what operating system?

This is happening using a fresh install of the client code generator on a clean 
machine.

Please provide any additional information below.

Original issue reported on code.google.com by [email protected] on 6 Nov 2013 at 10:34

Django AttributeError

Just ran pip install google-apis-client-generator then tried to run a couple commands for the generate_library command and got this traceback every time. Any suggestions?

Traceback (most recent call last):
  File "/usr/local/bin/generate_library", line 9, in <module>
    load_entry_point('google-apis-client-generator==1.4.2', 'console_scripts', 'generate_library')()
  File "/Library/Python/2.7/site-packages/googleapis/codegen/script_stubs.py", line 9, in RunGenerateLibrary
    from googleapis.codegen import generate_library
  File "/Library/Python/2.7/site-packages/googleapis/codegen/generate_library.py", line 35, in <module>
    from googleapis.codegen import generator_lookup
  File "/Library/Python/2.7/site-packages/googleapis/codegen/generator_lookup.py", line 10, in <module>
    from googleapis.codegen import csharp_generator
  File "/Library/Python/2.7/site-packages/googleapis/codegen/csharp_generator.py", line 23, in <module>
    from googleapis.codegen import api
  File "/Library/Python/2.7/site-packages/googleapis/codegen/api.py", line 39, in <module>
    from googleapis.codegen import data_types
  File "/Library/Python/2.7/site-packages/googleapis/codegen/data_types.py", line 24, in <module>
    from googleapis.codegen import template_objects
  File "/Library/Python/2.7/site-packages/googleapis/codegen/template_objects.py", line 27, in <module>
    from googleapis.codegen.django_helpers import MarkSafe
  File "/Library/Python/2.7/site-packages/googleapis/codegen/django_helpers.py", line 50, in <module>
    django_template.add_to_builtins(
AttributeError: 'module' object has no attribute 'add_to_builtins'

"google.apputils.app.Error: <not found>"

Am trying to generate a Dart client library. Here's my command. I get the same result when entering the URL of the discovery doc rather than --input=myapi.json:

generate_library --api_name= --api_version=v1 --language=dart --output_dir=lib --input=myapi.json

Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/googleapis/codegen/generate_library.py", line 230, in
app.run()
File "/usr/lib/python2.7/site-packages/google/apputils/app.py", line 238, in run
return _actual_start()
File "/usr/lib/python2.7/site-packages/google/apputils/app.py", line 267, in _actual_start
really_start()
File "/usr/lib/python2.7/site-packages/google/apputils/app.py", line 220, in really_start
sys.exit(main(argv))
File "/usr/lib/python2.7/site-packages/googleapis/codegen/generate_library.py", line 137, in main
content = GetApiDiscovery(FLAGS.api_name, FLAGS.api_version)
File "/usr/lib/python2.7/site-packages/googleapis/codegen/generate_library.py", line 225, in GetApiDiscovery
raise app.Error(error)
google.apputils.app.Error: {u'code': 404, u'message': u'Not Found', u'errors': [{u'domain': u'global', u'message': u'Not Found', u'reason': u'notFound'}]}
[/home/tom/work/dart/dart-sdk/discovery_api_dart_client_generator/bin] > dart --version
Dart VM version: 1.8.5 (Tue Jan 13 12:39:16 2015) on "linux_ia32"

Generating c++ fails.

rennie@rennie:~/gitrepos/google-api-cpp-client$ virtualenv env
New python executable in /usr/local/google/home/rennie/gitrepos/google-api-cpp-client/env/bin/python
Installing setuptools, pip, wheel...done.
rennie@rennie:~/gitrepos/google-api-cpp-client$ env/bin/pip install google-apis-client-generator
Collecting google-apis-client-generator
/usr/local/google/home/rennie/gitrepos/google-api-cpp-client/env/local/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:318: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#snimissingwarning.
  SNIMissingWarning
/usr/local/google/home/rennie/gitrepos/google-api-cpp-client/env/local/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
  Downloading google-apis-client-generator-1.4.2.tar.gz (279kB)
    100% |████████████████████████████████| 286kB 3.1MB/s 
�[?25hCollecting django (from google-apis-client-generator)
  Downloading Django-1.11.1-py2.py3-none-any.whl (6.9MB)
    100% |████████████████████████████████| 7.0MB 258kB/s 
�[?25hCollecting httplib2 (from google-apis-client-generator)
  Downloading httplib2-0.10.3.tar.gz (204kB)
    100% |████████████████████████████████| 204kB 6.1MB/s 
�[?25hCollecting google-apputils (from google-apis-client-generator)
  Downloading google-apputils-0.4.2.zip (101kB)
    100% |████████████████████████████████| 102kB 12.9MB/s 
�[?25hCollecting python-gflags (from google-apis-client-generator)
  Downloading python-gflags-3.1.1.tar.gz (52kB)
    100% |████████████████████████████████| 61kB 13.9MB/s 
�[?25hCollecting google-api-python-client (from google-apis-client-generator)
  Downloading google_api_python_client-1.6.2-py2.py3-none-any.whl (52kB)
    100% |████████████████████████████████| 61kB 14.3MB/s 
�[?25hCollecting pytz (from django->google-apis-client-generator)
  Downloading pytz-2017.2-py2.py3-none-any.whl (484kB)
    100% |████████████████████████████████| 491kB 3.4MB/s 
�[?25hCollecting python-dateutil>=1.4 (from google-apputils->google-apis-client-generator)
  Downloading python_dateutil-2.6.0-py2.py3-none-any.whl (194kB)
    100% |████████████████████████████████| 194kB 7.5MB/s 
�[?25hRequirement already satisfied: six<2dev,>=1.6.1 in ./env/lib/python2.7/site-packages (from google-api-python-client->google-apis-client-generator)
Collecting uritemplate<4dev,>=3.0.0 (from google-api-python-client->google-apis-client-generator)
  Downloading uritemplate-3.0.0-py2.py3-none-any.whl
Collecting oauth2client<5.0.0dev,>=1.5.0 (from google-api-python-client->google-apis-client-generator)
  Downloading oauth2client-4.0.0-py2.py3-none-any.whl (184kB)
    100% |████████████████████████████████| 194kB 5.7MB/s 
�[?25hCollecting rsa>=3.1.4 (from oauth2client<5.0.0dev,>=1.5.0->google-api-python-client->google-apis-client-generator)
  Using cached rsa-3.4.2-py2.py3-none-any.whl
Collecting pyasn1-modules>=0.0.5 (from oauth2client<5.0.0dev,>=1.5.0->google-api-python-client->google-apis-client-generator)
  Using cached pyasn1_modules-0.0.8-py2.py3-none-any.whl
Collecting pyasn1>=0.1.7 (from oauth2client<5.0.0dev,>=1.5.0->google-api-python-client->google-apis-client-generator)
  Downloading pyasn1-0.2.3-py2.py3-none-any.whl (53kB)
    100% |████████████████████████████████| 61kB 14.1MB/s 
�[?25hBuilding wheels for collected packages: google-apis-client-generator, httplib2, google-apputils, python-gflags
  Running setup.py bdist_wheel for google-apis-client-generator ... �[?25ldone
�[?25h  Stored in directory: /usr/local/google/home/rennie/.cache/pip/wheels/2d/08/6a/6b15dc90651bcca2d09abf126041d128f8a591b6e21d4eb656
  Running setup.py bdist_wheel for httplib2 ... �[?25ldone
�[?25h  Stored in directory: /usr/local/google/home/rennie/.cache/pip/wheels/ca/ac/5f/749651f7925b231103f5316cacca82a487810c22d30f011c0c
  Running setup.py bdist_wheel for google-apputils ... �[?25ldone
�[?25h  Stored in directory: /usr/local/google/home/rennie/.cache/pip/wheels/c2/c7/36/083b74a76ab1eeea8ebeb52c0ab118d455caec0607699c0eb8
  Running setup.py bdist_wheel for python-gflags ... �[?25ldone
�[?25h  Stored in directory: /usr/local/google/home/rennie/.cache/pip/wheels/f8/d5/b7/0647704d6fdd87819ff64008f883ff857c8340c6b122c17549
Successfully built google-apis-client-generator httplib2 google-apputils python-gflags
Installing collected packages: pytz, django, httplib2, python-dateutil, python-gflags, google-apputils, uritemplate, pyasn1, rsa, pyasn1-modules, oauth2client, google-api-python-client, google-apis-client-generator
Successfully installed django-1.11.1 google-api-python-client-1.6.2 google-apis-client-generator-1.4.2 google-apputils-0.4.2 httplib2-0.10.3 oauth2client-4.0.0 pyasn1-0.2.3 pyasn1-modules-0.0.8 python-dateutil-2.6.0 python-gflags-3.1.1 pytz-2017.2 rsa-3.4.2 uritemplate-3.0.0
rennie@rennie:~/gitrepos/google-api-cpp-client$ ls env/bin
activate          easy_install-2.7  pyrsa-decrypt          python
activate.csh      expand_templates  pyrsa-decrypt-bigfile  python2
activate.fish     generate_library  pyrsa-encrypt          python2.7
activate_this.py  gflags2man.py     pyrsa-encrypt-bigfile  python-config
django-admin      gflags2man.pyc    pyrsa-keygen           wheel
django-admin.py   pip               pyrsa-priv2pub
django-admin.pyc  pip2              pyrsa-sign
easy_install      pip2.7            pyrsa-verify
rennie@rennie:~/gitrepos/google-api-cpp-client$ ls
build           doxygenate.py   external_dependencies    README.txt
CMakeLists.txt  doxygen.config  introspect.cmake         service_apis
COPYING.txt     env             prepare_dependencies.py  src
rennie@rennie:~/gitrepos/google-api-cpp-client$ cd service_apis/
rennie@rennie:~/gitrepos/google-api-cpp-client/service_apis$ ls
calendar  CMakeLists.txt  drive  youtube
rennie@rennie:~/gitrepos/google-api-cpp-client/service_apis$ cd calendar/
rennie@rennie:~/gitrepos/google-api-cpp-client/service_apis/calendar$ ls
CMakeLists.txt  descriptor.json  google  LICENSE.txt  readme.html
rennie@rennie:~/gitrepos/google-api-cpp-client/service_apis/calendar$ ../../env/bin/generate_library --input=descriptor.json --language=cpp --output_dir=/tmp/generated
Traceback (most recent call last):
  File "../../env/bin/generate_library", line 11, in <module>
    sys.exit(RunGenerateLibrary())
  File "/usr/local/google/home/rennie/gitrepos/google-api-cpp-client/env/local/lib/python2.7/site-packages/googleapis/codegen/script_stubs.py", line 9, in RunGenerateLibrary
    from googleapis.codegen import generate_library
  File "/usr/local/google/home/rennie/gitrepos/google-api-cpp-client/env/local/lib/python2.7/site-packages/googleapis/codegen/generate_library.py", line 35, in <module>
    from googleapis.codegen import generator_lookup
  File "/usr/local/google/home/rennie/gitrepos/google-api-cpp-client/env/local/lib/python2.7/site-packages/googleapis/codegen/generator_lookup.py", line 10, in <module>
    from googleapis.codegen import csharp_generator
  File "/usr/local/google/home/rennie/gitrepos/google-api-cpp-client/env/local/lib/python2.7/site-packages/googleapis/codegen/csharp_generator.py", line 23, in <module>
    from googleapis.codegen import api
  File "/usr/local/google/home/rennie/gitrepos/google-api-cpp-client/env/local/lib/python2.7/site-packages/googleapis/codegen/api.py", line 39, in <module>
    from googleapis.codegen import data_types
  File "/usr/local/google/home/rennie/gitrepos/google-api-cpp-client/env/local/lib/python2.7/site-packages/googleapis/codegen/data_types.py", line 24, in <module>
    from googleapis.codegen import template_objects
  File "/usr/local/google/home/rennie/gitrepos/google-api-cpp-client/env/local/lib/python2.7/site-packages/googleapis/codegen/template_objects.py", line 27, in <module>
    from googleapis.codegen.django_helpers import MarkSafe
  File "/usr/local/google/home/rennie/gitrepos/google-api-cpp-client/env/local/lib/python2.7/site-packages/googleapis/codegen/django_helpers.py", line 50, in <module>
    django_template.add_to_builtins(
AttributeError: 'module' object has no attribute 'add_to_builtins'
rennie@rennie:~/gitrepos/google-api-cpp-client/service_apis/calendar$ ../../env/bin/generate_library --input=descriptor.json --language=c++ --output_dir=/tmp/generated
Traceback (most recent call last):
  File "../../env/bin/generate_library", line 11, in <module>
    sys.exit(RunGenerateLibrary())
  File "/usr/local/google/home/rennie/gitrepos/google-api-cpp-client/env/local/lib/python2.7/site-packages/googleapis/codegen/script_stubs.py", line 9, in RunGenerateLibrary
    from googleapis.codegen import generate_library
  File "/usr/local/google/home/rennie/gitrepos/google-api-cpp-client/env/local/lib/python2.7/site-packages/googleapis/codegen/generate_library.py", line 35, in <module>
    from googleapis.codegen import generator_lookup
  File "/usr/local/google/home/rennie/gitrepos/google-api-cpp-client/env/local/lib/python2.7/site-packages/googleapis/codegen/generator_lookup.py", line 10, in <module>
    from googleapis.codegen import csharp_generator
  File "/usr/local/google/home/rennie/gitrepos/google-api-cpp-client/env/local/lib/python2.7/site-packages/googleapis/codegen/csharp_generator.py", line 23, in <module>
    from googleapis.codegen import api
  File "/usr/local/google/home/rennie/gitrepos/google-api-cpp-client/env/local/lib/python2.7/site-packages/googleapis/codegen/api.py", line 39, in <module>
    from googleapis.codegen import data_types
  File "/usr/local/google/home/rennie/gitrepos/google-api-cpp-client/env/local/lib/python2.7/site-packages/googleapis/codegen/data_types.py", line 24, in <module>
    from googleapis.codegen import template_objects
  File "/usr/local/google/home/rennie/gitrepos/google-api-cpp-client/env/local/lib/python2.7/site-packages/googleapis/codegen/template_objects.py", line 27, in <module>
    from googleapis.codegen.django_helpers import MarkSafe
  File "/usr/local/google/home/rennie/gitrepos/google-api-cpp-client/env/local/lib/python2.7/site-packages/googleapis/codegen/django_helpers.py", line 50, in <module>
    django_template.add_to_builtins(
AttributeError: 'module' object has no attribute 'add_to_builtins'
rennie@rennie:~/gitrepos/google-api-cpp-client/service_apis/calendar$ 

PHPApi in php_generator.py does not strip out spaces from api class name

api.py toClassName method strips out spaces.

return utilities.CamelCase(s).replace(' ', '')

however, this method is overridden in PHPApi, and the override does not strip out spaces. So if the owner name in the API annotations has spaces in it, the generator php classes are no longer valid.

On the same note, php classes also can't have "." in them, so these also need to be substituted out (possibly underscore "_"?)

Build failure of java code generated.

What steps will reproduce the problem?
1. Generated java code with goolge-apis-client-generator.
2. mvn compile.
3. Build failure.

What is the expected output? What do you see instead?


What version of the product are you using? On what operating system?
Latest code from git repository.
Both Mac and ubuntu

Please provide any additional information below.
localhost:discovery jchen$ mvn compile
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building APIs Discovery Service v1 (revision snapshot) 
v1-revsnapshot-1.9.0-beta
[INFO] ------------------------------------------------------------------------
Downloading: 
http://mavenrepo.google-api-java-client.googlecode.com/hg/com/google/api-client/
google-api-client/1.12.0-beta-SNAPSHOT/maven-metadata.xml
Downloading: 
http://mavenrepo.google-api-java-client.googlecode.com/hg/com/google/api-client/
google-api-client/1.12.0-beta-SNAPSHOT/google-api-client-1.12.0-beta-SNAPSHOT.po
m
[WARNING] The POM for 
com.google.api-client:google-api-client:jar:1.12.0-beta-SNAPSHOT is missing, no 
dependency information available
Downloading: 
http://mavenrepo.google-api-java-client.googlecode.com/hg/com/google/api-client/
google-api-client/1.12.0-beta-SNAPSHOT/google-api-client-1.12.0-beta-SNAPSHOT.ja
r
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.658s
[INFO] Finished at: Thu Feb 07 17:36:47 PST 2013
[INFO] Final Memory: 2M/81M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project google-api-services-discovery: Could 
not resolve dependencies for project 
com.google.apis:google-api-services-discovery:jar:v1-revsnapshot-1.9.0-beta: 
Could not find artifact 
com.google.api-client:google-api-client:jar:1.12.0-beta-SNAPSHOT in 
google-api-services (http://mavenrepo.google-api-java-client.googlecode.com/hg) 
-> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e 
switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please 
read the following articles:
[ERROR] [Help 1] 
http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
localhost:discovery jchen$ 


Original issue reported on code.google.com by [email protected] on 8 Feb 2013 at 2:04

Incompatible with google-api-client:2.0.0

Dependency google-api-client:2.0.0 does not work with this api generator. Static initializer Preconditions.checkState sets the MAJOR_VERSION check == 1 but needs to be >= 1

Unresolved import: googletest

Description Resource    Path    Location    Type
Unresolved import: 
googletest  generator_test.py   /google-apis-client-generator/src/googleapis/codege
n   line 19 PyDev Problem

Original issue reported on code.google.com by [email protected] on 3 Aug 2011 at 5:10

AuthScope assumes prefix is https://www.googleapis.com/auth/

What steps will reproduce the problem?
1. Generate documentation for an API that doesn't use 
https://www.googleapis.com/auth/ as a base for scope

What is the expected output? What do you see instead?

  public static final String SOMETHING = "(url)";

but the template generates invalid Java here:

  public static final String  = "(url)";

What version of the product are you using? On what operating system?

git tip, Mac

Please provide any additional information below.

This probably shouldn't assume that the scope is prefixed with something 
specific:

    # Strip the common prefix to get a unique identifying name
    prefix_len = len('https://www.googleapis.com/auth/')

Original issue reported on code.google.com by [email protected] on 28 Jan 2013 at 10:44

PHP generated classes dont have a namespace in them

The classname template does not have a namespace in it. It should be possible to use the ownerdomain and replace "." with "" to create a namespace for the classes, so they can be appropriately used alongside the google-api-client in a php project. Right now all the generated classes show up in the global namespace.

Broken code generated using master on Java target

generate_library \
    --input=./testing_v1.json \
    --language=java \
    --output_dir=./testing/src/main/java

Results in:

./gradle/gradlew -p cloud_testing/cloud_api_poc clean build

> Task :testing:compileJava
/flank/cloud_testing/apis/testing/src/main/java/com/google/testing/Testing.java:918: error: method does not override or implement a method from a supertype
    @Override
    ^
/flank/cloud_testing/apis/testing/src/main/java/com/google/testing/Testing.java:920: error: cannot find symbol
      return (Builder) super.setBatchPath(batchPath);
                            ^
  symbol: method setBatchPath(String)
2 errors


FAILURE: Build failed with an exception.

C++: implementations of some functions are not generated.

I've been trying to use youtube API wrapper generated by this generator when I've encountered the following problem - for some functions generator is not generating implementations - only declarations and documentation.
You can see this on an example of already generated API provided here (https://github.com/google/google-api-cpp-client/tree/master/service_apis/youtube/google/youtube_api )
So for example for these functions in live_broadcast.h/cc:
get_snippet
mutable_snippet
get_content_details
mutable_contentDetails
etc.
There is only declarations generated.
I'm getting similar results by running generator myself.

Workaround that I'm using right know is to use option:
--monolithic_source_name
In this case - implementations are generated the way they should be.

cannot import name cpp_import_manager

It seems that cpp_import_manager.py is missing from the source tree.

hyrule:~ protomouse$ generate_library 
Traceback (most recent call last):
  File "/usr/local/bin/generate_library", line 8, in <module>
    load_entry_point('google-apis-client-generator==1.4.2', 'console_scripts', 'generate_library')()
  File "/Library/Python/2.7/site-packages/google_apis_client_generator-1.4.2-py2.7.egg/googleapis/codegen/script_stubs.py", line 9, in RunGenerateLibrary
    from googleapis.codegen import generate_library
  File "/Library/Python/2.7/site-packages/google_apis_client_generator-1.4.2-py2.7.egg/googleapis/codegen/generate_library.py", line 35, in <module>
    from googleapis.codegen import generator_lookup
  File "/Library/Python/2.7/site-packages/google_apis_client_generator-1.4.2-py2.7.egg/googleapis/codegen/generator_lookup.py", line 10, in <module>
    from googleapis.codegen import cpp_generator
  File "/Library/Python/2.7/site-packages/google_apis_client_generator-1.4.2-py2.7.egg/googleapis/codegen/cpp_generator.py", line 27, in <module>
    from googleapis.codegen import cpp_import_manager
ImportError: cannot import name cpp_import_manager

Original issue reported on code.google.com by [email protected] on 18 Feb 2014 at 9:02

Getting issue of name

Traceback (most recent call last):
File "c:\users\deepak\appdata\local\temp\pip-build-yv4lea\google-apis-client-generator\googleapis\codegen\generate_library.py", line 258, in
app.run()
File "c:\python27\lib\site-packages\google\apputils\app.py", line 238, in run
return _actual_start()
File "c:\python27\lib\site-packages\google\apputils\app.py", line 267, in _actual_start
really_start()
File "c:\python27\lib\site-packages\google\apputils\app.py", line 220, in really_start
sys.exit(main(argv))
File "c:\users\deepak\appdata\local\temp\pip-build-yv4lea\google-apis-client-generator\googleapis\codegen\generate_library.py", line 176, in main
language_variant=FLAGS.language_variant)
File "c:\users\deepak\appdata\local\temp\pip-build-yv4lea\google-apis-client-generator\googleapis\codegen\generate_library.py", line 223, in Generate
generator = generator_class(discovery_doc, options=options)
File "c:\python27\lib\site-packages\googleapis\codegen\php_generator.py", line 55, in init
options=options)
File "c:\python27\lib\site-packages\googleapis\codegen\api_library_generator.py", line 53, in init
self._api = api_loader(discovery)
File "c:\python27\lib\site-packages\googleapis\codegen\php_generator.py", line 287, in init
super(PHPApi, self).init(discovery_doc, language)
File "c:\python27\lib\site-packages\googleapis\codegen\api.py", line 87, in init
wire_name=discovery_doc['name'])
KeyError: 'name'

Generating C++ fails

This time, tried running the source directly and got this error:

rennie@rennie:~/gitrepos/apis-client-generator$ env/bin/python src/googleapis/codegen/generate_library.py --input=../google-api-cpp-client/service_apis/calendar/descriptor.json --language=cpp --output_dir=/tmp/generated
Traceback (most recent call last):
  File "src/googleapis/codegen/generate_library.py", line 251, in <module>
    app.run()
  File "/usr/local/google/home/rennie/gitrepos/apis-client-generator/env/local/lib/python2.7/site-packages/google_apputils-0.4.2-py2.7.egg/google/apputils/app.py", line 238, in run
    return _actual_start()
  File "/usr/local/google/home/rennie/gitrepos/apis-client-generator/env/local/lib/python2.7/site-packages/google_apputils-0.4.2-py2.7.egg/google/apputils/app.py", line 267, in _actual_start
    really_start()
  File "/usr/local/google/home/rennie/gitrepos/apis-client-generator/env/local/lib/python2.7/site-packages/google_apputils-0.4.2-py2.7.egg/google/apputils/app.py", line 220, in really_start
    sys.exit(main(argv))
  File "src/googleapis/codegen/generate_library.py", line 171, in main
    language_variant=FLAGS.language_variant)
  File "src/googleapis/codegen/generate_library.py", line 216, in Generate
    generator = generator_class(discovery_doc, options=options)
  File "/usr/local/google/home/rennie/gitrepos/apis-client-generator/env/local/lib/python2.7/site-packages/google_apis_client_generator-1.4.2-py2.7.egg/googleapis/codegen/cpp_generator.py", line 98, in __init__
    language_model, options=options)
  File "/usr/local/google/home/rennie/gitrepos/apis-client-generator/env/local/lib/python2.7/site-packages/google_apis_client_generator-1.4.2-py2.7.egg/googleapis/codegen/api_library_generator.py", line 53, in __init__
    self._api = api_loader(discovery)
  File "/usr/local/google/home/rennie/gitrepos/apis-client-generator/env/local/lib/python2.7/site-packages/google_apis_client_generator-1.4.2-py2.7.egg/googleapis/codegen/cpp_generator.py", line 653, in __init__
    super(CppApi, self).__init__(discovery_doc)
  File "/usr/local/google/home/rennie/gitrepos/apis-client-generator/env/local/lib/python2.7/site-packages/google_apis_client_generator-1.4.2-py2.7.egg/googleapis/codegen/api.py", line 93, in __init__
    self._class_name = self.ToClassName(canonical_name, self)
  File "/usr/local/google/home/rennie/gitrepos/apis-client-generator/env/local/lib/python2.7/site-packages/google_apis_client_generator-1.4.2-py2.7.egg/googleapis/codegen/cpp_generator.py", line 697, in ToClassName
    s = utilities.CamelCase(s)
  File "/usr/local/google/home/rennie/gitrepos/apis-client-generator/env/local/lib/python2.7/site-packages/google_apis_client_generator-1.4.2-py2.7.egg/googleapis/codegen/utilities/__init__.py", line 40, in CamelCase
    return ''.join([title(x) for x in _WORD_SPLIT_PATTERN.split(s)])
TypeError: expected string or buffer
rennie@rennie:~/gitrepos/apis-client-generator$ 

Optional Query Params Not Generated for Method Call Params

In C#, I've noticed that the optional parameters on some method calls are unavailable in the generated libraries. For instance, with the Gmail API, trying to insert a message, there are optional query parameters of deleted and internalDateSource. However, if I attempt to use them, there is no parameter to do so. The generated method for the standard Insert (not the MediaUpload version) is:

public virtual InsertRequest Insert(Google.Apis.Gmail.v1.Data.Message body, string userId)
{
    return new InsertRequest(service, body, userId);
}

So, within this generated API there is no way to set those two parameters without having the user create their own InsertRequest, which seems to defeat the purpose of the method call which returns the InsertRequest.

Upon closer inspection, it looks like within the /csharp/languages/csharp/default/templates/_method.tmpl file the only parameters being created are the requiredParameters. This seems to be by design, but I'm not sure why we wouldn't want those parameters accessible.

[Please feel free to ignore this suggestion.] The solution I've been using in my forked project is to wrap all required parameters in an optional Properties subclass (named for the method it is associated with) that is passed to any method with optional parameters. That way, no matter how many there are, your methods won't get cluttered. From there, I expand the new object being created and assign each optional parameter after the constructor, so that would look like:

public virtual InsertRequest Insert(Google.Apis.Gmail.v1.Data.Message body, string userId, Google.Apis.Gmail.v1.Data.Message.InsertParameters parameters = null)
{

    if (null == parameters) parameters = new Google.Apis.Gmail.v1.Data.Message.InsertParameters();

    return new InsertRequest(service, body, userId)
    {
        Deleted = parameters.Deleted,
        InternalDateSource = parameters.InternalDateSource,
    };
}

I'm not sure how well that solution would fit in to other languages, or if it would be necessary, but I figured I'd offer that. :)

Support for python3

Hi,

Is there a timeline on when python3 will be supported here ? We are trying to generate a client for the GCP Marketplace procurement APIs as mentioned here and are running into the below error.

generate_library --input=discovery.json --language=java --output_dir=procurement Traceback (most recent call last): File "/usr/local/google/home/kishorenamala/.local/bin/generate_library", line 5, in <module> from googleapis.codegen.script_stubs import RunGenerateLibrary File "/usr/local/google/home/kishorenamala/.local/lib/python3.9/site-packages/googleapis/codegen/script_stubs.py", line 4, in <module> from google.apputils import run_script_module File "/usr/local/google/home/kishorenamala/.local/lib/python3.9/site-packages/google/apputils/run_script_module.py", line 122 print 'Stub script %s (auto-generated). Options:' % sys.argv[0] ^ SyntaxError: invalid syntax

Not able to run

Hello,

I'm trying to execute the generator for the new Admin-SDK API, however I'm not 
even able to download plus API

What steps will reproduce the problem?

$ python $(/bin/pwd)/googleapis/codegen/generate_library.py --api_name=plus 
--api_version=v1 --language=java --output_dir=/tmp/gen --language=java
Traceback (most recent call last):
  File "/Users/alejacquet/Development/git/google-apis-client-generator/src/googleapis/codegen/generate_library.py", line 245, in <module>
    app.run()
  File "/Library/Python/2.7/site-packages/google_apputils-0.3.0-py2.7.egg/google/apputils/app.py", line 216, in run
    return _actual_start()
  File "/Library/Python/2.7/site-packages/google_apputils-0.3.0-py2.7.egg/google/apputils/app.py", line 244, in _actual_start
    really_start()
  File "/Library/Python/2.7/site-packages/google_apputils-0.3.0-py2.7.egg/google/apputils/app.py", line 203, in really_start
    sys.exit(main(argv))
  File "/Users/alejacquet/Development/git/google-apis-client-generator/src/googleapis/codegen/generate_library.py", line 152, in main
    language_variant=FLAGS.language_variant)
  File "/Users/alejacquet/Development/git/google-apis-client-generator/src/googleapis/codegen/generate_library.py", line 179, in Generate
    language_variations = Targets().VariationsForLanguage(language)
  File "/Users/alejacquet/Development/git/google-apis-client-generator/src/googleapis/codegen/targets.py", line 68, in __init__
    files.GetFileContents(self.targets_path))
  File "/Users/alejacquet/Development/git/google-apis-client-generator/src/googleapis/codegen/json_with_comments.py", line 54, in Loads
    return json.loads(stripped, **kw)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/__init__.py", line 326, in loads

  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py", line 366, in decode
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py", line 382, in raw_decode
ValueError: Expecting property name: line 9 column 9 (char 198)



What is the expected output? What do you see instead?
Export the api

What version of the product are you using? On what operating system?
MacOSX 10.8.3 and Ubuntu 13.04 I've tried with python2.6 and python2.7

Please provide any additional information below.


Original issue reported on code.google.com by [email protected] on 21 May 2013 at 7:09

Top level list in discovery document are not generated correctly

In our discovery document we have lists as method return types like this:

"schemas": {
    "ListOfOrder": {
        "id": "ListOfOrder",
        "type": "array",
        "items": {
            "$ref": "Order"
        }
    },
    "...": "...",
}
"methods": {
    "list": {
        "...": "...",
        "response": {
            "$ref": "ListOfOrder"
        }
    }
}

The java client generator will happily use the type ListOfOrder like a class in many places, but will not generate the class itself, thereby yielding code, which will not even compile.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.