Skip to content

Commit

Permalink
update token-user in apidoc
Browse files Browse the repository at this point in the history
  • Loading branch information
chhsiao1981 committed May 21, 2024
1 parent 7cd008a commit 38fcb55
Show file tree
Hide file tree
Showing 12 changed files with 25 additions and 15 deletions.
2 changes: 1 addition & 1 deletion apidoc/addsecurity.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
filename = sys.argv[1]

with open(filename, 'r') as f:
the_struct = yaml.load(f)
the_struct = yaml.full_load(f)

components = the_struct.get('components', {})
components['securitySchemes'] = {
Expand Down
6 changes: 4 additions & 2 deletions apidoc/apidoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def _with_app_prefix(path):


with open('apidoc/template.json', 'r') as f:
template = yaml.load(f)
template = yaml.full_load(f)


@app.route('/')
Expand Down Expand Up @@ -106,6 +106,7 @@ def _load_favorite_boards(user_id):
"""
return ''


@app.route(_with_app_prefix('/user/<user_id>/favorites/addboard'), methods=['POST'])
def _add_favorite_board(user_id):
"""
Expand Down Expand Up @@ -467,10 +468,11 @@ def _get_verion():
"""
return ''


@app.route(_with_app_prefix('/uservisitcount'), methods=['GET'])
def _get_user_visit_count():
"""
swagger_from_file: apidoc/get_user_visit_count.yaml
"""
return ''
return ''
3 changes: 2 additions & 1 deletion apidoc/attempt_register_user.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@ responses:
properties:
username:
type: string
!include defs/tokenuser.yaml
tokenuser:
'$ref': '#/definitions/tokenuser'
3 changes: 2 additions & 1 deletion apidoc/create_rank.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@ responses:
properties:
rank:
type: number
!include def/tokenuser.yaml
tokenuser:
'$ref': '#/definitions/tokenuser'
3 changes: 2 additions & 1 deletion apidoc/cross_post.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,5 @@ responses:
'$ref': '#/definitions/ArticleSummary'
comment:
'$ref': '#/definitions/Comment'
!include defs/tokenuser.yaml
tokenuser:
'$ref': '#/definitions/tokenuser'
3 changes: 2 additions & 1 deletion apidoc/delete_articles.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ responses:
properties:
success:
type: boolean
!include defs/tokenuser.yaml
tokenuser:
'$ref': '#/definitions/tokenuser'
3 changes: 2 additions & 1 deletion apidoc/delete_comments.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,5 @@ responses:
properties:
success:
type: boolean
!include defs/tokenuser.yaml
tokenuser:
'$ref': '#/definitions/tokenuser'
3 changes: 2 additions & 1 deletion apidoc/delete_favorite.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@ responses:
success:
type: boolean
description: 是否成功刪除.
!include defs/tokenuser.yaml
tokenuser:
'$ref': '#/definitions/tokenuser'
3 changes: 2 additions & 1 deletion apidoc/edit_article.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,5 @@ responses:
type: string
class:
type: string
!include defs/tokenuser.yaml
tokenuser:
'$ref': '#/definitions/tokenuser'
4 changes: 2 additions & 2 deletions apidoc/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
name="apidoc",
version='0.0.1',
install_requires=[
"pyyaml==5.3.1",
"Flask==1.1.2",
"pyyaml==6.0.1",
"Flask==3.0.3",
"flask-swagger @ git+https://github.com/chhsiao1981/flask-swagger.git@flaskswagger-with-from-file-keyword#egg=flask-swagger",
],
classifiers=[
Expand Down
1 change: 1 addition & 0 deletions apidoc/template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,4 @@ definitions:
!include defs/man_article_summary.yaml
!include defs/man_article_list.yaml
!include defs/man_article_block.yaml
!include defs/tokenuser.yaml
6 changes: 3 additions & 3 deletions apidoc/yamltojson.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,21 @@ def include(self, node):
result = {}
for each in filename_list:
with open(each, 'r') as f:
each_struct = yaml.load(f)
each_struct = yaml.full_load(f)
result.update(each_struct)
return result

'''
with open(filename, 'r') as f:
return yaml.load(f, Loader)
return yaml.full_load(f, Loader)
'''


yaml.add_constructor('!include', include)


with open(src, 'r') as f:
the_struct = yaml.load(f)
the_struct = yaml.full_load(f)

with open(dst, 'w') as f:
json.dump(the_struct, f, indent=4)

0 comments on commit 38fcb55

Please sign in to comment.