Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

仅使用knife4j-openapi3-ui,如何搭配项目中的已经生成好的openapi.json使用 #714

Open
luo-zhan opened this issue Jan 5, 2024 · 3 comments

Comments

@luo-zhan
Copy link

luo-zhan commented Jan 5, 2024

我在尝试用knife4j-ui搭配smart-doc使用,smart-doc可以使用maven插件生成openapi.json文件,目录如下(可配置)

resources
|-static
  |-doc
    openapi.json

knife4j-ui可以直接配置openai.json地址,然后渲染吗?

@xiaoymin
Copy link
Owner

xiaoymin commented Jan 7, 2024

主要步骤:

1、基于源码进行构建,knife4j-vue,参考文档:https://doc.xiaominfo.com/docs/community/contributing

2、修改文件BasicLayout.vue,针对created()方法中,修改使用this.initKnife4jFront()方法

3、修改this.initKnife4jFront()方法中的url属性,改成你们自定义的接口地址

4、url接口响应回来的结构需要满足如下格式,格式参考blog

[
    {
        "name": "2.X版本",
        "url": "/v2/api-docs?group=2.X版本",
        "swaggerVersion": "2.0",
        "location": "/v2/api-docs?group=2.X版本"
    },
    {
        "name": "分组接口",
        "url": "/v2/api-docs?group=分组接口",
        "swaggerVersion": "2.0",
        "location": "/v2/api-docs?group=分组接口"
    },
    {
        "name": "默认接口",
        "url": "/v2/api-docs?group=默认接口",
        "swaggerVersion": "2.0",
        "location": "/v2/api-docs?group=默认接口"
    }
]

@luo-zhan
Copy link
Author

luo-zhan commented Jan 9, 2024

主要步骤:

1、基于源码进行构建,knife4j-vue,参考文档:https://doc.xiaominfo.com/docs/community/contributing

2、修改文件BasicLayout.vue,针对created()方法中,修改使用this.initKnife4jFront()方法

3、修改this.initKnife4jFront()方法中的url属性,改成你们自定义的接口地址

4、url接口响应回来的结构需要满足如下格式,格式参考blog

[
    {
        "name": "2.X版本",
        "url": "/v2/api-docs?group=2.X版本",
        "swaggerVersion": "2.0",
        "location": "/v2/api-docs?group=2.X版本"
    },
    {
        "name": "分组接口",
        "url": "/v2/api-docs?group=分组接口",
        "swaggerVersion": "2.0",
        "location": "/v2/api-docs?group=分组接口"
    },
    {
        "name": "默认接口",
        "url": "/v2/api-docs?group=默认接口",
        "swaggerVersion": "2.0",
        "location": "/v2/api-docs?group=默认接口"
    }
]

那是不是在项目中提供/services.json接口,返回上述json数据就可以了?
另外,json数据中的“2.x版本”、“分组接口”、“默认接口”分别是什么意思,在哪配置我已有的openai.json的地址呢

@xiaoymin
Copy link
Owner

xiaoymin commented Jan 9, 2024

另外,json数据中的“2.x版本”、“分组接口”、“默认接口”分别是什么意思,在哪配置我已有的openai.json的地址呢

这个只是显示分组的名称,随便你自己设定

参考这个demo:https://doc.xiaominfo.com/demo/doc.html#/home

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants