-
Notifications
You must be signed in to change notification settings - Fork 90
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
fix for operationContextParam codegen #1475
Conversation
*/ | ||
export interface OperationContextParamInstruction { | ||
type: "operationContextParams"; | ||
get(input: any): any; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can I assume that the path expression is solely based on the input? No other parameters are needed, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. As per internal documentation
The
operationContextParams
trait defines one or more context parameters that MUST be bound to values specified in the operation input using a JMESPath expression
b40efff
to
3b3ba74
Compare
@@ -344,7 +344,7 @@ private void generateEndpointParameterInstructionProvider() { | |||
operationContextParamValues.forEach((name, jmesPathForInputInJs) -> { | |||
writer.write( | |||
""" | |||
$L: { type: \"operationContextParams\", name: $L }, | |||
$L: { type: \"operationContextParams\", get: (input?: any) => $L }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These need to be functions because there is no this
at the time the instruction is evaluated. The instruction sits in the global/module scope due to the use of classBuilder to create commands.
export class XCommand extends $Command.
classBuilder<...>()
.ep({
...commonParams,
MemberName: { type: "operationContextParams", get: (input?: any) => ... },
})
...
.build() {
protected declare static __types: { ... }
}
Internal JS-5629
This PR fixes codegen for operationContextParam by changing the path expression result into a mapping function based on the command's input. The getter functions are made non-throwing so as not to perform unintentional client side validation.