feathersjs-ecosystem / feathers-swagger

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

Feature: add support for `service.id` as array of columns #194

Closed dekelev closed 4 years ago

dekelev commented 4 years ago

When integrating this lib with feathers-objection & feathers-cassandra services, service.id property can be an array of column names that represent a composite PK.

In addition, there's the service.idSeperator property that default to , so a composite PK can be set as ID with REST, e.g. /users/firstPathParam,secondPathParam.

I didn't find any workaround for this issue in the lib options. The only thing that worked was changing the file feathers-swagger/openapi.js:line 190 to:

swaggerPath += `/{${Array.isArray(methodIdName) ? methodIdName.join(`}${service.idSeparator}{`) : methodIdName}}`;

Is there anything I'm missing here? should we integrate this logic into the lib or expose a method in the options to control it?

Mairu commented 4 years ago

Hi, I guess it should be part of the lib itself, but there are more things that would need to be changed. service.id is used in other places too.

dekelev commented 4 years ago

Cool, I'll PR this later with tests for your review. thanks!

Mairu commented 4 years ago

PRs are welcome. As a hint, if you need it fast, you should target v1 branch, I guess master (and v2) will still take a while. Of course this would only be valid if there are no BC breaks.

dekelev commented 4 years ago

I've opened a PR on v2 (master branch). I'll check v1 soon. There are no breaking-changes.

dekelev commented 4 years ago

Added another PR on v1 branch.

Mairu commented 4 years ago

Merged it into v1 branch.