Closed kiwiroy closed 3 years ago
With recent changes to the way Mojolicious routes for requests with format parameters the editor no longer retrieves data from the api but instead errors with a TypeError: items is undefined at /yancy/app.js:693.
format
TypeError: items is undefined
/yancy/app.js:693
As mentioned on IRC: https://github.com/preaction/Yancy/blob/42111830eccb514f5dbacba2fb6b358d79bf1860/lib/Mojolicious/Plugin/Yancy/resources/public/yancy/app.js#L682 could be changed to.
$.get( this.currentOperations["list"].url, query, null, 'json' ).done(
Without this, the request headers are Accept: */* and json is never selected as a format in Yancy::Controller#list ($c->respond_to).
Accept: */*
json
Yancy::Controller#list
$c->respond_to
However, Yancy goes to lengths to set the format to json for api routes in
https://github.com/preaction/Yancy/blob/42111830eccb514f5dbacba2fb6b358d79bf1860/lib/Yancy/Plugin/Editor.pm#L420-L457
Mojolicious::Plugin::OpenAPI reverses this by undefing format when configuring the route https://github.com/jhthorsen/mojolicious-plugin-openapi/blob/master/lib/Mojolicious/Plugin/OpenAPI.pm#L232-L233
Mojolicious::Plugin::OpenAPI
undef
M::P::OpenAPI could be patched, but I'll open a PR for a local fix.
Fixed by merging #133. Thanks!
With recent changes to the way Mojolicious routes for requests with
format
parameters the editor no longer retrieves data from the api but instead errors with aTypeError: items is undefined
at/yancy/app.js:693
.As mentioned on IRC: https://github.com/preaction/Yancy/blob/42111830eccb514f5dbacba2fb6b358d79bf1860/lib/Mojolicious/Plugin/Yancy/resources/public/yancy/app.js#L682 could be changed to.
Without this, the request headers are
Accept: */*
andjson
is never selected as a format inYancy::Controller#list
($c->respond_to
).However, Yancy goes to lengths to set the
format
tojson
for api routes inhttps://github.com/preaction/Yancy/blob/42111830eccb514f5dbacba2fb6b358d79bf1860/lib/Yancy/Plugin/Editor.pm#L420-L457
Mojolicious::Plugin::OpenAPI
reverses this byundef
ingformat
when configuring the route https://github.com/jhthorsen/mojolicious-plugin-openapi/blob/master/lib/Mojolicious/Plugin/OpenAPI.pm#L232-L233M::P::OpenAPI could be patched, but I'll open a PR for a local fix.