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

[Typescript] Return type of mockserver's RequestHandler.response is void, but should be boolean #4182

Closed
C5233991 opened this issue Jan 17, 2025 · 2 comments

Comments

@C5233991
Copy link

According to Step 4: Calling a Function Import of OData mock server tutorial:

We finally respond on the XHR object by calling the respondJSON API. It will add the proper content type header for the JSON format and send the result. We provide the HTTP status code 200 (success) and the 'stringified' response data as the arguments. Returning true at the end of the function indicates that we have completed the processing of the request in this handler (no additional request handlers should be checked for that request).

However, RequestHandler interface of Mockserver has return method as void:

  export type RequestHandler = {
    /**
     * Any HTTP verb
     */
    method: HTTPMETHOD | keyof typeof HTTPMETHOD;
    /**
     * A string path is converted to a regular expression, so it can contain normal regular expression syntax.
     *
     * All regular expression groups are forwarded as arguments to the `response` function. In addition to this,
     * parameters can be written in this notation: `:param`. These placeholders will be replaced by regular
     * expression groups.
     */
    path: string | RegExp;
    /**
     * A response handler function that will be called when an incoming request matches `method` and `path`.
     * The first parameter of the handler will be a `Response` object which can be used to respond on the request.
     */
    response: (p1: Response, p2: any) => void;
  };

Taken from "@sapui5/types": "1.131.1"

@IlianaB
Copy link
Member

IlianaB commented Jan 17, 2025

Hello @C5233991 ,
Thank you for sharing this finding. I've created an internal incident DINC0385231. The status of the issue will be updated here in GitHub.

Regards,
Iliana

@viktorsperling
Copy link
Member

viktorsperling commented Jan 20, 2025

Hello @C5233991,

thank you for pointing this issue out. We have created a change fixing this.
I will close this issue as we will continue working on this issue via our internal ticket. The fix will be available with the next release (1.133.0).

Best regards,
Viktor

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

No branches or pull requests

3 participants