Questions tagged [flasgger]

Easy OpenAPI specs and Swagger UI for your Flask API

Flasgger is a Flask extension to extract OpenAPI-Specification from all Flask views registered in your API.

Flasgger also comes with SwaggerUI embedded so you can access http://localhost:5000/apidocs and visualize and interact with your API resources.

Flasgger also provides validation of the incoming data, using the same specification it can validates if the data received as as a POST, PUT, PATCH is valid against the schema defined using YAML, Python dictionaries or Marshmallow Schemas.

Flasgger can work with simple function views or MethodViews using docstring as specification, or using @swag_from decorator to get specification from YAML or dict and also provides SwaggerView which can use Marshmallow Schemas as specification.

Flasgger is compatible with Flask-RESTful so you can use Resources and swag specifications together, take a look at restful example.

Flasgger also supports Marshmallow APISpec as base template for specification, if you are using APISPec from Marshmallow take a look at apispec example.

52 questions
5
votes
1 answer

Sort Swagger Tags

Hi I'm using flasgger/swagger but I was wondering if there are feature where in I could sort all my tags in alphabetical order? right I don't understand the order of my tags. It's neither Alpha nor Numeric. Sample order is like this User - API…
MadzQuestioning
  • 3,341
  • 8
  • 45
  • 76
5
votes
1 answer

Flasgger - Upload File

I am working on a project that requires to upload a file via flasgger UI. I modified my conf based on Swagger docs but doesn't seem to work. Below is my conf. Please, let know the mistake. """ This API let's you train word embeddings Call this…
4
votes
1 answer

Why flasgger is working with localhost but not with my deployed server?

I am using a python flask app and for API documentation using flasgger. When I run my flask app locally http://localhost:8086/swagger/ I am getting the swagger UI properly. Now we have deployed our application with an Nginx front-facing service.…
Danish Xavier
  • 1,225
  • 1
  • 10
  • 21
4
votes
2 answers

Flasgger - Add bearer authorization

I am running a flask app and using flasgger to generate Swagger Specs as well as a Swagger UI. My API requires the requests to be authenticated using a bearer token. I am able to get the button on the page and set the token. But it is not sent…
arunmmanoharan
  • 2,535
  • 2
  • 29
  • 60
4
votes
2 answers

Including external yml file in flasgger

I'd like to create a separate definitions.yml file using json remote references, so I can share the definitions across multiple YML files. We followed the instructions in https://azimi.me/2015/07/16/split-swagger-into-smaller-files.html by moving…
arthuston
  • 227
  • 1
  • 3
  • 10
4
votes
1 answer

Python (Flask + Swagger) Flasgger throwing 404 error

I am trying to use swagger ui as a frontend to query my flask application. I'm using Flasgger I tried a toy example as shown below from flasgger import Swagger from flask import Flask, logging app = Flask(__name__) Swagger(app) # ENDPOINT =…
Betafish
  • 1,212
  • 3
  • 20
  • 45
2
votes
1 answer

How to have marshmallow definitions and multi-version specs together in flasgger?

I'm going to load initial definitions from marshmallow schemas with Flasgger and APISpec. Also along with that, I want to have multiple version API doc. Here is my code: from app.api.v1.controllers.assessment_controller import…
Mojtaba
  • 786
  • 1
  • 9
  • 18
2
votes
0 answers

Flasgger failed to load API definition

I get this error message when trying to see the Swagger UI with Flasgger: ERROR in app: Exception on /apispec_1.json [GET] Traceback (most recent call last): File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 2446, in wsgi_app …
Mike4
  • 103
  • 1
  • 1
  • 4
2
votes
1 answer

How can I make Flasgger automatically validate flask-restful resource endpoints against the template_file?

TLDR; What I'm looking to achieve: Since there's the option to load an universal/app-wide schema in flasgger, as defined by the template_file parameter when instantiating Swagger, how can I automatically validate all data sent to endpoints that have…
CaffeinatedMike
  • 1,537
  • 2
  • 25
  • 57
2
votes
1 answer

Flasgger: How to write description of several endpoints in one yaml file?

I created several endpoints in Flask and created yml files for each of them. So, for example I have 10 endpoints and 10 small yaml files. It is not very comfort to use it, so I want put all the descriprions into 1 yml file. I tried this: app…
Mikhail_Sam
  • 10,602
  • 11
  • 66
  • 102
2
votes
1 answer

Flask/Flasgger - Document does not appear if `endpoint` parameter is set

I have a Blueprint which I wrote an OpenAPI documentation for. Without the endpoint definition, it's working just fine but it doesn't with the endpoint definition. Working code: @my_blueprint.route('/') @swag_from('open_api/root.yml') def main(): …
Michael 'Maik' Ardan
  • 4,213
  • 9
  • 37
  • 60
2
votes
1 answer

Python Flask Flasgger (Swagger) webargs - List of Strings in HTTP PUT body

I've created a python web API using flask, flasgger (swagger defined by yml files), and webargs: @app.route('/api/set/', methods=['PUT']) @swag_from('swagger/put_community_sets.yml') @use_kwargs({'community_set': fields.List(fields.Str(), …
mlander
  • 51
  • 5
2
votes
2 answers

How to tune flasgger in order to use basic authentication in sending requests

I try to use flasgger for my simple RESTful API. The API requireds the authentication/authorization and uses the basic authentication to perform any query. There is really good documentation about Basic Authentication in swagger.io But how can those…
Dimaf
  • 653
  • 1
  • 11
  • 25
2
votes
1 answer

flassger Auto validation (validation=True)

I would like to ask help from the community regarding using flasgger on python (v3) Currently I'm using flasgger with Flask-Restplus (though flask-resplus do have it's own Swagger, I prefer to use flasgger). Anyway, my problem is when turning on the…
1
vote
0 answers

Unable to use a model definition and validate an endpoint using flasgger

I am trying to use flasgger to generate both the OpenAPI 2.0 spec and validate my endpoint payloads. To avoid duplications I want to define the models in the swagger config definitions. The Swagger UI is generated correctly and it appears to be…
luisf
  • 84
  • 4
1
2 3 4