Coffeescript 如何在express中设置昂首阔步?
我正在使用这个库,我的代码都在里面。根据我的定义,我有:Coffeescript 如何在express中设置昂首阔步?,coffeescript,swagger,swagger-ui,Coffeescript,Swagger,Swagger Ui,我正在使用这个库,我的代码都在里面。根据我的定义,我有: app.use swagger.init app, apis: ['./src/routes.coffee', './src/models.yml'] apiVersion: '0.1.0' basePath: "http://localhost:#{port}" info: title: 'My API' description: 'A complete listing of all API functi
app.use swagger.init app,
apis: ['./src/routes.coffee', './src/models.yml']
apiVersion: '0.1.0'
basePath: "http://localhost:#{port}"
info:
title: 'My API'
description: 'A complete listing of all API functions'
swaggerUI: path.join __dirname, 'public'
swaggerURL: '/swagger'
require('./src/routes') app
在路线中
,我有:
###
* @swagger
* path: /login
* operations:
* - httpMethod: POST
* summary: Login with username and password
* notes: Returns a user based on username
* responseClass: User
* nickname: login
* consumes:
* - text/html
* parameters:
* - name: username
* description: Your username
* paramType: query
* required: true
* dataType: string
* - name: password
* description: Your password
* paramType: query
* required: true
* dataType: string
###
这很好。我的model.yml
文件是:
definitions:
User:
properties:
user_id:
type: string
description: Unique ID to represent the user
first_name:
type: string
description: First name of the Uber user.
last_name:
type: string
description: Last name of the Uber user.
email:
type: string
description: Email address of the Uber user
picture:
type: string
description: Image URL of the Uber user.
promo_code:
type: string
description: Promo code of the Uber user.
但这并没有出现在
api docs.json
中。我试图在一个文件中定义模型
,在另一个文件中定义路径
。可以这样做吗?我认为它不会起作用,因为每种格式都是单独读取的,并保存在一个散列中,该散列使用resourcePath
作为键
相同resourcePath
的任何进一步声明都将覆盖以前的声明
我使用更新的yml格式进行了测试,其中包含resourcePath
、名称models
而不是definitions
,以及模型的唯一id
。这使得模型出现,但我的其他信息没有:/
resourcePath: /login
models:
User:
id: User
properties:
user_id:
type: String
description: Unique ID to represent the user
first_name:
type: String
description: First name of the Uber user.
last_name:
type: String
description: Last name of the Uber user.
email:
type: String
description: Email address of the Uber user
picture:
type: String
description: Image URL of the Uber user.
promo_code:
type: String
description: Promo code of the Uber user.
他们github上的示例使它看起来可以工作,但我无法让它工作