Git Product home page Git Product logo

Comments (8)

pdusen avatar pdusen commented on July 29, 2024 2

Just opened a PR with this change: #19

from typescript-rest.

thiagobustamante avatar thiagobustamante commented on July 29, 2024 1

Fixed in version 1.0.3

from typescript-rest.

pdusen avatar pdusen commented on July 29, 2024

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.

cyphercider avatar cyphercider commented on July 29, 2024

@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.

pdusen avatar pdusen commented on July 29, 2024

@tamethecomplex I am running Windows, and I independently reached a similar conclusion.

from typescript-rest.

pdusen avatar pdusen commented on July 29, 2024

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.

cyphercider avatar cyphercider commented on July 29, 2024

Just confirmed the same myself.

from typescript-rest.

thiagobustamante avatar thiagobustamante commented on July 29, 2024

Thanks. I already merged the code.

from typescript-rest.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.