Comments (4)
Weird, could you provide me with a test case. Eg. zip of a barebones flask app where this behaviour is displayed?
from flask-swagger.
@atlithorn Here is a working example.
It happens when you want one resource to handle multiple routes. Note that if you try to curl -X POST localhost:5002/HelloWorld/ASDF
you will get an error but curl -X POST localhost:5002/HelloWorld
will succeed
from flask import Flask, jsonify
from flask_restful import Resource, Api
from flask_swagger import swagger
app = Flask(__name__)
api = Api(app)
class HelloWorld(Resource):
def post(self):
"""
Create a new user
---
tags:
- users
definitions:
- schema:
id: Group
properties:
name:
type: string
description: the group's name
parameters:
- in: body
name: body
schema:
id: User
required:
- email
- name
properties:
email:
type: string
description: email for user
name:
type: string
description: name for user
address:
description: address for user
schema:
id: Address
properties:
street:
type: string
state:
type: string
country:
type: string
postalcode:
type: string
groups:
type: array
description: list of groups
items:
$ref: "#/definitions/Group"
responses:
201:
description: User created
"""
return {'hello': 'world'}
def get(self, session_id : str) -> "http response":
return session_id
@app.route("/spec")
def spec():
return jsonify(swagger(app))
api.add_resource(HelloWorld, '/HelloWorld', '/HelloWorld/<session_id>')
if __name__ == '__main__':
app.run(debug=True, port = 5002)
from flask-swagger.
Running into this same issue in my app where we have one resource handling multiple routes. It's adding an operation per route rather than per resource. I'm not sure if there's a good solution though. How would you determine what route tied to what method?
from flask-swagger.
Finally had a look at it and @dmertl is right there is no easy solution without refactoring how flask_swagger discovers resources. It's probably doable but unfortunately not something I need or have time for at the moment. More than willing to review suggestions as always.
from flask-swagger.
Related Issues (20)
- Doc example showing root level definitions? HOT 1
- Are Blueprint supported ? HOT 9
- Pip source code is different from github master branch HOT 2
- Multiple path parameters and multiple endpoints HOT 3
- Add partial substitution of docstrings -- expansion of .yml file support HOT 5
- Spec throws exception on bad yaml HOT 1
- Swagger UI v3 HOT 2
- Support resuableParameters
- yaml file location HOT 2
- Support flask blueprint
- Passing Absolute YAML Path In Windows HOT 1
- pip install missing packages
- Supported methods to authenticate and cache web token
- Support for "securityDefinitions" HOT 3
- AttributeError: type object 'Create' has no attribute 'lower' HOT 1
- TypeError: swagger() got an unexpected keyword argument 'base_path'
- Type annotations / type hints / stub files for mypy HOT 4
- [Question] Can I check flask-swagger comments for correctnes?
- 'base_path' argument error HOT 3
- Invalid path parameter HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flask-swagger.