Skip to content

Does JSONSchema support assigning a function to a property? #64

@reselbob

Description

@reselbob

I want to be able to define functions with parameters and return type for my JavaScript object specification. I am hoping to be able to do this using JSONSchema. But, I can't seem to figure out how to do it.

I am trying to do something like the following:

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://example.com/product.schema.json",
  "title": "Product",
  "description": "A JavaScript object that gets a product from Acme's catalog",
  "type": "object",
  "properties": {
    "getProduct": {
      "description": "returns a product object when a product id is provided as a parameter",
      "type": "function",
      "parameters": ["id": uuid],
      "returnType": object
    }
  },
}

Is it possible to do something liek this? Triple thanks in advance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions