question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Self is not defined

See original GitHub issue
  • node version
$ node --version
v6.9.5
  • swagger-ui version
"swagger-ui-dist": "^3.0.17",
  • a swagger file reproducing the issue
npm install --save swagger-ui-dist

Sample file:

const express = require('express');
const app = express();
app.listen();
const swaggerDist = require('swagger-ui-dist');
const swaggerUiAssetPath = swaggerDist.getAbsoluteFSPath(); // <-- errors out
app.use('/swagger', express.static(swaggerUiAssetPath));

Full stack trace:

ReferenceError: self is not defined
    at Object.<anonymous> (c:\dev\cpt\ads\ads-web-services\node_modules\swagger-ui-dist\swagger-ui-bundle.js:73:22556)
    at t (c:\dev\cpt\ads\ads-web-services\node_modules\swagger-ui-dist\swagger-ui-bundle.js:1:402)
    at Object.e.exports.e.__esModule.default (c:\dev\cpt\ads\ads-web-services\node_modules\swagger-ui-dist\swagger-ui-bundle.js:72:10755)
    at t (c:\dev\cpt\ads\ads-web-services\node_modules\swagger-ui-dist\swagger-ui-bundle.js:72:110)
    at Object.<anonymous> (c:\dev\cpt\ads\ads-web-services\node_modules\swagger-ui-dist\swagger-ui-bundle.js:72:9958)
    at t (c:\dev\cpt\ads\ads-web-services\node_modules\swagger-ui-dist\swagger-ui-bundle.js:72:110)
    at Object.e.exports.e.__esModule.default (c:\dev\cpt\ads\ads-web-services\node_modules\swagger-ui-dist\swagger-ui-bundle.js:72:11205)
    at t (c:\dev\cpt\ads\ads-web-services\node_modules\swagger-ui-dist\swagger-ui-bundle.js:72:110)
    at Object.<anonymous> (c:\dev\cpt\ads\ads-web-services\node_modules\swagger-ui-dist\swagger-ui-bundle.js:73:1750)
    at t (c:\dev\cpt\ads\ads-web-services\node_modules\swagger-ui-dist\swagger-ui-bundle.js:72:110)
    at c:\dev\cpt\ads\ads-web-services\node_modules\swagger-ui-dist\swagger-ui-bundle.js:72:493
    at Object.<anonymous> (c:\dev\cpt\ads\ads-web-services\node_modules\swagger-ui-dist\swagger-ui-bundle.js:72:503)
    at t (c:\dev\cpt\ads\ads-web-services\node_modules\swagger-ui-dist\swagger-ui-bundle.js:1:402)
    at Object.e.exports.n.(anonymous function).i (c:\dev\cpt\ads\ads-web-services\node_modules\swagger-ui-dist\swagger-ui-bundle.js:71:31725)
    at t (c:\dev\cpt\ads\ads-web-services\node_modules\swagger-ui-dist\swagger-ui-bundle.js:1:402)
    at Object.t (c:\dev\cpt\ads\ads-web-services\node_modules\swagger-ui-dist\swagger-ui-bundle.js:39:4816)
    at t (c:\dev\cpt\ads\ads-web-services\node_modules\swagger-ui-dist\swagger-ui-bundle.js:1:402)
    at Object.t (c:\dev\cpt\ads\ads-web-services\node_modules\swagger-ui-dist\swagger-ui-bundle.js:39:3431)
    at t (c:\dev\cpt\ads\ads-web-services\node_modules\swagger-ui-dist\swagger-ui-bundle.js:1:402)
    at Object.<anonymous> (c:\dev\cpt\ads\ads-web-services\node_modules\swagger-ui-dist\swagger-ui-bundle.js:1:15146)
    at t (c:\dev\cpt\ads\ads-web-services\node_modules\swagger-ui-dist\swagger-ui-bundle.js:1:402)
    at Object.<anonymous> (c:\dev\cpt\ads\ads-web-services\node_modules\swagger-ui-dist\swagger-ui-bundle.js:1:802)

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
goinggoodcommented, Jun 29, 2017

\swagger-api-doc\swagger-ui-bundle.js:73 j.default)(“JSONRefError”,function(e,t,n){this.originalError=n,(0,T.default)(this,t||{})}),L={},z=new C.default,q={key:“$ref”,plugin:function(e,t,n,r){var u=n.slice(0,-1),c=r.getContext(n).baseDoc;if(“string”!=typeof e)return new B(“$ref: must be a string (JSON-Ref)”,{$ref:e,baseDoc:c,fullPath:n});var l=a(e),p=l[0],h=l[1]||“”,d=void 0;try{d=c||p?i(p,c):null}catch(t){return o(t,{pointer:h,$ref:e,basePath:d,fullPath:n})}var m=void 0,v=void 0;if(!y(h,d,u,r)){if(null==d?(v=f(h),void 0===(m=r.get(v))&&(m=new B("Could not resolve reference: "+e,{pointer:h,$ref:e,baseDoc:c,fullPath:n}))):(m=s(d,h),m=null!=m.__value?m.__value:m.catch(function(t){throw o(t,{pointer:h,$ref:e,baseDoc:c,fullPath:n})})),m instanceof Error)return[N.default.remove(n),m];var =N.default.replace(u,m,{$$ref:e});return d&&d!==c?[,N.default.context(u,{baseDoc:d})]:g(r.state,)?void 0:}}},U=(0,T.default)(q,{docCache:L,absoluteify:i,clearCache:u,JSONRefError:B,wrapError:o,getDoc:c,spl

ReferenceError: self is not defined

We are facing this issue with swagger api. Appreciate the early solution to this issue.

0reactions
shockeycommented, Jul 12, 2017

@chaitralisk, can you please open a new ticket so we can help you with this? I want to minimize the noise for the five people getting emails about this thread.

Read more comments on GitHub >

github_iconTop Results From Across the Web

NameError: name 'self' is not defined - python - Stack Overflow
Default argument values are evaluated at function define-time, but self is an argument only available at function call time.
Read more >
NameError: name 'self' is not defined in Python [Solved]
Default arguments in Python are evaluated when the function is defined, however, self is an argument that represents the instance the method is...
Read more >
Python NameError: name 'self' is not defined - Softhints
Common errors for beginners related to self in Python is: NameError: name 'self' is not defined The keyword self is a special one...
Read more >
why does it keep saying "global name 'self' is not defined"
This is my code: class Car(object): condition = "new" def __init__(self, model, color, ... why does it keep saying "global name 'self' is...
Read more >
NameError: name 'self' is not defined : r/learnpython - Reddit
I have the following python code but it gives me the error in the title: "NameError: name 'self' is not defined" class foo:...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found