Comments (8)
Just opened a PR with this change: #19
from typescript-rest.
Fixed in version 1.0.3
from typescript-rest.
We're running into a similar issue.
// app.ts
import * as express from 'express';
import { Server } from 'typescript-rest';
import './api/controllers';
const app: express.Application = express();
Server.buildServices(app);
Server.swagger(app, './dist/swagger.yaml', 'api-docs');
app.listen('4000', () => {
console.log('REST Server listening on port 4000!');
});
Looking at the debug output, it appears to me as though the route is not registering in the same way as the API routes. Compare /api-docs
with /hello
in the log:
express:application set "x-powered-by" to true +0ms
express:application set "etag" to 'weak' +7ms
express:application set "etag fn" to [Function: wetag] +11ms
express:application set "env" to 'development' +7ms
express:application set "query parser" to 'extended' +7ms
express:application set "query parser fn" to [Function: parseExtendedQueryString] +8ms
express:application set "subdomain offset" to 2 +11ms
express:application set "trust proxy" to false +5ms
express:application set "trust proxy fn" to [Function: trustNone] +11ms
express:application booting in development mode +7ms
express:application set "view" to [Function: View] +9ms
express:application set "views" to 'C:\\Repositories\\application\\views' +5ms
express:application set "jsonp callback name" to 'callback' +10ms
express:router use '/' query +15ms
express:router:layer new '/' +7ms
express:router use '/' expressInit +7ms
express:router:layer new '/' +5ms
express:router:route new '/hello/:name' +6ms
express:router:layer new '/hello/:name' +5ms
express:router:route get '/hello/:name' +7ms
express:router:layer new '/' +6ms
express:router:layer new '/' +9ms
express:router:route new '/hello/:name' +7ms
express:router:layer new '/hello/:name' +4ms
express:router:route acl '/hello/:name' +8ms
express:router:layer new '/' +5ms
express:router:route bind '/hello/:name' +8ms
express:router:layer new '/' +5ms
express:router:route checkout '/hello/:name' +5ms
express:router:layer new '/' +9ms
express:router:route connect '/hello/:name' +5ms
express:router:layer new '/' +5ms
express:router:route copy '/hello/:name' +5ms
express:router:layer new '/' +4ms
express:router:route delete '/hello/:name' +7ms
express:router:layer new '/' +5ms
express:router:route get '/hello/:name' +6ms
express:router:layer new '/' +6ms
express:router:route head '/hello/:name' +5ms
express:router:layer new '/' +5ms
express:router:route link '/hello/:name' +5ms
express:router:layer new '/' +5ms
express:router:route lock '/hello/:name' +6ms
express:router:layer new '/' +5ms
express:router:route m-search '/hello/:name' +7ms
express:router:layer new '/' +4ms
express:router:route merge '/hello/:name' +7ms
express:router:layer new '/' +4ms
express:router:route mkactivity '/hello/:name' +4ms
express:router:layer new '/' +7ms
express:router:route mkcalendar '/hello/:name' +7ms
express:router:layer new '/' +5ms
express:router:route mkcol '/hello/:name' +5ms
express:router:layer new '/' +4ms
express:router:route move '/hello/:name' +5ms
express:router:layer new '/' +62ms
express:router:route notify '/hello/:name' +3ms
express:router:layer new '/' +2ms
express:router:route options '/hello/:name' +4ms
express:router:layer new '/' +3ms
express:router:route patch '/hello/:name' +2ms
express:router:layer new '/' +2ms
express:router:route post '/hello/:name' +5ms
express:router:layer new '/' +1ms
express:router:route propfind '/hello/:name' +2ms
express:router:layer new '/' +5ms
express:router:route proppatch '/hello/:name' +1ms
express:router:layer new '/' +5ms
express:router:route purge '/hello/:name' +2ms
express:router:layer new '/' +4ms
express:router:route put '/hello/:name' +1ms
express:router:layer new '/' +5ms
express:router:route rebind '/hello/:name' +1ms
express:router:layer new '/' +5ms
express:router:route report '/hello/:name' +1ms
express:router:layer new '/' +4ms
express:router:route search '/hello/:name' +2ms
express:router:layer new '/' +4ms
express:router:route subscribe '/hello/:name' +1ms
express:router:layer new '/' +5ms
express:router:route trace '/hello/:name' +1ms
express:router:layer new '/' +5ms
express:router:route unbind '/hello/:name' +4ms
express:router:layer new '/' +2ms
express:router:route unlink '/hello/:name' +4ms
express:router:layer new '/' +1ms
express:router:route unlock '/hello/:name' +5ms
express:router:layer new '/' +2ms
express:router:route unsubscribe '/hello/:name' +4ms
express:router:layer new '/' +2ms
express:router:route new '\\api-docs\\json' +22ms
express:router:layer new '\\api-docs\\json' +1ms
express:router:route get '\\api-docs\\json' +2ms
express:router:layer new '/' +12ms
express:router:route new '\\api-docs\\yaml' +1ms
express:router:layer new '\\api-docs\\yaml' +6ms
express:router:route get '\\api-docs\\yaml' +8ms
express:router:layer new '/' +2ms
express:router use '\\api-docs' serveStatic +10ms
express:router:layer new '\\api-docs' +2ms
express:router use '\\api-docs' <anonymous> +2ms
express:router:layer new '\\api-docs' +3ms
REST Server listening on port 4000!
from typescript-rest.
@pdusen , are you running windows? We ran into an issue with Path.join here: thiagobustamante/typescript-rest-swagger#3, where the path library was inserting '\' instead of '/' when running on Windows.
from typescript-rest.
@tamethecomplex I am running Windows, and I independently reached a similar conclusion.
from typescript-rest.
Locally, I was able to resolve my problem by changing the implementation of Server.swagger
to use path.posix.join
instead of the current path.join
:
router.get(path.posix.join('/', endpoint, 'json'), (req, res, next) => {
res.send(swaggerDocument);
});
router.get(path.posix.join('/', endpoint, 'yaml'), (req, res, next) => {
res.set('Content-Type', 'text/vnd.yaml');
res.send(YAML.stringify(swaggerDocument, 1000));
});
router.use(path.posix.join('/', endpoint), swaggerUi.serve, swaggerUi.setup(swaggerDocument));
from typescript-rest.
Just confirmed the same myself.
from typescript-rest.
Thanks. I already merged the code.
from typescript-rest.
Related Issues (20)
- Response codes not appearing in generated swagger HOT 1
- How to respond with multipart/form-data HOT 1
- docs: Upgrade instructions for 2.X -> 3.X missing HOT 1
- Multiple @Security tags? HOT 1
- Multer HOT 1
- Wiki Example: Syntax Error / Typo
- ContextRequest doesn't have right types HOT 1
- swagger-ui-dist dependency with vulnerability at version 3.38.0
- How To Contribute ?
- @PreProcessor errors not catched by express error middleware HOT 1
- express limits
- Requesting to upgrade few internal dependent packages which seems to have potential fixes reported in OSS CVE
- PassportJS with Google OAuth strategy not working as expected
- @Options Method decorator
- Two routes beign called at the same time HOT 1
- Route calls next() after sending response
- Question, can i have multiple preproccesors?
- Migrate to tsoa? HOT 2
- Vulnerabilities busboy and dicer HOT 1
- whether support in @hapi/hapi
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 typescript-rest.