Comments (4)
import koaSwagger from 'koa2-swagger-ui';
is working for me. maybe make sure you have "esModuleInterop": true,
in your tsconfig.
here's what i'm using
{
"compileOnSave": false,
"compilerOptions": {
"moduleResolution": "node",
"lib": ["es2018"],
"target": "es2017",
"module": "commonjs",
"esModuleInterop": true,
"strict": true,
"noImplicitAny": false,
"noUnusedLocals": true,
"declaration": true,
"sourceMap": true,
"inlineSources": true,
"outDir": "dist"
},
"include": ["src/index.ts"]
}
from koa2-swagger-ui.
Thanks Scott!
Adding "esModuleInterop": true
worked but I had to update a bunch of other imports to use that style. Sounds like a discussion on requiring esModuleInterop could end in a holy war so I'll just take my win and run.
Thanks again!
from koa2-swagger-ui.
Itβs probably because I tried to keep backwards comparability with the previous nodejs version. Oh well
from koa2-swagger-ui.
Okay @nodehack (and others), here's a workaround that allows you to include the library
- saves you from having to turning on
esModuleInterop
(which is great since that messes up every other import) - it also gets you the types
import { KoaSwaggerUiOptions } from 'koa2-swagger-ui';
type koa2SwaggerUiFunc = (config: Partial<KoaSwaggerUiOptions>) => Koa.Middleware
// tslint:disable-next-line: no-var-requires // We actually have to use require for koa2-swagger-ui
const koaSwagger = require('koa2-swagger-ui') as koa2SwaggerUiFunc;
from koa2-swagger-ui.
Related Issues (20)
- Serve local json or yaml swagger file HOT 1
- implements multiple namspace? HOT 1
- Action Required: Fix Renovate Configuration
- About the "example with koa-router" in README HOT 1
- Uncaught ReferenceError: SwaggerUIBundle is not defined HOT 8
- use `module.exports.default` instead of `module.exports` HOT 1
- Missing lodash dependency when running in production HOT 1
- OAuth2 implicit flow not working HOT 4
- V5.0.5 isn't loading doc HOT 7
- Swagger-ui v3.38 is not loading HOT 1
- [bug] failed to parse Circular structures HOT 2
- The automated release is failing π¨
- koa2-swagger-ui does not render the swagger.json file and it shows error messages HOT 3
- TypeError: koaSwagger is not a function HOT 1
- multiple spec files and urls
- Black Duck Vulnerability
- Error in Building Project Using TypeScript Configuration HOT 1
- Consider to move @types/koa to devDependencies HOT 1
- UI does not render response examples correctly when a response has multiple examples HOT 2
- Http interceptor
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from koa2-swagger-ui.