dropwizard-swagger icon indicating copy to clipboard operation
dropwizard-swagger copied to clipboard

Error "Could not render this component, see the console." when clicking the "Try it out" button

Open mahe1970 opened this issue 4 years ago • 21 comments

Hi, when I press the "Try it out" button I get the error "Could not render this component, see console". I use dropwizard-swagger in version 2.0.12-1.

This is the chrome console output:

TypeError: Cannot read property 'apply' of null at Object.e.requestInterceptor (actions.js:420) at index.js:578 at c (runtime.js:45) at Generator._invoke (runtime.js:271) at Generator.e. [as next] (runtime.js:97) at o (asyncToGenerator.js:5) at s (asyncToGenerator.js:27) at asyncToGenerator.js:34 at new Promise () at new t (_export.js:36)

TypeError: Cannot read property 'get' of null at t.value (live-response.jsx:56) at t.M.t.render (root-injects.jsx:93) at u._renderValidatedComponentWithoutOwnerOrContext (ReactCompositeComponent.js:796) at u._renderValidatedComponent (ReactCompositeComponent.js:819) at u._updateRenderedComponent (ReactCompositeComponent.js:743) at u._performComponentUpdate (ReactCompositeComponent.js:721) at updateComponent (ReactCompositeComponent.js:642) at u.receiveComponent (ReactCompositeComponent.js:544) at Object.receiveComponent (ReactReconciler.js:122) at Object.updateChildren (ReactChildReconciler.js:107)

live-response.jsx line 56:

const url = curlRequest.get("url")

The file live-response.jsx comes from the swagger-ui package (src/core/components)

Does anyone have an idea what I am doing wrong?

Best Regards mahe1970

mahe1970 avatar Aug 26 '20 15:08 mahe1970

I think this is probably the same as issue #210

KatseNarniaan avatar Oct 08 '20 22:10 KatseNarniaan

Should be closed as it's a dup of #210 (the other way round actually).

marcelstoer avatar Dec 26 '20 21:12 marcelstoer

Having the same problem. Tried getting the latest from master but still getting the same error.

asantosca avatar Feb 01 '21 07:02 asantosca

So this isn't #210 issue. I've updated swagger and still got this issue. FYI: /swagger-static/index.html requests works fine

petusch avatar Feb 12 '21 09:02 petusch

We were able to solve this issue by getting the version 2.0.12.2 and removing the lines

        <#if customJavascriptPath??>
        requestInterceptor: (typeof customRequestInterceptor == 'function' ? customRequestInterceptor : null)
        </#if>

from src/main/resources/io/federecio/dropwizard/swagger/index.ftl

Although this fixed our issues, it is not a general solution, as it removes the interceptor for custom javascript.

asantosca avatar Feb 18 '21 20:02 asantosca

Having the same problem 4/24/2021. Any new updates?

jnovotny avatar Apr 24 '21 07:04 jnovotny

I’d be happy to review a PR if someone can submit one.

jplock avatar Apr 24 '21 17:04 jplock

Ok thanks I'l see what I can do

On Sat, Apr 24, 2021, 6:05 PM Justin Plock @.***> wrote:

I’d be happy to review a PR if someone can submit one.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/smoketurner/dropwizard-swagger/issues/206#issuecomment-826122765, or unsubscribe https://github.com/notifications/unsubscribe-auth/AANMFFQFBMKOIAFGEN46K6DTKL26ZANCNFSM4QL7JOWQ .

jnovotny avatar Apr 24 '21 18:04 jnovotny

Hi,

Just following up, it appears only a new release needs to be published to maven central repository as the issue is fixed in code but maven has an older version available.

Thanks, Jason

On Sat, Apr 24, 2021, 7:02 PM Jason Novotny @.***> wrote:

Ok thanks I'l see what I can do

On Sat, Apr 24, 2021, 6:05 PM Justin Plock @.***> wrote:

I’d be happy to review a PR if someone can submit one.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/smoketurner/dropwizard-swagger/issues/206#issuecomment-826122765, or unsubscribe https://github.com/notifications/unsubscribe-auth/AANMFFQFBMKOIAFGEN46K6DTKL26ZANCNFSM4QL7JOWQ .

jnovotny avatar May 03 '21 11:05 jnovotny

any updates on this?

dmitrypol avatar May 09 '21 14:05 dmitrypol

Not yet. I got a new machine and haven’t set up the ability to publish to maven central yet

jplock avatar May 09 '21 15:05 jplock

Just want to say I understand and appreciate your maintenance of this library

dmitrypol avatar May 09 '21 16:05 dmitrypol

AN update to this would please our PEN testing team !!!

roryodonnell avatar Jun 01 '21 08:06 roryodonnell

Any update on this ? This would also be important for us to use the new tag .

Is there a way we can help somehow to create tag and publish to maven central ?

raviharshil27 avatar Jun 24 '21 00:06 raviharshil27

Hi, same need here for an updated version in maven central. Too bad we can't help without the credentials!

alainbodiguel avatar Sep 20 '21 13:09 alainbodiguel

For anyone having the experiencing this issue. I found the following workaround:

  1. Create an "empty" custom request interceptor e.g. swagger-static/custom-request-interceptor.js in your resources directory
    function customRequestInterceptor(request) {
        return request;
    }
    
  2. Add a reference to this file in the customJavascript field of the SwaggerBundleConfiguration class e.g.:
    swagger:
        customJavascript: "/swagger-static/custom-request-interceptor.js"
    
    or
    bootstrap.addBundle(new SwaggerBundle<>() {
        protected SwaggerBundleConfiguration getSwaggerBundleConfiguration(ServiceConfiguration configuration) {
            SwaggerBundleConfiguration config = new SwaggerBundleConfiguration();
            config.setCustomJavascript("/swagger-static/custom-request-interceptor.js");
    
            return config;
        }
    });
    

amcghie avatar Sep 29 '21 02:09 amcghie

When is the new released planned ?

ankuagarwal avatar Oct 08 '21 04:10 ankuagarwal

@amcghie I tried your solution, but the swagger is unable to find the path for the new custom interceptor.

ankuagarwal avatar Oct 08 '21 04:10 ankuagarwal

Hi @jplock , @federecio , sorry for bugging you guys directly, but would be nice to have a 2.0.12-2 release with this fix. Could you release it please? It's blocking a lot of us having a more recent version which also allows better dependency management (avoiding CVEs and such). Thank you for your work, pls let us know how we can help you guys!

akatona84 avatar Oct 19 '21 09:10 akatona84

workaround:

  1. Copy the fixed index.ftl from here to your project resources (and make it land into the jar as well of course)
  2. override the view template in SwaggerBundleConfiguration, where you are adding the bundle to your dw app
SwaggerBundleConfiguration config = new SwaggerBundleConfiguration();
config.getSwaggerViewConfiguration().setTemplateUrl("/index.ftl");

(in my example, I've put the index.ftl to the root of my jar)

akatona84 avatar Oct 19 '21 09:10 akatona84

Any movement on this? I have tried some of the work-arounds above, but none of them seem to work for me.

flybonzai avatar Nov 15 '21 18:11 flybonzai

This issue is stale because it has been open 90 days with no activity. Remove the "stale" label or comment or this will be closed in 14 days.

github-actions[bot] avatar Dec 20 '22 01:12 github-actions[bot]

Any updates on this?

dmitrypol avatar Dec 20 '22 14:12 dmitrypol

config.getSwaggerViewConfiguration().setTemplateUrl("/index.ftl");

Same here :(

waldeilson-info avatar Mar 09 '23 15:03 waldeilson-info

This issue is stale because it has been open 90 days with no activity. Remove the "stale" label or comment or this will be closed in 14 days.

github-actions[bot] avatar Jun 08 '23 01:06 github-actions[bot]