Reputation: 1853
I am trying to work with swagger-codegen
to generate code based on my Swagger resource file. However, I am running into the following error when attempting to generate code:
base path is http://my.documentation.com/api/docs/v1.json
java.io.FileNotFoundException: http://my.documentation.com/api/docs/v1.json/authenticateUser
It seems that swagger-codegen
is attempting to read the method definition by appending the operation name after v1.json
, but I am not sure why, as the operation name is defined inside v1.json
itself:
{
"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"
}
]
},
...
]
}
I am not entirely sure what format swagger-codegen
is expecting. Do the basePath for the API and the documentation for the API need to be the same? Note that the documentation for the documentation is hosted on a separate basePath than the API itself. I am not sure if this matters.
I will also note that my swagger resource file v1.json
was generated with swagger-php
and is working fine with swagger-ui
.
Upvotes: 1
Views: 2348
Reputation: 1853
Changing the basePath to http://my.documentation.com/api/docs/
instead of http://my.documentation.com/api/docs/v1.json
resolved the issue.
Upvotes: 1