Skip to content

Commit

Permalink
Fix #478
Browse files Browse the repository at this point in the history
  • Loading branch information
mathieuancelin committed Apr 17, 2020
1 parent fc314cd commit 100a601
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion otoroshi/app/script/script.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1353,7 +1353,19 @@ class ScriptApiController(ApiAction: ApiAction, cc: ControllerComponents)(
case _ => false
}
}
.map(c => Json.obj("id" -> c.id, "name" -> c.name, "description" -> c.desc)) ++
.map(c => (c, env.scriptManager.getAnyScript[NamedPlugin](c.id)))
.map {
case (c, Left(_)) => Json.obj("id" -> c.id, "name" -> c.name, "description" -> c.desc)
case (c, Right(instance)) => Json.obj(
"id" -> c.id,
"name" -> Option(c.name).map(_.trim).filter(_.nonEmpty).orElse(instance.name).map(JsString.apply).getOrElse(JsNull).as[JsValue],
"description" -> Option(c.desc).map(_.trim).filter(_.nonEmpty).orElse(instance.description).map(JsString.apply).getOrElse(JsNull).as[JsValue],
"defaultConfig" -> instance.defaultConfig.getOrElse(JsNull).as[JsValue],
"configRoot" -> instance.configRoot.map(JsString.apply).getOrElse(JsNull).as[JsValue],
"configSchema" -> instance.configSchema.getOrElse(JsNull).as[JsValue],
"configFlow" -> JsArray(instance.configFlow.map(JsString.apply))
)
} ++
cpTransformers.map(extractInfos) ++
cpValidators.map(extractInfos) ++
cpPreRoutes.map(extractInfos) ++
Expand Down

0 comments on commit 100a601

Please sign in to comment.