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
5
votes
1 answer

Flask -Restplus + swagger, how to restrict to authenticated users +/ roles

I have a Flask-Restplus endpoint like so: @api.route('/apps/') @api.doc(params={'uid': 'UUID of the app agent.'}) class AppAgentAPI(Resource): @login_required @api.marshal_with(app_agent) def get(self, uid): …
David Simic
  • 2,061
  • 2
  • 19
  • 33
5
votes
2 answers

SQLAlchemy LookupError: "DIVERSE" is not among the defined enum values

I'm trying to build simple REST API with single table with the help of SQLAlchemy, Marshmallow and flask-restplus. But it is giving LookupError. Following error is given by during the application usage: File…
5
votes
2 answers

specific time format for api documenting using flask restplus

I have an api which accepts start_time, end_time and a boolean closed_all_day in body of the request. from flask_restplus import Namespace, fields timings = api.model('open times', { 'start_time': fields.String(required=True, description='Time…
Mateen-Hussain
  • 718
  • 1
  • 13
  • 29
5
votes
2 answers

Flask RestPlus inherit model doesn't work as expected

So I have this model in Flask RestPlus: NS = Namespace('parent') PARENT_MODEL = NS.model('parent', { 'parent-id': fields.String(readOnly=True, 'parent-name': fields.String(required=True) }) CHILD_MODEL = NS.inherit('child',…
4c74356b41
  • 69,186
  • 6
  • 100
  • 141
4
votes
2 answers

marshmallow ValidationError not handled correctly by flask error handler

I don't know if this matters, but I'm actually using flask-restplus extension. All of my other flask error handlers work as expected, but for some reason when handling a marshmallow ValidationError, the response is just my original request body,…
LRH
  • 43
  • 1
  • 5
4
votes
2 answers

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 be returned what I expected. In responce body, it has a nested structure, I don't know how to document that. Am I…
beyond_inifinity
  • 443
  • 13
  • 29
4
votes
3 answers

How to accept None for String type field when using Flask-RESTPlus

I am just starting develop with flask-restplus and I am not a native speaker, but I will try to describe my question as clear as I can. I know there is a fields module in flask that help us define and filter response data type, such as String,…
Roy Kuo
  • 43
  • 1
  • 5
4
votes
1 answer

Adding multiple json fields in flask_restplus RequestParser

I want to expect a request where the request.json looks like: { "app_name": "app", "model_name": "model" } I created the following parser: parser = reqparse.RequestParser() parser.add_argument('app_name', location='json',…
nish
  • 6,952
  • 18
  • 74
  • 128
4
votes
0 answers

Does Flask RESTPlus support the Open API response examples property?

Given a Flask RESTPlus model like: todo = api.model("Todo", { "id": fields.Integer(example=123), "task": fields.String(example="Feed the cat") }) I want Flask RESTPlus support the Open API response examples property, to export a spec…
LaSmell
  • 151
  • 8
4
votes
0 answers

Use existing sql-alchemy model class as flask-restplus api.model?

I am developing a CRUD application using vue.js and vuetify as frontend (view) and python flask-resplus and sqlAlchemy as backend (controler and model). app/main/model/person.py from sqlalchemy import Column, Integer, String, Date from…
wuz
  • 483
  • 3
  • 16
4
votes
1 answer

How to protect swagger documentation with password

I am building a flask app and need to add password for swagger documentation in production, but dont know how. Here is my code: api = Api( version='1.0', title='API', description='Main API', doc='/doc', …
Ali Kompany
  • 81
  • 1
  • 8
4
votes
3 answers

how to hide password with ********* on swagger ui with flask_restplus in python

Hi Below is my running code , can be accessed with below URL: http://127.0.0.1:5000/api/documentation from flask import Flask, Blueprint from flask_restplus import Api, Resource, fields app = Flask(__name__) blueprint = Blueprint('api', __name__,…
4
votes
1 answer

Flask-restplus returning marshal model instead of the data

So I'm pretty new to implementing flask-restplus and I have encountered this road block. I have read the restplus docs over and over again and followed several exampled. But the behavior that I'm facing is very much different from what is supposed…
hrishikeshpaul
  • 459
  • 1
  • 11
  • 27
4
votes
2 answers

How to generate a machine readable yaml specification of an existing API written in flask-restplus?

I have a simple API written with the help of flask-restplus: from flask import Flask from flask_restplus import Resource, Api app = Flask(__name__) # Create a Flask WSGI application api = Api(app) # Create…
Riko
  • 155
  • 1
  • 3
  • 10
4
votes
1 answer

Flask-restplus: any way to sort the namespaces in swagger?

Is there any way to sort the Namespace entries after they've been added to the Api? I'm following the documentation, and the flow (AFAIK) appears to be: a) Create the API: api = Api(version="1.0", title="MahApi", description="Mah Nice…
Ojingo
  • 202
  • 2
  • 9
1 2
3
21 22