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

Make HttpClient#buildRequest headers and options parameter mandatory #984

Closed
wants to merge 2 commits into from

Conversation

Mik13
Copy link
Contributor

@Mik13 Mik13 commented Oct 17, 2017

With #979 I sadly introduced a bug, because the two parameters are optional, despite the fact that they are not marked as such in the jsdoc comment.

This commit makes them mandatory and should fix the tests.

@@ -159,7 +159,7 @@ export function listen(server: any, options: IServerOptions): Server;

export class HttpClient {
constructor(options?: IOptions);
buildRequest(rurl: string, data: any | string, exheaders?: { [key: string]: any }, exoptions?: { [key: string]: any }): any;
buildRequest(rurl: string, data: any | string, exheaders: { [key: string]: any }, exoptions: { [key: string]: any }): any;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sync ts with jsdoc

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit confused. They weren't mandatory before. Why should they be mandatory now?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not. The jsdoc does not mark them as optional, and there is only one instance, which does not set them to an empty object like all the others. So if we just set them to an empty object by default in this one instance, we can make the parameters mandatory and do not have to handle a falsy value in this function, thus taking complexity out of it

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Documentation is one thing. If the implementation had them as optional in the past, then I'm of the opinion that we should update the documentation i.e. ts file or jsdoc.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this even a method that most users of node-soap would use? If not, then I'm fine with this change.

var request_headers = options.wsdl_headers;
var request_options = options.wsdl_options;
var request_headers = options.wsdl_headers || {};
var request_options = options.wsdl_options || {};
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those are the only instances where the two parameter may become falsy

@jsdevel
Copy link
Collaborator

jsdevel commented Oct 18, 2017

Being that these have been optional for a while, I'm deciding that we shouldn't make them required now. It is possible that others have been interfacing with the HttpClient directly.

I updated master so the tests should pass now. If you'd like to update the JSDoc/tsdoc to mark the parameters as optional feel free.

@Mik13
Copy link
Contributor Author

Mik13 commented Oct 19, 2017

Works for me, thank you!

@Mik13 Mik13 closed this Oct 19, 2017
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 this pull request may close these issues.

2 participants