首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >swagger-codegen: java.io.FileNotFoundException:无法读取API

swagger-codegen: java.io.FileNotFoundException:无法读取API
EN

Stack Overflow用户
提问于 2014-04-16 16:53:52
回答 1查看 1.6K关注 0票数 1

我正在尝试与swagger-codegen一起工作,以生成基于Swagger资源文件的代码。但是,在试图生成代码时,我遇到了以下错误:

代码语言:javascript
复制
base path is http://my.documentation.com/api/docs/v1.json
java.io.FileNotFoundException: http://my.documentation.com/api/docs/v1.json/authenticateUser

swagger-codegen似乎试图通过在v1.json之后追加操作名来读取方法定义,但我不确定为什么,因为操作名称是在v1.json本身中定义的:

代码语言:javascript
复制
{
    "basePath":"https://my.api.com/v1",
    "swaggerVersion":"1.2",
    "apiVersion":"1.0.0",
    "resourcePath":"v1",
    "apis":[
        {
            "path":"/authenticateUser",
            "description":"Authenticates a user into the API",
            "operations":[
                {
                    "method":"GET",
                    "summary":"Authenticates a user into the API",
                    "nickname":"authenticateUser",
                    "parameters":[
                        {
                            "paramType":"query",
                            "name":"username",
                            "type":"string",
                            "required":true,
                            "description":"Name of of user to authenticate"
                        },
                        {
                            "paramType":"query",
                            "name":"password",
                            "type":"string",
                            "required":true,
                            "description":"User's password"
                        }
                    ],
                    "notes":"Returns access token in the response object"
                }
            ]
        },
    ...
    ]
}

我不完全确定swagger-codegen所期望的格式。API的basePath和API的文档是否需要相同?注意,文档的文档保存在一个独立的basePath上,而不是API本身。我不知道这是否重要。

我还将注意到,我的swagger资源文件v1.json是用swagger-php生成的,并且在swagger-ui中运行得很好。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-04-16 18:32:09

将basePath改为http://my.documentation.com/api/docs/而不是http://my.documentation.com/api/docs/v1.json解决了这个问题。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/23115565

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档