sanic-org / sanic-ext

Extended Sanic functionality
https://sanic.dev/en/plugins/sanic-ext/getting-started.html
MIT License
50 stars 36 forks source link

[Bug] The tags in OpenAPI yaml are not effective #246

Open AllenCHM opened 6 months ago

AllenCHM commented 6 months ago
@xcx_login_route.post("/login")
@json_validate(WechatLoginRequest)
async def wechat_login(
    request: Request, parsed_data:dict, *args, **kwargs
) -> HTTPResponse:
    """微信小程序登录

    code  小程序wx.login()获取

    openapi:
    ---
    tags: 
        - 微信小程序

After testing, the tag is not effective。

After debugging testing, operation_ The tags in Autodoc are not effective. Solution: Need to adjust code sanic_ext/extensions/openapis/builders. py (line 153)

The adjusted code is

    def autodoc(self, docstring: str):
        y = YamlStyleParametersParser(docstring)
        self._autodoc = y.to_openAPI_3()
        if self._autodoc.get('tags'):
            self.tags = self._autodoc['tags']