我正在尝试与swagger-codegen一起工作,以生成基于Swagger资源文件的代码。但是,在试图生成代码时,我遇到了以下错误:
base path is http://my.documentation.com/api/docs/v1.json
java.io.FileNotFoundException: http://my.documentation.com/api/docs/v1.json/authenticateUserswagger-codegen似乎试图通过在v1.json之后追加操作名来读取方法定义,但我不确定为什么,因为操作名称是在v1.json本身中定义的:
{
"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中运行得很好。
发布于 2014-04-16 18:32:09
将basePath改为http://my.documentation.com/api/docs/而不是http://my.documentation.com/api/docs/v1.json解决了这个问题。
https://stackoverflow.com/questions/23115565
复制相似问题