Questions tagged [flask-restx]

Flask-RESTX is an extension for Flask that adds support for quickly building REST APIs in Python. Flask-RESTX is a community-driven fork of Flask-RESTPlus, hence users can also make use of [flask-restplus] tag in addition to [flask-restx] to search for relevant issues and questions.

Flask-RESTX is an extension for Flask that adds support for quickly building REST APIs.

Flask-RESTX encourages best practices with minimal setup. If you are familiar with Flask, Flask-RESTX should be easy to pick up.

It provides a coherent collection of decorators and tools to describe your API and expose its documentation properly using Swagger.

Flask-RESTX is a community driven fork of Flask-RESTPlus


A Minimal API

A minimal Flask-RESTX API looks like this:

from flask import Flask
from flask_restx import Resource, Api

app = Flask(__name__)
api = Api(app)

@api.route('/hello')
class HelloWorld(Resource):
    def get(self):
        return {'hello': 'world'}

if __name__ == '__main__':
    app.run(debug=True)

Compatibility

Flask-RESTX requires Python 2.7 or 3.4+.

Documentation

The documentation is hosted on Read the Docs

108 questions
0
votes
0 answers

Flask swagger interactive UI

I took the TodoApp example for flask_restx. Swagger json is generated correctly but I want to have interactive Swagger like this I need your help on this matter. Here is the code that executed is generated the swagger.json from flask import…
Colateral
  • 1,736
  • 2
  • 18
  • 22
0
votes
0 answers

python flask route decorator in for loop has unexpected behavior

I try to register many namespaces for many 'devices' based of the same class. This seems working well. register namespaces After that I try to register the routes for every device and map them to the corresponding class functions. As seen in the…
Bugs
  • 11
  • 2
0
votes
1 answer

Create Flask Restx endpoints without namespaces

I'm working in the redesign of an API with Flask using Flask-restx, but I've a problem: We need a legacy version of the API that accepts the old urls, for compatibility reasons, but I'm not understanding how to do this since flask-restx requires a…
Efraín
  • 453
  • 1
  • 7
  • 13
0
votes
1 answer

Is it possible to create muti thread in a flask server?

I am using flask and flask-restx try to create a protocol to get a specific string from another service. I am trying to figure out a way to run the function in server in different threads. Here's my code sample: from flask_restx import…
0
votes
1 answer

How to pass a parameter from client side to server in python

I am using flask and flask-restx try to create a protocol to get a specific string from another service. I am wonder if there is a way I can pass the parameter from another function to server side. For example, here's my server side: from…
0
votes
1 answer

Dictionary type api.model in flask Restx

I am new to flask restx and trying to create a dict type api.model but I cannot find any example or documentation where it is mentioned, I am not sure if there is any work around to achieve this. Please share your ideas Here is my data I want to…
0
votes
0 answers

Why does flask_restx's reqparse can't filter nonetype parameter in json?

I find flask_restx's reqparse can't filter nonetype parameters in post json. For example. My resource: from flask_restx import Resource, reqparse class Login(Resource): def __init__(self, api=None, *args, **kwargs): …
Clarmy Lee
  • 130
  • 5
0
votes
1 answer

make at lease one argument mandatory in flask restx reqparser

from flask_restx import reqparse parser = reqparse.RequestParser(bundle_errors=True) parser.add_argument('foo', type=int) parser.add_argument('bar', type=int) I am implementing search endpoint where user can specify /item?foo=f or /item?bar=b to…
tempuser
  • 1,517
  • 3
  • 11
  • 15
0
votes
1 answer

Authenticate once using a json field with Flask-HTTPAuth and Flask-RESTX

I have set up an API using configured with auth protected endpoints as described in this excellent tutorial https://blog.miguelgrinberg.com/post/restful-authentication-with-flask My end user, however, wants to authenticate by passing a JSON and then…
0
votes
0 answers

Proper way to serve React frontend with Flask-RestX?

I'm trying to make a website where the APIs are defined with Flask-RestX and the React frontend can use those APIs. However, with the code below, and after running FLASK_APP=app.py flask run --host=0.0.0.0 --port=8000, the server won't return the…
Pirlo Lochisomo
  • 185
  • 1
  • 16
0
votes
0 answers

Customize flask-restplus swagger page for custom login

What I want to do is automatically generate a JWT token when a user log in with their Username and Password. Based on my current research, swagger does not support this functionality natively (see How to use UserName and Password in Swagger to…
Ben
  • 1
  • 1
  • 1
0
votes
1 answer

Enabling Cors with Flask RestX

Trying to add CORS to my flask app that is using an API created with flask-restx. Hopefully someone here can spot what I am doing wrong. In the console that is running flask I don't get any relevant logs and the website is saying Cross-Origin…
Jerakin
  • 455
  • 3
  • 17
0
votes
1 answer

Working with flask-jwt-extended and flask-restx for Headers and Cookie Token

I'm building an API with Flask-Restx, and I'm using flask-jwt-extended for the JSON web Token, I have views like this class InputReaderView(Resource): """Endpoint for validate args from PMR Response with XSD and Validate DataType from…
perymerdeka
  • 766
  • 9
  • 19
0
votes
0 answers

Flask-Restx: How to specify Swagger Request Body Expectation if Resource resides in a different module than the app/api?

All Swagger docs (https://flask-restx.readthedocs.io/en/latest/swagger.html) assume that the instantiation of the api is in the same place as the Resource. But if I have an app.py of the form from flask import Flask from flask_restx import Api from…
mgross
  • 550
  • 1
  • 7
  • 24
0
votes
0 answers

Gunicorn Server killed with signal 9 - way to reduce memory usage

I am trying to test code on gunicorn server on my local with flask_restx. The code is to create some groups and association rules then it tries to save the rules as a dictionary (originally) or into a pickle file while running as cron. The following…
Abhas Mehrotra
  • 119
  • 2
  • 9