Q:

Override the path of my API in Springfox Swagger

I am using Spring REST with Springfox Swagger, and I had a method such as
@RequestMapping(method = RequestMethod.POST, value = "/my-methd")
@ApiOperation(value = "My method")

and all was working fine.
Now I notice there is a spelling mistake in the path. I already have clients using the existing API, so I would like to support both the old and new versions, but only have the new versions show up in the documentation.
I can correct it like follows:
@RequestMapping(method = RequestMethod.POST, value = {
   "/my-methd",  // Spelling mistake, deprecated
   "/my-method"  // To be used by new software
})
@ApiOperation(value = "My method")

However, both the old and new spelling show up in the Swagger docs.
I want both to work, but only the new spelling to show up in the Swagger docs.
The @ApiOperation has the facility to override the HTTP method, and many other things, but seemingly not the path.
Is there anything I can do here?
(I can't even mark the old method as "deprecated" in the docs, as the docs come from the method annotation, which is shared between the two paths.)

A:

I'd suggest to just create a new separate method, one with the misspelled RequestMapping "/my-methd", and one for the correct one "/my-method".
Then it's easy to mark the misspelled one as deprecated.
Also this way you can put proper comments in the code, so in the future it's easier to maintain / remove.

