Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
bavardage opened this issue Jul 23, 2019 · 1 comment · Fixed by #100

Comments

@bavardage
Copy link
Contributor

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
Copy link
Contributor Author

bavardage commented Jul 23, 2019

endpointDefinition.args.forEach(argDefinition => {
if (IParameterType.isBody(argDefinition.paramType)) {
bodyArgs.push(argDefinition);
} else if (IParameterType.isPath(argDefinition.paramType)) {
pathArgNames.push(argDefinition.argName);
} else if (IParameterType.isHeader(argDefinition.paramType)) {
headerArgs.push(argDefinition);
} else if (IParameterType.isQuery(argDefinition.paramType)) {
queryArgs.push(argDefinition);
}
});
is where the path params are pulled out

then in

writer.write("pathArguments: [");
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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant