使用方式:

    1. $ gf swagger -h
    2. USAGE
    3. gf swagger [OPTION]
    4. OPTION
    5. -s, --server start a swagger server at specified address after swagger files
    6. produced
    7. -o, --output the output directory for storage parsed swagger files,
    8. the default output directory is "./swagger"
    9. -/--pack auto parses and packs swagger into packed/swagger.go.
    10. EXAMPLES
    11. gf swagger
    12. gf swagger --pack
    13. gf swagger -s 8080
    14. gf swagger -s 127.0.0.1:8080
    15. gf swagger -o ./document/swagger
    16. DESCRIPTION
    17. The "swagger" command parses the current project and produces swagger API description
    18. files, which can be used in swagger API server. If used with "-s/--server" option, it
    19. watches the changes of go files of current project and reproduces the swagger files,
    20. which is quite convenient for local API development.
    21. If it fails in command "swag", please firstly check your system PATH whether containing
    22. go binary path, or you can install the "swag" tool manually referring to:
    23. https://github.com/swaggo/swag

    该命令内部使用的是swag工具,相关语法请参考:https://github.com/swaggo/swag

    此外,推荐使用gf框架的swagger插件,仓库地址:https://github.com/gogf/swagger

    使用示例:

    1. $ gf swagger --pack
    2. 2020-12-31 00:42:10.345 producing swagger files...
    3. 2020-12-31 00:42:10.452 done!
    4. 2020-12-31 00:42:10.452 gf pack swagger packed/swagger.go -n packed
    5. path 'packed/swagger.go' is not empty, files might be overwrote, continue? [y/n]: y
    6. 2020-12-31 00:42:13.954 done!