代码之家  ›  专栏  ›  技术社区  ›  AHmedRef

featherjs和swaggerui:无法解析指针/定义/消息

  •  0
  • AHmedRef  · 技术社区  · 6 年前

    我尝试在基于feathersjs框架的项目中实现swagger ui模块,如下所示:

    ...
    messageService.docs = {
          description: 'A service to send and receive messages',
          definitions: {
            messages: {
              "type": "object",
              "required": [
                "text"
              ],
              "properties": {
                "text": {
                  "type": "string",
                  "description": "The message text"
                }
              }
            }
          }
        };
    
        const app = feathers()
          ....
          .configure(swagger({
            docsPath: '/docs',
            info: {
              title: 'A test',
              description: 'A description'
            }
          }))
          .use('/messages', messageService);
    

    但我收到了这个错误信息。我怎样才能修好它?

    Resolver error at paths./messages.get.responses.200.schema.$ref
    Could not resolve reference because of: Could not resolve pointer: /definitions/messages list does not exist in document
    
    1 回复  |  直到 6 年前
        1
  •  1
  •   Noval Parinussa    6 年前

    从错误消息中显然必须添加 '邮件列表' 在MessageService.docs定义属性中。

    如下:

    messageService.docs = {
      description: 'A service to send and receive messages',
      definitions: {
        messages: {
          "type": "object",
          "required": [
            "text"
          ],
        },
        "properties": {
          "text": {
            "type": "string",
            "description": "The message text"
          }
        },
    
        // add message list definitions
        'messages list': {
          "type": "object",
          "required": [
            "text"
          ],
          "properties": {
            "text": {
              "type": "string",
              "description": "The message text"
            }
          }
        }
      };
    

    您可以在 docs .

        2
  •  0
  •   bravo-kernel    5 年前

    如果你正在使用sequentize,你可能想尝试 https://github.com/alt3/sequelize-to-json-schemas . 它将自动为您生成模型模式。