marshmallow-code / marshmallow-code/apispec-webframeworks

Can't use apispec tornado plugin icw complex paths

Aperta
#13 1 commento 1 reazione 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

tornado
Lingua principale
Python
Stelle
33
Fork
24
Merge medio
5h 38m
PR unite (30g)
4

Descrizione

Issue by p0psicles
Monday Dec 11, 2017 at 19:41 GMT
Originally opened as https://github.com/marshmallow-code/apispec/issues/176


I'm trying to use apispec icw the 'apispec.ext.tornado' and 'apispec.ext.marshmallow' plugins.
Only i'm getting the following error:

Traceback (most recent call last):
  File "D:\JetBrains\PyCharm 2017.2.4\helpers\pydev\pydevd.py", line 1599, in <module>
    globals = debugger.run(setup['file'], None, None, is_module)
  File "D:\JetBrains\PyCharm 2017.2.4\helpers\pydev\pydevd.py", line 1026, in run
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "D:\myproj/start.py", line 7, in <module>
    main()
  File "D:\myproj\medusa\__main__.py", line 2104, in main
    application.start(sys.argv[1:])
  File "D:\myproj\medusa\__main__.py", line 347, in start
    self.web_server = AppWebServer(self.web_options)
  File "D:\myproj\medusa\server\core.py", line 230, in __init__
    spec.add_path(urlspec=urlspec)
  File "D:\Python27\lib\site-packages\apispec\core.py", line 211, in add_path
    raise APISpecError('Path template is not specified')
apispec.exceptions.APISpecError: Path template is not specified

It seems to be happening because matcher._path is None.
https://github.com/marshmallow-code/apispec/blob/dev/apispec/ext/tornado.py#L95

urlspec.matcher._path returns None, because of this:
https://github.com/tornadoweb/tornado/blob/master/tornado/routing.py#L571

And my route looks like this:
'/api/v2/series/(?P<series_slug>\\w+)/episode(?:(?:(?:(?:/(?P<episode_slug>[\\w-]+))|/?)(?:(?:/(?P<path_param>\\w+))|/?))|/?)/?$'

So because the tornado plugin uses the matcher._path, it's can't translate to an OpenApi compliant path.
Is there anything I can do about it?

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia da apispec/ext/tornado.py, nella parte relativa alla gestione di matcher._path, e da apispec/core.py, dove add_path genera l'errore; confronta questi elementi con il comportamento di routing.py di Tornado per la route segnalata. Riproduci la route complessa e aggiungi un test di regressione che dimostri che il plugin fornisce un template di percorso OpenAPI valido senza compromettere le route più semplici.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
openapi, python
Ambito
api
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Da chiarire
Idoneità per principianti
25/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.