conjure-typescript icon indicating copy to clipboard operation
conjure-typescript copied to clipboard

Generated typescript incorrect if endpoint path args ordering doesn't match the order they appear in the path

Open bavardage opened this issue 6 years ago • 1 comments

What happened?

Generated code assumes the ordering of path params in the endpoint args block matches the ordering of those params in the path.

i.e. if you have

http: POST /{one}/{two}/{three}
args:
    two: string
    three: string
    one: string

the generated code will incorrectly substitute to create the path {two}/{three}/{one}

What did you want to happen?

The substitution should be based on the names of the params, not the ordering.

bavardage avatar Jul 23 '19 19:07 bavardage

https://github.com/palantir/conjure-typescript/blob/b39e8f4f4a4546d5583e36ae1d6d1466bc765436/src/commands/generate/serviceGenerator.ts#L156-L166 is where the path params are pulled out

then in https://github.com/palantir/conjure-typescript/blob/b39e8f4f4a4546d5583e36ae1d6d1466bc765436/src/commands/generate/serviceGenerator.ts#L203 they're passed only by position

they're then used in https://github.com/palantir/conjure-typescript-runtime/blob/develop/packages/conjure-client/src/fetchBridge/fetchBridge.ts#L165

bavardage avatar Jul 23 '19 19:07 bavardage