feathersjs-ecosystem / feathers-swagger

Add documentation to your FeatherJS services and feed them to Swagger UI.
MIT License
225 stars 62 forks source link

FeatherJS and SwaggerUI: Could not resolve pointer: /definitions/messages #113

Closed yasahmed closed 5 years ago

yasahmed commented 6 years ago

I tried to implement Swagger UI module in my project based on FeathersJS framework as shown below:

...
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);

But I got this error message. How can I fix it?

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
bravo-kernel commented 6 years ago

FWIW I had the same error trying to get the definition inside my service. Solved by changing the service structure gisted here.

Mairu commented 5 years ago

Use the service.docs.definition option if you dont want to handle lists yourself.