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
3
votes
0 answers

How to require one of two fields with `fask_restplus` for endpoint

I have a model like this: my_resource_model = api.model( RESOURCE_NAME, 'month_id': rest.fields.String, 'week_id': rest.fields.String ) And a Resource like this: class MyResource(Resource): @api.expect(my_resource_model): def post(self): …
Jon Rose
  • 1,457
  • 1
  • 15
  • 25
3
votes
2 answers

Multiprocessing with flask sqlalchemy - psycopg2.DatabaseError: error with status PGRES_TUPLES_OK and no message from the libpq

am getting below exception while trying to use multiprocessing with flask sqlalchemy. sqlalchemy.exc.ResourceClosedError: This result object does not return rows. It has been closed automatically. [12/Aug/2019 18:09:52] "GET /api/resources…
3
votes
0 answers

Swagger UI issue with multiple route parameters

I am essentially trying to create two endpoints, one where time is passed and if the time isnt passed it takes on a default value. It works completely fine when I use the request url, I get the output I require. However, the swagger UI still shows…
Aman Agarwal
  • 31
  • 1
  • 6
3
votes
1 answer

Flask RestPlus: how to catch all exceptions and output the original error

I'm trying to catch all exceptions that may happen and output the stack details as message in FlaskRestPlus. The below is an example that works if I raise custom exception such as RootException. But I didn't manage to get it to work with…
Nickpick
  • 6,163
  • 16
  • 65
  • 116
3
votes
1 answer

How to handle multiple 'GET' endpoints in a Flask-Restplus response class

I'm just starting learning Flask and are trying to create a simple API dealing with a data processing backend (named ATExplorer). I started by creating a 'backend' namespace, i.e. backendAPI: from flask import Flask, Blueprint, redirect,…
Totte Karlsson
  • 1,261
  • 1
  • 20
  • 55
3
votes
1 answer

Flask-RESTPlus - Nested Fields not getting registered into SwaggerUI

I'm trying to create a Nested field to a response model. I don't unserstand why the generated swagger.json is aware of the nested field but do not register it under $/definitions. This is my Model HypervisorResponse = ns.model('HypervisorResponse',…
Bruno Araújo
  • 91
  • 2
  • 9
3
votes
1 answer

How to define dictionary fields with flask_restplus to be used in go code generated with swagger codegen?

I have used swagger CLI to generate go code to call my flask app. swagger codegen converts fields.Raw type defined with flask_restplus model to *interface{} in go assigning the value to the field with *interface{} type in go returns…
Azadeh Khojandi
  • 3,806
  • 1
  • 30
  • 32
3
votes
1 answer

How can I enforce Basic Auth in Flask Restplus Swagger UI?

I am developing a back-end and using Flask Restplus. So far the code works great and the Swagger UI looks great too. I am considering adding Basic Auth on a particular endpoint (I am planning on using a Basic Auth Decorator from a previous…
3
votes
1 answer

Remove added error information from response

Using flask-restplus I've noticed that if I handle some error like: api.abort(code=404, message='Item not found') The response renders: { "message": "Item not found. You have requested this URI [/item/1] but did you mean…
tutuca
  • 3,444
  • 6
  • 32
  • 54
3
votes
1 answer

How to set base url for swagger with flask_restplus?

I'm serving a flask app with flask_restplus from an apache server. I'm using ProxyPass to forward all traffic to the app at some url extension like so in the apache .conf file: ProxyPass /some-extension http://127.0.0.1:3000 ProxyPassReverse…
3
votes
1 answer

Why @api.doc decorator python flask restplus not update the changes I make?

I using Flask-Restplus to develop my API. I wanna to ask,why the @api.doc decorator not update my changes in the Swagger UI? Here is the endpoint I define @api.route('/create_user') class User(Resource): @api.response(201, 'User successfully…
ken
  • 2,426
  • 5
  • 43
  • 98
3
votes
1 answer

flask test_client returns 404 for valid url

I've been writing an API and I want to test it. Get requests to API by requests are working well but when I want to test by test_client I have always received I handled a 404 error and checked if the URL is…
3
votes
1 answer

How to get Flask_restplus to use error handlers from app_errorhandler?

I am trying to use global error handlers(app_errorhandler) in my APIs but I am getting some problems. I have a blueprint for errors where I define global errors defined as: from werkzeug.exceptions import NotFound from flask_app.errors import…
kemis
  • 4,404
  • 6
  • 27
  • 40
3
votes
1 answer

Flask Restplus Swagger Not Loading Behind Nginx

I have a Flask API and a Swagger UI generated with Flask Restplus. The API runs in a Docker container behind an Nginx container which serves it over HTTP. Here is a health check endpoint which confirms the API is…
Alexis.Rolland
  • 5,724
  • 6
  • 50
  • 77
3
votes
2 answers

fetch always pass with OPTIONS method

I made API server with flask-restplus. Also use cors module for avoid CSP issue. And frontend is React.js. My code is here. class ArticleList(Resource): def post(self): print(1) return {"status":"true", "result":"article write…
Hide
  • 3,199
  • 7
  • 41
  • 83