Comments (8)
from flaskerk.
I was thinking about the Swagger layout and I think that is better let as it is now. You just need to put a small example in the README of how to change it (also not a priority).
and you are right. If you take my example code above I can customize the Swagger layout just passing the template_folder as a parameter and adding the two HTML files (redoc.html and swagger.html) inside the template_api folder.
About the tags, my implementation was just a test, it works but it does not mean it is the right way to do. Think about how to incorporate it, maybe using a concept similar to Blueprints would be the way to go.
An official way to support tags is the only thing holding me back to start using this library hahaha.
Anyways, keep your amazing work! It can only get better from here!
PS: In the More feature example there is a small typo, you create the e233 and pass the e403.
from flaskerk.
The "tags" implementation in FastAPI is also the same way. https://fastapi.tiangolo.com/tutorial/path-operation-configuration/#tags
I guess the blueprint way may look like this:
from flaskerk import Flaskerk, Tags
from flask import Flask, jsonify
api = Flaskerk()
cat = Tags('cat')
dog = Tags('dog')
app = Flask(__name__)
@app.route('/api/ping')
@api.validate()
@cat
def ping():
return jsonify(msg='pong')
@app.route('/api/demo')
@api.validate()
@cat
@dog
def demo():
return jsonify(msg='demo test')
if __name__ == '__main__':
api.add_tags(cat, dog)
api.register(app)
app.run()
So if there are multiple tags for one route, it may have too many decorators.
I guess just add tags
to validate()
function is the better way.
from flaskerk.
Looks good!
I think that for an initial implementation we can just add it in the validate function. In the future, we can include something like the APIRouter implemented by FastAPI (that was what I meant when I said "similar to Blueprints").
Here is an example:
from fastapi import Depends, FastAPI, APIRouter
app = FastAPI(
title="Some FastAPI Test",
version="1.0.0"
)
#-------------------------------------------------
router1 = APIRouter()
@router1.get("/test")
async def test1():
return {"msg": "Test"}
app.include_router(
router1,
prefix="/my-tests",
tags=["my tests"],
)
#--------------------------------------------------
router2 = APIRouter()
@router2.get("/test")
async def test2():
return {"msg": "Test"}
app.include_router(
router1,
prefix="/other-tests",
tags=["other tests"],
)
from flaskerk.
The new version (v0.6.3) now supports tags
in validate()
.
The APIRouter
can be a feature in the future.
I'll work on the enhanced layout later.
from flaskerk.
Great! Thank you!
from flaskerk.
Hi @ThiNepo , this library may be archived in the future. Since spectree supports all the features with a better interface. Feel free give it a try!
from flaskerk.
Thanks for letting me know. I will take a look at spectree!
from flaskerk.
Related Issues (9)
- Add some test HOT 4
- same route with multiple methods are not display in swagger HOT 1
- support for flask extensions
- response data is always bonded to 200 HOT 2
- support cookie and header HOT 1
- 422 status code message
- Unable to customize HTTP status code when validating response data HOT 3
- jinja2.exceptions.TemplateNotFound: redoc.html
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 flaskerk.