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
1
vote
0 answers

In python flasgger, how to expand schema in web interface by default?

I have started to use Swagger for API documentation. Please help me configure it. How to expand the schema in Swagger UI by default? from flasgger import Swagger, swag_from from flask import Flask app = Flask(__name__) swagger =…
pyjedy
  • 389
  • 2
  • 9
1
vote
0 answers

How can I show code while documenting an API using Flasgger

I'm documenting an API and I'd like to show some code examples in order to show how does my api works, I'm using Flasgger and I didn't find any information about this topic, I read from x-codeSamples doc to show pieces of code by writing something…
1
vote
0 answers

Accessing flasgger_static endpoints behind a reverse proxy?

Let's assume I have a Flask app exposing an endpoint /login and I expose this app behind a reverse proxy (traefik) using the prefix my_app (the proxy has to strip the prefix, however when I use the "try it out" function in swagger ui, it send the…
Nicolas Mauti
  • 506
  • 3
  • 13
1
vote
0 answers

Flasgger does not load when hostname has a path

I have a Flask application and I've integrated Flasgger for documentation. When I run my app locally, I can access swagger at http://127.0.0.1:5000/apidocs. But when it's deployed to our dev environment, the hostname is…
Saturnian
  • 1,686
  • 6
  • 39
  • 65
1
vote
1 answer

External YAML with multiple specs not working on Flasgger

I'm trying to document multiple endpoints by reference to the same YAML file but it just won't work. Is this not supported? Or am I doing something wrong? app.py from flask import Flask, jsonify from flasgger import Swagger app =…
Ariel
  • 3,383
  • 4
  • 43
  • 58
1
vote
1 answer

Flasgger / Swagger - apidocs works with localhost but not Openshift (You need to enable JavaScript to run this app)

I am running a Python Flask server. A co-worker added Flasgger/Swagger support and I can successfully display the API using http://localhost:5000/apidocs Similarly, I can get the json version of the API http://localhost:5000/api_documentation.json …
mwk
  • 71
  • 1
  • 5
1
vote
0 answers

Flasgger: Swagger App - http://127.0.0.1:5000/apidocs/ - Fetch errorINTERNAL SERVER ERROR /apispec_1.json

I created a Flasgger/Swagger App in Spyder and got returned: 127.0.0.1 - - [28/Mar/2021 21:49:13] "GET /apispec_1.json HTTP/1.1" 500 - 127.0.0.1 - - [28/Mar/2021 21:49:13] "GET /flasgger_static/favicon-32x32.png HTTP/1.1" 200 - When trying to visit…
Tobitor
  • 1,388
  • 1
  • 23
  • 58
1
vote
1 answer

Flasgger: Parameters not showing and Schema

I have recently started learning Swagger for APi documentation. However, when I go to localhost:5000/apidocs, I see APIs that I added but all APIs are with no parameters even when I have described parameters in my yml file. I couldn't find anything…
1
vote
1 answer

Python Flask Blueprints - Defining API Docs for multiple endpoints in one .yaml file

I have some endpoints in one of my blueprints, and I'm hoping to add all the API documentation for this blueprint into a single .yaml file. However, with my current .yaml file structure and blueprint code, it seems like flasgger is not recognizing…
Chiah Soon
  • 507
  • 5
  • 18
1
vote
1 answer

flasgger: reference marshmallow schema in a .py module

I have flask project with Marshmallow Schema classes defined in a schemas module. For example: project - app.py - routes.py - schemas/ - schema1.py - schema2.py Where schema1.py is a typical marshmallow Schema. class…
Adam Hughes
  • 14,601
  • 12
  • 83
  • 122
1
vote
1 answer

Swagger change base URL in Python using flasgger library

I am trying to update my Swagger Base URL from '/' to '/testapp' for my REST API This is my Swagger Config swagger_config = { "headers": [ ], "specs": [ { "endpoint": 'APISpecification', "route":…
Nikhil Redij
  • 1,011
  • 1
  • 14
  • 21
1
vote
0 answers

flasgger /apidocs does not render with nginx reverse proxy

I have been using the flasgger extension for flask to render swagger UI for OpenAPI spec locally with developement server. But in production, when I throw nginx into the mix I am not able to get the /apidocs to render
phoenix
  • 11
  • 3
1
vote
2 answers

Flasgger execution is a success but not showing the XML body

While Deploying iris prediction model using flasgger API, i can enter the lengths and widths of the iris flower with http/200 ok , but i do not see an xml output with the prediction results. From ipython notebook: Running on http://127.0.0.1:5001/…
amitk
  • 143
  • 1
  • 1
  • 9
1
vote
1 answer

Failed to laod API defination error using Flasgger in python

I am creating an API for my machine learning Model using Flasgger and Flask in python. After running my API file I am getting the below error as ‘Failed to load API documents. Fetch error Internal Server Error/ apispex_1.json Below is my code…
Aditya Sharma
  • 147
  • 1
  • 10
1
vote
1 answer

File upload selector in Flasgger POST routes

In Flasgger, I'm trying to create documentation for route which accepts uploaded files. However, despite sticking to the specification, I cannot display file selector in Flasgger UI. I'm using latest (as of today) flasgger==0.9.1 running OpenAPI 3…
adamczi
  • 343
  • 1
  • 7
  • 24