Hello. What's the correct payload / request forma...
# ory-network
r
Hello. What's the correct payload / request format for calling the OPL Syntax Check endpoint on Ory Network? I'm testing with the example namespaces file from the repo, and getting a response showing
fatal error
. This is also happening with my own custom namespaces file. Here's the request I'm using:
Copy code
curl --request POST \
  --url <https://ory-network-endpoint/opl/syntax/check> \
  --header 'authorization: Bearer {{some key}}' \
  --header 'content-type: multipart/form-data' \
  --form file=@/path/to/keto/contrib/rewrites-example/namespaces.keto.ts
Testing with the sample file from https://github.com/ory/keto/blob/master/contrib/rewrites-example/namespaces.keto.ts
I've also tried using the key:
checkOplSyntaxBody
as outlined in the API docs: https://www.ory.sh/docs/keto/reference/rest-api#tag/relationship/operation/checkOplSyntax
e
That endpoint only accepts text/plain as the content-type. I would try putting the
checkOplSyntaxBody
key with the content of your namespaces.keto.ts file as the body. (unless I am misunderstanding your second part in the thread that you attempted this.)
r
Understood. Thanks for the info. Putting the file content into the request body worked (NB: I didn't have to specify
checkOplSyntaxBody
anywhere) This works well for me
Copy code
curl --request POST \
  --url <https://ory-network-endpoint/opl/syntax/check> \
  --header 'authorization: Bearer {{ory_keto_api_key}}' \
  --header 'content-type: text/plain' \
  --data '// Copyright © 2023 Ory Corp
// SPDX-License-Identifier: Apache-2.0

import { Namespace, SubjectSet, Context } from "@ory/keto-namespace-types"

class User implements Namespace {
  related: {
    manager: User[]
  }
}

class Group implements Namespace {
  related: {
    members: (User | Group)[]
  }
}

class Folder implements Namespace {
  related: {
    parents: (File | Folder)[]
    viewers: SubjectSet<Group, "members">[]
  }

  permits = {
    view: (ctx: Context): boolean =>
      this.related.viewers.includes(ctx.subject) ||
      this.related.parents.traverse((p) => p.permits.view(ctx)),
  }
}

class File implements Namespace {
  related: {
    parents: (File | Folder)[]
    viewers: (User | SubjectSet<Group, "members">)[]
    owners: (User | SubjectSet<Group, "members">)[]
  }

  // Some comment
  permits = {
    view: (ctx: Context): boolean =>
      this.related.parents.traverse((p) => p.permits.view(ctx)) ||
      this.related.viewers.includes(ctx.subject) ||
      this.related.owners.includes(ctx.subject),

    edit: (ctx: Context) => this.related.owners.includes(ctx.subject),
  }
}'
@early-magician-18981 Perhaps a quick follow up: Is there a CLI equivalent of this OPL Syntax validation endpoint? I'd like to be able to perform this check in our CI/CD pipelines.
s
currently not, but I'll add it to the backlog