Url parsing should handle params by name
Currently, url parsing works by matching types in the path to parameters being passed:
@HttpOperation(method = "POST",url = "/costs/{vyne.ClientId}/doCalculate")
operation calculateCreditCosts(@RequestBody CreditCostRequest, ClientId ) : CreditCostResponse
This example works as expected.
however, when working with imports from other languages (eg., swagger), where there isn't an advanced microtype presence, this is less appealing:
@HttpOperation(method = "GET",url = "http://pets.com/pets/{lang.taxi.Int}")
operation getPetById( petId : Int ):Pet
Here, I think that http://pets.com/pets/{petId}
is actually better, and clearer.
I think we should enhance the code that extracts params, to make it "smarter"
- Parse the Uri, extracting a map of requested params
- For each UriParam, try to match on type first (preferred, as it still encourages microtypes)
- If that fails, look to see if there's a match based on param name, bearing in mind that names for params are optional
- If that fails, error.
The relevant code is within RestTemplateInvoker.getUriVariables()
There's a test written as a starting point for this in RestTemplateInvokerTest.whenInvoking_paramsCanBePassedByTypeIfMatchedUnambiguously
Edited by Marty Pitt