-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Description
Following the instructions at python-docs-samples/appengine/standard/endpoints-frameworks-v2/echo/, I run into multiple errors.
For reference, here's the version of Python I'm using (using an isolated conda environment): Python 2.7.8 :: Continuum Analytics, Inc. After successfully installing the required packages with pip install -t lib google-endpoints, running the command python lib/endpoints/endpointscfg.py get_swagger_spec main.EchoApi --hostname bombora-dev.appspot.com yields the following error:
Traceback (most recent call last):
File "lib/endpoints/endpointscfg.py", line 615, in <module>
main(sys.argv)
File "lib/endpoints/endpointscfg.py", line 611, in main
args.callback(args)
File "lib/endpoints/endpointscfg.py", line 479, in _GenSwaggerSpecCallback
application_path=args.application)
File "lib/endpoints/endpointscfg.py", line 324, in _GenSwaggerSpec
application_path=application_path)
File "lib/endpoints/endpointscfg.py", line 181, in GenApiConfig
module = __import__(module_name, fromlist=base_service_class_name)
File "/Users/jeffkpayne/repos/python-docs-samples/appengine/standard/endpoints-frameworks-v2/echo/main.py", line 105, in <module>
api = endpoints.api_server([EchoApi])
File "/Users/jeffkpayne/repos/python-docs-samples/appengine/standard/endpoints-frameworks-v2/echo/lib/endpoints/apiserving.py", line 481, in api_server
apis_app = _ApiServer(api_services, **kwargs)
File "/Users/jeffkpayne/repos/python-docs-samples/appengine/standard/endpoints-frameworks-v2/echo/lib/endpoints/apiserving.py", line 249, in __init__
self.api_config_registry)
File "/Users/jeffkpayne/repos/python-docs-samples/appengine/standard/endpoints-frameworks-v2/echo/lib/endpoints/apiserving.py", line 331, in __register_services
config_file = generator.pretty_print_config_to_json(service_classes)
File "/Users/jeffkpayne/repos/python-docs-samples/appengine/standard/endpoints-frameworks-v2/echo/lib/endpoints/api_config.py", line 2057, in pretty_print_config_to_json
descriptor = self.get_config_dict(services, hostname)
File "/Users/jeffkpayne/repos/python-docs-samples/appengine/standard/endpoints-frameworks-v2/echo/lib/endpoints/api_config.py", line 2043, in get_config_dict
return self.__api_descriptor(services, hostname=hostname)
File "/Users/jeffkpayne/repos/python-docs-samples/appengine/standard/endpoints-frameworks-v2/echo/lib/endpoints/api_config.py", line 1970, in __api_descriptor
service.__name__))
endpoints.api_exceptions.ApiConfigurationError: POST path "echo" used multiple times, in classes EchoApi and EchoApi
The problem and fix is obvious, so I simply comment out one of the offending methods, yielding the following diff:
diff --git a/appengine/standard/endpoints-frameworks-v2/echo/main.py b/appengine/standard/endpoints-frameworks-v2/echo/main.py
index 2f0abbc..5b47b63 100644
--- a/appengine/standard/endpoints-frameworks-v2/echo/main.py
+++ b/appengine/standard/endpoints-frameworks-v2/echo/main.py
@@ -67,18 +67,18 @@ class EchoApi(remote.Service):
output_content = ' '.join([request.content] * request.n)
return EchoResponse(content=output_content)
- @endpoints.method(
- # This method takes a ResourceContainer defined above.
- ECHO_RESOURCE,
- # This method returns an Echo message.
- EchoResponse,
- path='echo',
- http_method='POST',
- name='echo_api_key',
- api_key_required=True)
- def echo_api_key(self, request):
- output_content = ' '.join([request.content] * request.n)
- return EchoResponse(content=output_content)
+# @endpoints.method(
+# # This method takes a ResourceContainer defined above.
+# ECHO_RESOURCE,
+# # This method returns an Echo message.
+# EchoResponse,
+# path='echo',
+# http_method='POST',
+# name='echo_api_key',
+# api_key_required=True)
+# def echo_api_key(self, request):
+# output_content = ' '.join([request.content] * request.n)
+# return EchoResponse(content=output_content)
@endpoints.method(
# This method takes an empty request body.
Once that is done, the swagger spec file can be generated successfully. However, running the next command in the workflow, gcloud alpha service-management deploy echo-v1_swagger.json, yields the following warnings and errors:
ERROR: (gcloud.alpha.service-management.deploy) INVALID_ARGUMENT: Cannot convert to service config.
'WARNING: echo-v1_swagger.json: Operation 'post' in path '/echo/v1/echo': Operation does not require an API key; callers may invoke the method without specifying an associated API-consuming project.
WARNING: echo-v1_swagger.json: Operation 'get' in path '/echo/v1/echo/getUserEmail': Operation does not require an API key; callers may invoke the method without specifying an associated API-consuming project.
WARNING: echo-v1_swagger.json: Operation 'post' in path '/echo/v1/echo/{n}': Operation does not require an API key; callers may invoke the method without specifying an associated API-consuming project.
ERROR: toplevel: http rule has bad syntax in selector 'echo-v1_swagger.EchoApi_echo'. See documentation for information on selector syntax.
ERROR: toplevel: http rule has bad syntax in selector 'echo-v1_swagger.EchoApi_getUserEmail'. See documentation for information on selector syntax.
ERROR: toplevel: http rule has bad syntax in selector 'echo-v1_swagger.EchoApi_echoPathParameter'. See documentation for information on selector syntax.
ERROR: toplevel: usage rule has bad syntax in selector 'echo-v1_swagger.EchoApi_echo'. See documentation for information on selector syntax.
ERROR: toplevel: usage rule has bad syntax in selector 'echo-v1_swagger.EchoApi_getUserEmail'. See documentation for information on selector syntax.
ERROR: toplevel: usage rule has bad syntax in selector 'echo-v1_swagger.EchoApi_echoPathParameter'. See documentation for information on selector syntax.
ERROR: toplevel: auth rule has bad syntax in selector 'echo-v1_swagger.EchoApi_getUserEmail'. See documentation for information on selector syntax.
WARNING: unknown location: http: POST/PATCH/PUT method for 'echo-v1_swagger.EchoApi_echo' should specify a body.
WARNING: unknown location: (lint) http-invalid-collection-id: path segment '_ah' contains '_'; instead, please use camelCase.
WARNING: unknown location: (lint) http-invalid-collection-id: path segment '_ah' contains '_'; instead, please use camelCase.
WARNING: toplevel: (lint) http-rest: 'rpc EchoApi_getUserEmail as HTTP GET /_ah/api/echo/v1/echo/getUserEmail' is not a recognized REST pattern. Did you mean one of:
rpc List.* as HTTP GET <prefix>/<literal>
rpc Get.* as HTTP GET <prefix>:<literal>
rpc List.* as HTTP GET <prefix>:<literal>
rpc EchoApi_getUserEmail as HTTP GET <prefix>:<literal>
rpc EchoApi_getUserEmail as HTTP POST <prefix>:<literal>
Refer to http://go/api-style/standard_methods.md for details.
WARNING: unknown location: http: POST/PATCH/PUT method for 'echo-v1_swagger.EchoApi_echoPathParameter' should specify a body.
WARNING: unknown location: (lint) http-invalid-collection-id: path segment '_ah' contains '_'; instead, please use camelCase.
WARNING: toplevel: (lint) http-rest: 'rpc EchoApi_echoPathParameter as HTTP POST /_ah/api/echo/v1/echo/*' is not a recognized REST pattern. Did you mean one of:
rpc EchoApi_echoPathParameter as HTTP GET <prefix>:<literal>
rpc EchoApi_echoPathParameter as HTTP POST <prefix>:<literal>
Refer to http://go/api-style/standard_methods.md for details.
WARNING: toplevel: (lint) servicecontrol-unused-metrics: The metric(s) 'serviceruntime.googleapis.com/api/consumer/quota_billable_count' are not used.
WARNING: toplevel: http: The rpc methods and the associated http paths are not following the guidelines. As a result the derived rest collection '_ah.api.echo.v1' contains a sub collection and a method with the same name as 'echo'. This can cause a failure to generate client library, since these names are used for generating artifacts in generated code.
See http://go/api-style/standard_methods.md for api styles.
WARNING: : (lint) naming-lower-camel-qualified: Name '' is not matching lower-camel-qualified conventions (pattern '[a-z][a-z0-9_]*([.][a-z][a-z0-9_]*)*')
WARNING: unknown location: (lint) documentation-presence: 'message MainEchoResponse' has no documentation, neither in IDL nor config.
WARNING: unknown location: (lint) documentation-presence: 'string MainEchoResponse.content' has no documentation, neither in IDL nor config.
WARNING: unknown location: (lint) documentation-presence: 'message EchoApi_echoPathParameterRequest' has no documentation, neither in IDL nor config.
WARNING: unknown location: (lint) naming-upper-camel: Name 'EchoApi_echoPathParameterRequest' is not matching upper-camel conventions (pattern '[A-Z][A-Za-z0-9]*')
WARNING: unknown location: (lint) documentation-presence: 'int64 EchoApi_echoPathParameterRequest.n' has no documentation, neither in IDL nor config.
WARNING: unknown location: (lint) documentation-presence: 'message google.protobuf.Empty' has no documentation, neither in IDL nor config.
WARNING: echo-v1_swagger.json: (lint) naming-lower-camel-qualified: Name '' is not matching lower-camel-qualified conventions (pattern '[a-z][a-z0-9_]*([.][a-z][a-z0-9_]*)*')
WARNING: unknown location: (lint) documentation-presence: 'api echo-v1_swagger' has no documentation, neither in IDL nor config.
WARNING: unknown location: (lint) naming-upper-camel: Name 'echo-v1_swagger' is not matching upper-camel conventions (pattern '[A-Z][A-Za-z0-9]*')
WARNING: unknown location: (lint) documentation-presence: 'method echo-v1_swagger.EchoApi_echo' has no documentation, neither in IDL nor config.
WARNING: toplevel: (lint) versioning-http-version-prefix: 'method echo-v1_swagger.EchoApi_echo' has a HTTP path that does not start with version, which must match '^(v\d+(\w+)?)$'.
WARNING: unknown location: (lint) naming-upper-camel: Name 'EchoApi_echo' is not matching upper-camel conventions (pattern '[A-Z][A-Za-z0-9]*')
WARNING: unknown location: (lint) documentation-presence: 'method echo-v1_swagger.EchoApi_getUserEmail' has no documentation, neither in IDL nor config.
WARNING: toplevel: (lint) versioning-http-version-prefix: 'method echo-v1_swagger.EchoApi_getUserEmail' has a HTTP path that does not start with version, which must match '^(v\d+(\w+)?)$'.
WARNING: unknown location: (lint) naming-upper-camel: Name 'EchoApi_getUserEmail' is not matching upper-camel conventions (pattern '[A-Z][A-Za-z0-9]*')
WARNING: unknown location: (lint) documentation-presence: 'method echo-v1_swagger.EchoApi_echoPathParameter' has no documentation, neither in IDL nor config.
WARNING: toplevel: (lint) versioning-http-version-prefix: 'method echo-v1_swagger.EchoApi_echoPathParameter' has a HTTP path that does not start with version, which must match '^(v\d+(\w+)?)$'.
WARNING: unknown location: (lint) naming-upper-camel: Name 'EchoApi_echoPathParameter' is not matching upper-camel conventions (pattern '[A-Z][A-Za-z0-9]*')
WARNING: toplevel: (lint) legacy-contacts: email is not specified in the legacy section.
WARNING: toplevel: (lint) legacy-contacts: oncall is not specified in the legacy section.
WARNING: toplevel: (lint) legacy-contacts: mdb is not specified in the legacy section.
WARNING: toplevel: (lint) legacy-contacts: learnmore_url is not specified in the legacy section.
WARNING: toplevel: (lint) discovery-canonical_name: Starting from config_version 3, discovery.canonical_name is required field to make sure client libraries for languages like objective-c can be properly generated.'
The part that looks relevant is ERROR: toplevel: http rule has bad syntax in selector 'echo-v1_swagger.EchoApi_echo'. See documentation for information on selector syntax., but I'm at a loss as to how to proceed.