diff --git a/jans-config-api/server/src/main/java/io/jans/configapi/rest/resource/auth/AgamaResource.java b/jans-config-api/server/src/main/java/io/jans/configapi/rest/resource/auth/AgamaResource.java index 6b6efc42fb4..79cbc579d8f 100644 --- a/jans-config-api/server/src/main/java/io/jans/configapi/rest/resource/auth/AgamaResource.java +++ b/jans-config-api/server/src/main/java/io/jans/configapi/rest/resource/auth/AgamaResource.java @@ -148,6 +148,26 @@ public Response createFlow(@Valid Flow flow) return Response.status(Response.Status.CREATED).entity(minimize(flow, false)).build(); } + @POST + @Consumes(MediaType.TEXT_PLAIN) + @ProtectedApi(scopes = { ApiAccessConstants.AGAMA_READ_ACCESS }, groupScopes = { + ApiAccessConstants.AGAMA_WRITE_ACCESS }, superScopes = { ApiAccessConstants.SUPER_ADMIN_READ_ACCESS }) + @Path("/syntax-check/" + ApiConstants.QNAME_PATH) + public Response doSyntaxCheck(@PathParam(ApiConstants.QNAME) String qname, String source) { + + Exception e = null; + try { + Transpiler.runSyntaxCheck(qname, source); + e = new TranspilerException(""); + } catch (SyntaxException | TranspilerException te) { + logger.info("Syntax check failed"); + e = te; + } + e.setStackTrace(new StackTraceElement[0]); + return Response.ok().entity(e).build(); + + } + @Operation(summary = "Create a new agama flow from source", description = "Create a new agama flow from source.", operationId = "post-agama-flow-from-source", tags = { "Agama - Configuration" }, security = @SecurityRequirement(name = "oauth2", scopes = { ApiAccessConstants.AGAMA_WRITE_ACCESS }))