feathersjs-ecosystem / feathers-swagger

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

Create documentation for Feathers Custom API #224

Open steventanwc opened 3 years ago

steventanwc commented 3 years ago

Hi,

Thank you so much for the wonderful module.

I have managed to get mongoose API running.

However, can you advise how can we setup a custom endpoint (meaning one that is not connected to any table or collection)?

Thank you in advance

Steven Tan

Mairu commented 3 years ago

Hi Steven,

there is nothing different when creating/using a custom service. To create a custom service you can use the generator or just create a class that does not extend a adapter class, see https://docs.feathersjs.com/api/services.html#service-methods

The documentation for a service can always be customized with the same possibilities. Checkout the documentation for that https://github.com/feathersjs-ecosystem/feathers-swagger#servicedocs

  1. You can define anything of the spec for any method, here is an example how to make changes to the find method of a service: https://github.com/feathersjs-ecosystem/feathers-swagger/blob/master/example/openapi-v3/customMethods.js#L107
  2. You can completely define the methods spec, if nothing of the defaults should be reused.
  3. If only request or response schema have to be defined, you can define that and refer to it in the refs section of the service docs.