我正在尝试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/authenticateUser
似乎swagger-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 的文档是否需要相同?请注意,文档的文档托管在与 API 本身不同的 basePath 上。我不确定这是否重要。
我还会注意到我的 swagger 资源文件v1.json
是swagger-php
使用swagger-ui
.