Giter VIP home page Giter VIP logo

Comments (8)

kemingy avatar kemingy commented on May 18, 2024

from flaskerk.

ThiNepo avatar ThiNepo commented on May 18, 2024

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.

kemingy avatar kemingy commented on May 18, 2024

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.

ThiNepo avatar ThiNepo commented on May 18, 2024

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.

kemingy avatar kemingy commented on May 18, 2024

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.

ThiNepo avatar ThiNepo commented on May 18, 2024

Great! Thank you!

from flaskerk.

kemingy avatar kemingy commented on May 18, 2024

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.

ThiNepo avatar ThiNepo commented on May 18, 2024

Thanks for letting me know. I will take a look at spectree!

from flaskerk.

Related Issues (9)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.