question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Intercept and correct input type `bool` in reqparse dicts

See original GitHub issue

See this issue for a discussion around how RESTplus parses the string “false” as true with type=bool.

We can fix this by intercepting the boolean parameter in the dicts that are being passed in @accepts or @reponds and casting them to flask_restplus.inputs.boolean

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
apryor6commented, Aug 30, 2019

First install pytest (pip install pytest), and then run pytest

There’s a pytest.ini file at the root source directory that configures pytest for you

1reaction
apryor6commented, Aug 24, 2019

isinstance should be preferred when checking the type of an object because it will also, in general, check subclasses of the type. In this specific case, it so happens that bool cannot be subclassed, but for consistency and readability isinstance is still better.

Read more comments on GitHub >

github_iconTop Results From Across the Web

RequestParser doesn't handle booleans submitted as 'false ...
When the RequestParser is given an argument of type bool, it parses any value as ... Intercept and correct input type bool in...
Read more >
flask restful: how to document response body with fields.Dict()?
In flask-restplus , I want to model the response body which has nested list strucure, so whenever make api call, response body will...
Read more >
Python - Test Boolean Value of Dictionary - GeeksforGeeks
Method #1: Using loop This is brute force method to solve this problem. In this, we iterate for each key and tag it...
Read more >
API — Flask Documentation (1.1.x)
In order to convert the return value to a proper response object, ... data – The request body, either as a string or...
Read more >
Input Types - Strateos
Demonstrated below are the input types and parameters to construct the manifest. ... "required" field accepts a boolean value that indicates if this...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found