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

How to write API documentation using flasgger when my function has multiple http methods (GET, POST) in it?

I am using flasgger to write my API documentation, one of my function has both GET and POST method.The problem is that flasgger is not able to differentiate between the GET and the POST method. I have written the code only for the post method but it…
dannywallock
  • 23
  • 1
  • 4
1
vote
1 answer

swagger: how to validate formData

So far I'm able to do swagger validation if the parameters are from "in": "body" or if the input expected is in a json format. However, I can't find how to validate a simple string entered as formData. Below is my swagger script (in json…
1
vote
1 answer

Syntax for HTTP methods in same def using Swagger

I am new to SwaggerUI. In my python code, I have an API called 'work' which supports POST, PUT and DELETE HTTP methods. Now I want to create Swagger Documentation for the same. I am using the following code: @app.route('/work', methods=['POST',…
amankedia
  • 377
  • 2
  • 8
  • 23
0
votes
0 answers

Flasgger Swagger UI not loading endpoints

I want to use Flasgger to read my openapi definitions from a swagger.yml file. My swagger.yml file: # swagger.yml openapi: 3.0.0 info: title: "Job DB Flask EST API" description: "An API about opportunities and applications" version:…
0
votes
0 answers

Flasgger/Swagger: Resolver Errror when using $ref

I'm using Flasgger 0.9.7b2 with OpenAPI 2.0. This is an excerpt I have in my yaml file: responses: 200: description: Successfully fetched models. schema: $ref: "model.yml#/definitions/Model" In the same directory, I have my…
Y0oo0
  • 1
0
votes
0 answers

Flask Blueprint Flasgger Example Not Rendering Properly

Can someone please help me solve this Flasgger issue here. I'm trying to use the Flask Blueprint example with Flasgger and when I spin up the sample app on my end, I see the page, but I'm not able to see any documentation of the endpoints. See below…
0
votes
0 answers

Setup Swagger Yaml paths - Flask

I have been trying to set swagger paths for YAML files for my flask application. Those are external YAML files. But flask in unable to read the YAML files somehow. Following is my setting as of now. run.py app = Flask(__name__) api =…
0
votes
1 answer

How to add default JSON object in body of post request swagger

I'd like to add JSON as the default to this swagger endpoint for the body of the POST request. I can not for the life of me figure out what this format is supposed to be to add a very large JSON object as the default for a POST endpoint. See example…
Justin Furuness
  • 685
  • 8
  • 21
0
votes
1 answer

how to load swagger UI, in before_request looking for token but token used in particular endpoint

#flask, swagger, before_request problem in app.py one function is decorated with before_request and in this fuction """ token = request.args.get('token') if not token: return jsonify({ 'status': 'error', 'message': 'Unauthorized.' }) # Parse…
0
votes
1 answer

flasgger-flask-swagger: request parameters not displayed in Webpage

I want to create a REST API using flask. I also would like to document the api using swagger 2.0. This is the reason why I chose flasgger to create a webpage for the documentation. Right now the web page is rendered but the parameters for the…
0
votes
1 answer

Flasgger header parameters aren't described

I try to implement swagger documentation for the project using flasgger. When I describe body fields - it works ok, but when I try to describe header fields, flasgger doesn't present the description of the parameters on the web. An example of .yml…
Alex Kay
  • 23
  • 1
  • 3
0
votes
0 answers

Encrypt password text during API call in swagger(flasgger)

I am using flasgger to generate swagger UI for API's in flask. I have an API endpoint http://localhost:5000/api/token which gives back token, if correct username and password is given, everything is fine, only problem is password is sent in clear…
young_minds1
  • 1,181
  • 3
  • 10
  • 25
0
votes
0 answers

How prevent redirect in flasgger requests?

I check below code in cmd - its not redirected to another url. curl -X POST "http://localhost:5555/login" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"email\": \"admin\", \"password\": \"admin\"}" But when i click in…
Axixa
  • 43
  • 4
0
votes
0 answers

Login window not showing for Swagger using Flask

I have a REST API set up with Flask that has some API documentation. The documentation is in the code itself, and I am using Flasgger to run the API documentation interface. The issue is that upon trying to access the API, with the URL…
0
votes
1 answer

How to add POST request to Flasgger?

I am new with Flasgger and I am trying to figure out how to add POST request to it. Here is my Flask app with Flasgger (app.py): import datetime import numpy as np import pandas as pd from flask import Flask, jsonify, make_response, Response,…
illuminato
  • 1,057
  • 1
  • 11
  • 33