feathersjs-ecosystem / feathers-swagger

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

How can I get correct prefix with $ref in related models? #250

Closed skilltryck closed 1 year ago

skilltryck commented 1 year ago

I have spent a few days now trying to get feathers-swagger@pre working with related models using Type.Ref()

Can't seem to find any way to use correct prefix for $ref. It always ends up as "[Model]" but seems to me it should be "#/components/schemas/[Model]".

Can someone point me in the right direction on how to fix this?

Mairu commented 1 year ago

Hi, I am sorry that I have not found the time to finish the new release yet. I was experimenting with extending the sanitizeSchema function to replace the refs with working ones.

You can see what I have tried in https://github.com/feathersjs-ecosystem/feathers-swagger/blob/wip_3.0/lib/utils.js#L76 As this is then more than sanitizing in the end I think I will rename the parameter for the final version to something like transformSchema.

So for now you can add your own sanitizeSchema function and provide it as a parameter when calling createSwaggerServiceOptions.

skilltryck commented 1 year ago

Thanks! I will take a look at your example and try to implement that as my own sanitizeSchema function.