cloudendpoints / endpoints-python

A Python framework for building RESTful APIs on Google App Engine
Apache License 2.0
51 stars 17 forks source link

get_swagger_spec causes AttributeError: 'Namespace' object has no attribute 'x_google_api_name' #189

Closed realgsong closed 5 years ago

realgsong commented 5 years ago

Repro

  1. clone https://github.com/GoogleCloudPlatform/python-docs-samples
  2. cd ~/python-docs-samples/appengine/standard/endpoints-frameworks-v2/echo
  3. pip install --system -t lib google-endpoints>=4.8.0
  4. python ./lib/endpoints/endpointscfg.py get_swagger_spec main.api

Error

Traceback (most recent call last):
  File "./lib/endpoints/endpointscfg.py", line 31, in <module>
    main(sys.argv)
  File "/home/ksbae/python-docs-samples/appengine/standard/endpoints/backend/lib/endpoints/_endpointscfg_impl.py", line 617, in main
    args.callback(args)
  File "/home/ksbae/python-docs-samples/appengine/standard/endpoints/backend/lib/endpoints/_endpointscfg_impl.py", line 465, in _GenOpenApiSpecCallback
    x_google_api_name=args.x_google_api_name)

Please tell me if I'm missing something.

inklesspen commented 5 years ago

Unfortunately, that example is obsolete and should not be used. The correct examples are in https://github.com/GoogleCloudPlatform/python-docs-samples/tree/master/appengine/standard/endpoints-frameworks-v2

realgsong commented 5 years ago

I got the same error with endpoints-frameworks-v2 sample. @inklesspen would you reopen this issue?

Traceback (most recent call last):
  File "./lib/endpoints/endpointscfg.py", line 31, in <module>
    main(sys.argv)
  File "/home/ksbae/python-docs-samples/appengine/standard/endpoints-frameworks-v2/echo/lib/endpoints/_endpointscfg_impl.py", line 617, in main
    args.callback(args)
  File "/home/ksbae/python-docs-samples/appengine/standard/endpoints-frameworks-v2/echo/lib/endpoints/_endpointscfg_impl.py", line 465, in _GenOpenApiSpecCallback
    x_google_api_name=args.x_google_api_name)
AttributeError: 'Namespace' object has no attribute 'x_google_api_name'
tomboc commented 5 years ago

get_swagger_spec is a legacy command, replaced by get_openapi_spec. While I investigate why get_swagger_spec doesn't behave correctly, use: python ./lib/endpoints/endpointscfg.py get_openapi_spec main.EchoApi

The full up-to-date instructions for Endpoints Frameworks are here: https://cloud.google.com/endpoints/docs/frameworks/python/get-started-frameworks-python