当前位置: 首页 > 知识库问答 >
问题:

无法读取swagger JSON

白高逸
2023-03-14

我已经按照下面的链接使用spring的Swagger为我的REST服务创建API文档。

http://jakubstas.com/spring-jersey-swagger-configuration/#comment-1726

一切都很顺利,但当我试图使用url http://localhost:8080/rest/api-docs访问swagger的api文档时,我发现无法读取swagger JSON。谁能帮帮忙吗?

共有2个答案

鄢开诚
2023-03-14

你试试这条路。

@Configuration
@EnableSwagger
// Loads the spring beans required by the framework
public class MySwaggerConfig
{

    private SpringSwaggerConfig springSwaggerConfig;

    /**
     * Required to autowire SpringSwaggerConfig
     */
    @Autowired
    public void setSpringSwaggerConfig(SpringSwaggerConfig springSwaggerConfig)
    {
        this.springSwaggerConfig = springSwaggerConfig;
    }

    /**
     * Every SwaggerSpringMvcPlugin bean is picked up by the swagger-mvc
     * framework - allowing for multiple swagger groups i.e. same code base
     * multiple swagger resource listings.
     */
    @Bean
    public SwaggerSpringMvcPlugin customImplementation()
    {
        return new SwaggerSpringMvcPlugin(this.springSwaggerConfig).apiInfo(apiInfo()).includePatterns(
                ".*?");
    }

    private ApiInfo apiInfo()
    {
        ApiInfo apiInfo = new ApiInfo(
                "xx", 
                "xxxx",
                "My Apps API terms of service", 
                "xxx",
                null,
                null);
        return apiInfo;
    }
}







 <dependency>
                <groupId>com.mangofactory</groupId>
                <artifactId>swagger-springmvc</artifactId>
                <version>0.9.5</version>
            </dependency>
鲜于璞瑜
2023-03-14

斯瓦格不在本地工作!您可以为本地下载Swagger Ui

 类似资料:
  • 我是新来的node.js.我正在尝试创建一个注册页面,并使用mysql将输入的值保存在数据库中。 我可以通过在请求头上传递参数来实现这一点。但是,在请求头中传递参数始终不是一个好主意。所以尝试在请求体上传递参数。 我使用邮差测试我的node.js服务。 下面是我的演示应用程序的github链接 https://github.com/debasish283/node_gulp 我还需要做什么来传递请

  • 问题内容: 我想读取.bak文件,这些文件是ms sql数据库的备份文件。现在,我正在研究如何使用Sql Mngmnt studio读取这些文件。请帮帮我。谢谢 问题答案: 您可以使用SQL Management Studio将.BAK文件还原到临时数据库并读取它们! 这里的一些指针

  • LiquiBase.Exception.SetupException:文件:/src/main/LiquiBase/changes/000-initial-schema.xml不存在 我的pom.xml插件配置如下: 我的Liquibase.properties文件是: 为什么Liquibase找不到那个文件?即使我将文件名更改为:000-initial-schematest.xml,错误也是:

  • 我的文件在src/main/Resources/freemarker/email_notification.txt 我无法读取freemaker文件,即电子邮件通知。txt,其中包含html文件。 我的推荐信来自这里:http://websystique.com/spring/spring-4-email-using-velocity-freemaker-template-library/ 我尝试

  • 我有一个问题做npm启动,这似乎是一个bug与css-loader但我不能修复它。 我读过这篇文章,但我不能让它工作:https://github.com/reactjsresources/react-webpack-babel/issues/197 我还修改了webpack.config.js,添加了: 和: 如果有人能帮忙请... 谢谢.

  • 尝试2:有趣的部分是下载文件(只是在浏览器地址栏中粘贴URL),然后执行类似的代码在本地读取文档确实有效: 尝试3:现在是最奇怪的部分。我想文件需要先下载。因此,我首先使用Java下载了它,然后在本地执行前面的代码来读取文档。像第一个案例一样失败! 你知道这是怎么回事吗? 以下异常失败:javax.net.ssl.sslhandShakeException:sun.security.validat