Skip to content
Advertisement

Replace @PathVariable object with ID only for Springdoc

I am currently trying to migrate from Springfox to Springdoc.

Most of my endpoints contain a @PathVariable Instance. Obviously I am only passing in the ID of the instance and Spring would automatically resolve the object for me.

Here is an example:

JavaScript

Called as /api/myInstance/role.

Springfox would handle this correctly for me, only generating {instance} as a String mapping to the ID of Instance. However, Springdoc expects the entire object to be passed as a path param.

I did try this so far, however it didn’t seem to have any effect:

JavaScript

If possible, I’d like to avoid annotating hundreds of endpoints with the same annotation and solve this on a global level.

Advertisement

Answer

You can define your own ParameterCustomizer:

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement