我正在使用Swagger记录我的ROR应用程序的API。这是我的初始化文件:
class Swagger::Docs::Config
def self.transform_path(path, api_version)
# Make a distinction between the APIs and API documentation paths.
"/apidocs/#{path}"
end
end
Swagger::Docs::Config.register_apis({
'1.0' => {
controller_base_path: '',
api_file_path: 'public/apidocs',
base_path: 'http://localhost:3000',
clean_directory: true
}})
当我运行rake任务时,api-docs.json将为swagger GUI生成。
{
"apiVersion": "1.0",
"swaggerVersion": "1.2",
"basePath": "http://localhost:3000/",
"apis": [
{
"path": "/apidocs/api/v1/users.{format}",
"description": "UserS"
}]}
但是为users.json生成了相应的JSON,路径没有正确显示。
{
"apiVersion": "1.0",
"swaggerVersion": "1.2",
"basePath": "http://localhost:3000/",
"resourcePath": "users",
"apis": [
{
"path": "api/v1/users",
"operations": [
{
"summary": "Fetches all User items",
"notes": "This lists all the active users",
"parameters": [
{.....} ]}]}]}
我需要"path": "api/v1/users"
,
"path": "/api/v1/users"