what is the proper way to create a swagger web service in TypeScript

I am part of a project written in TypeScipt and I am trying to add TypeScript Web Server which will be compatible with Swagger.
What is the most basic strategy to implement it, considering easy maintainability.

  • For Typescript I have notice that exists 'Typson' library for generating a JSON Model from TypeScript Interface.

  • For Swagger, I have tried using 'swagger-node-restify' library, since it supports adding JSON models to swagger.

  • However, I encounter some problems:

  • Typson doesn't support typeScript syntax of Import - ( import {Server} from "restify" )
  • I tried to implement the 'swagger-node-restify' example (Pet Example), however the RESPONSE of the localhost:8080/api-docs.json GET Request is missing all the SPEC data of the API. {"apiVersion":"0.1","swaggerVersion":"1.1","basePath":"http://localhost:8080","apis":[{"path":"/api-docs.{format}/pet","description":"none"}]}

  • I suggest to describe a Swagger compliant API using yaml or json and to generate the server from that.

    swagger-server can build APIs on top of express in real time (no source code generation).

    There are JavaScript code generators :

  • Call the swagger-codegen client with -l nodejs-server

  • swagger-node is a great alternative but seems hard to integrate with TypeScript

  • 链接地址: http://www.djcxy.com/p/32786.html

    上一篇: 相机在通话正在运行时打开应用程序时冻结

    下一篇: 在TypeScript中创建一个Swagger Web服务的正确方法是什么?