Skip to content

Commit 3b23636

Browse files
authored
feat: add endpoint to do syntax check only #3277 (#3299)
1 parent 8d743f2 commit 3b23636

File tree

1 file changed

+20
-0
lines changed
  • jans-config-api/server/src/main/java/io/jans/configapi/rest/resource/auth

1 file changed

+20
-0
lines changed

jans-config-api/server/src/main/java/io/jans/configapi/rest/resource/auth/AgamaResource.java

+20
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,26 @@ public Response createFlow(@Valid Flow flow)
148148
return Response.status(Response.Status.CREATED).entity(minimize(flow, false)).build();
149149
}
150150

151+
@POST
152+
@Consumes(MediaType.TEXT_PLAIN)
153+
@ProtectedApi(scopes = { ApiAccessConstants.AGAMA_READ_ACCESS }, groupScopes = {
154+
ApiAccessConstants.AGAMA_WRITE_ACCESS }, superScopes = { ApiAccessConstants.SUPER_ADMIN_READ_ACCESS })
155+
@Path("/syntax-check/" + ApiConstants.QNAME_PATH)
156+
public Response doSyntaxCheck(@PathParam(ApiConstants.QNAME) String qname, String source) {
157+
158+
Exception e = null;
159+
try {
160+
Transpiler.runSyntaxCheck(qname, source);
161+
e = new TranspilerException("");
162+
} catch (SyntaxException | TranspilerException te) {
163+
logger.info("Syntax check failed");
164+
e = te;
165+
}
166+
e.setStackTrace(new StackTraceElement[0]);
167+
return Response.ok().entity(e).build();
168+
169+
}
170+
151171
@Operation(summary = "Create a new agama flow from source", description = "Create a new agama flow from source.", operationId = "post-agama-flow-from-source", tags = {
152172
"Agama - Configuration" }, security = @SecurityRequirement(name = "oauth2", scopes = {
153173
ApiAccessConstants.AGAMA_WRITE_ACCESS }))

0 commit comments

Comments
 (0)