Skip to content

Commit

Permalink
update swagger add fields help description
Browse files Browse the repository at this point in the history
  • Loading branch information
AloneFire committed Nov 19, 2018
1 parent 959fe9c commit cd87af8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
9 changes: 4 additions & 5 deletions example/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,19 @@ class Config(object):
APP_VERSION = "0.1.0"
APP_DESC = "Hsrpc Demo"
SERVICE_INFO = {
"address": "192.168.1.6",
"address": "192.168.88.99",
"port": 5301,
"meta": {
"apidoc": "/apidocs"
},
"check": {
"name": "health",
"http": "http://192.168.1.6:5301/health",
"http": "http://192.168.88.99:5301/health",
"interval": "5s"
}

}
HSRPC_AUTO_UNREGISTER = True
CONSUL_HOST = "192.168.1.10"


app = Flask(__name__)
Expand All @@ -34,8 +33,8 @@ class Config(object):


class LoginSchema(BaseSchema):
login_name = fields.String(required=True, load_from="loginName")
password = fields.String(required=True)
login_name = fields.String(required=True, load_from="loginName", help="用户名")
password = fields.String(required=True, help="密码")


@rpc.route(description="Login Demo", schema=LoginSchema)
Expand Down
2 changes: 1 addition & 1 deletion flask_hsrpc/__version__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# -*- coding: utf-8 -*-
__version__ = '0.1.12'
__version__ = '0.1.13'
3 changes: 2 additions & 1 deletion flask_hsrpc/swagger.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ def add_path(self, path, schema=None, methods=None, description="", tags=[]):
"name": field.load_from if field.load_from else key,
"type": field.__type_name__() if hasattr(field, "__type_name__") else field.__class__.__name__,
"required": field.required,
"in": ["path"] if method in ("GET") else ["json"]
"in": ["path"] if method in ("GET") else ["json"],
"description": field.metadata.get("help", "") if field.metadata else ""
} for key, field in schema._declared_fields.items()] if schema else []
}

Expand Down

0 comments on commit cd87af8

Please sign in to comment.