Skip to content

Optional named parameters of value None #5

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

Closed
jonathanpaek opened this issue Sep 17, 2016 · 2 comments
Closed

Optional named parameters of value None #5

jonathanpaek opened this issue Sep 17, 2016 · 2 comments
Assignees

Comments

@jonathanpaek
Copy link

api_response = api_instance.get_normalized_messages(uid=uid, sdid=sdid, mid=mid, field_presence=field_presence, filter=filter, offset=offset, count=count, start_date=start_date, end_date=end_date, order=order)

may affect the other SDKs as well.

looks like swagger is is already taking a look as it doesn't yet support optional params for all languages yet
swagger-api/swagger-codegen#3665

@yujingwu
Copy link
Member

yujingwu commented Sep 18, 2016

@jonathanpaek

If a parameter (e.g. uid) is an optional request parameter of REST call Get normalized messages, you can pass it as None (Python's null equivalent) when using the corresponding python sdk method (mentioned above), .

For example,
api_response = api_instance.get_normalized_messages(None, sdid, None, None, None, None, 2, start_date, end_date, None);

Does this solve your problem?

@jonathanpaek
Copy link
Author

No - Using None in that fashion results in a compilation TypeError.

However, I tried setting None specifically with named arguments in the following fashion:

api_instance.get_normalized_messages(uid=None, sdid=None, ..., count=None, order=None)

This would still results in type error, for example, since None cannot convert to an int type for certain types, for example. However, some luck - the workaround would be to not include the parameter at all within the method call. For example:

api_instance.get_normalized_messages()

After more investigation, the problem appears to be 2 things: 1) type checking 2) and when None is set as a named argument, the request is not omitting the request parameter.

@jonathanpaek jonathanpaek changed the title Optional parameters are being required in generated code Optional named parameters of value None Sep 19, 2016
@jonathanpaek jonathanpaek self-assigned this Sep 19, 2016
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

2 participants