Questions tagged [flask-restplus]

Flask-RESTPlus is an extension for Flask that adds support for quickly building REST APIs documented with Swagger

Flask-RestPlus provide syntaxic suger, helpers and automatically generated Swagger documentation on top of Flask-Restful. It provides a bunch of decorators and helpers to quickly build documented and maintainable APIs with Flask.

Website: https://flask-restplus.readthedocs.io/

330 questions
2
votes
2 answers

Can't make Restplus Flask API run using uWSGI

I'm working on a Flask API which works fine. I'm now trying to replace the Flask development server with uWSGI but everything breaks. I'm trying to solve this since 2 days, went through tutorials and searched here but couldn't find a solution to the…
2
votes
1 answer

How to share a flask-pymongo instance in the api routes handler

I am trying to design a simple api using flask, flask-restplus, and flask-pymongo but I'm facing one structural design, based on import and variables sharing, I cannot get access to the db in any way. Here is my code in my main engine file: app =…
Mumrau
  • 62
  • 7
2
votes
1 answer

How to marshal nested attribute up to the schema?

I have a project with articles having different prices depending on their location. The Article and ArticlePrice models are as follow: from flask_sqlalchemy import SQLAlchemy from sqlalchemy.orm import relationship db = SQLAlchemy() class…
Elfayer
  • 4,411
  • 9
  • 46
  • 76
2
votes
2 answers

How to pass URLs as parameters in a GET request within python flask (restplus)?

I am creating a REST API using python flask. The API is ready and works on port number 8000 of my localhost. Now I intend to give this REST API a user friendly interface for which I decided to go with python - restplus. I thought of calling this…
Harry
  • 137
  • 1
  • 7
2
votes
1 answer

How to call an API in Flask Restplus?

I'm trying to figure out how can I call an API using Flask-Restplus (normally, I'd just use API key, as it always was possible - let's say the easiest example is weather). I know how I can do it in Flask, but have no idea how can I do it in…
Alice Jarmusch
  • 467
  • 1
  • 7
  • 20
2
votes
1 answer

flask restplus - pass arguments after '?' and keep arg input form in web interface

I've been able to write this code from flask_restplus.resource import Resource from flask_restplus import reqparse @ns.route('') class ExampleClass(Resource): @ns.response(500, 'generic error') def get(self): parser =…
user1403546
  • 1,680
  • 4
  • 22
  • 43
2
votes
1 answer

How can I marshal a pickled object through an API ( preferably using flask-restplus )?

I have an API fully documented and finished, built in python 3.5/flask using flask-restplus. I'd like to add one chunk of functionality - returning a pickled object as part of one of my responses. General solutions not specific to flask-restplus are…
thclark
  • 4,784
  • 3
  • 39
  • 65
2
votes
2 answers

How to send authentication credentials in app.post for Flask unit testing of API views

I have written a Flask application. In that, I am using basic auth to restrict certain POST API views. From Python requests, I can access those views as - print post(url, json=data, auth=('username', 'password')) And from curl, curl -a…
Avi
  • 1,341
  • 1
  • 18
  • 28
2
votes
1 answer

Fix "unsupported date format" when marshaling data from rest endpoint

I am trying to figure out why the date is not working in flask-restplus. MarshallingError: Unable to marshal field "lastUpdate" value "": Unsupported DateTime format 127.0.0.1 - - [16/Apr/2016…
nycynik
  • 7,371
  • 8
  • 62
  • 87
1
vote
0 answers

Swagger UI - TypeError: Failed to fetch on Chrome Browser

I am currently using Swagger UI version 3.19.0 with Flask-RestPlus version 0.13.0 and testing out unauthorised (401) response of uploading file endpoint of my deployed python flask application on Chrome. The problem is that I am getting TypeError:…
Min
  • 11
  • 2
1
vote
0 answers

How to model a complex list in Flask

My API is returning lists with three entries like so (pseudocode only) results=[] for db_row in db_rows: result = [] result.append (db_row[0]) # Name (string) result.append (db_row[1]) # Age (int) result.append (db_row[2]) # DOB…
1
vote
1 answer

flask restx - pytest in not working with error handler

I am building API using Flask Restx. I had written a generic exception handler which will throw an error message and code in Json format. @app.errorhandler(APIError) def handle_invalid_usage(error): logger.opt(exception=True).error(error) …
Arul
  • 143
  • 3
  • 12
1
vote
0 answers

Swagger (using flask-restx/plus) optional list/nested JSON

I need the API to accept: { 'field1' : 10, 'children' : [ 'c1', 'c2' ] } and also { 'field1' : 10, } i.e., when there are no children the field can be skipped. I tried defining the model: 'field1' : fields.Integer(example=42), …
mibm
  • 1,328
  • 2
  • 13
  • 23
1
vote
1 answer

How to specify a generic dictionary in payload of flask-restplus/flask-restx?

I have an API which receives a JSON looking like this { "some_key" : [ "v1", "v2" ] "another_key" : [ a1, a2, a3, a4 ] ... } So I wanted to define something along these lines dict_model = api.model('ArbitraryDict', { fields.String :…
mibm
  • 1,328
  • 2
  • 13
  • 23
1
vote
2 answers

How to return a nested json response in Flask-Restx

I am trying to make an API with Flask-RestX that can show a response like this, { "id": 1, "msg": "How are things", "score": 345, "additional": { "goal": 56, "title": "ASking how" } } when data is like this (In my case, I do not…
realsdx
  • 28
  • 2
  • 7