FeathersJS和Swagger UI:无法解析指针:/ definitions / messages

问题描述 投票:0回答:1

我尝试在我的项目中基于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
javascript node.js swagger-ui feathersjs
1个回答
1
投票

从错误消息显然,您必须在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中的完整示例。

© www.soinside.com 2019 - 2024. All rights reserved.