xeipuuv / gojsonschema

An implementation of JSON Schema, draft v4 v6 & v7 - Go language
2.56k stars 358 forks source link

Get all properties under a section #364

Open rajsenthil opened 1 year ago

rajsenthil commented 1 year ago

I have json schema as given below

{
  "$schema": "http://json-schema.org/draft-07/schema",
  "$id": "https://example.com/product.schema.json",
  "title": "Demo",
  "description": "Demo properties and its definition",
  "type": "object",
  "properties": {
    "id": {
      "type": "string"
    },
    "nested-prop": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "description": "A unique id and cane be used in UI forms for an 'id' attribute "
        },
        "name": {
          "type": "string",
          "description": "handler name. This name can be used in UI form for 'name' attribute"
        },
        "label": {
          "type": "string",
          "description": "Label is used for displaying purpose. It is visible for example in UI forms"
        },
        "target": {
          "type": "string",
          "description": "'target' is a target service that validates and take actions"
        }
      },
      "required": ["id", "name", "label", "target"]
    }
  },
  "required": ["nested-prop"]
}

Is there a way, to get all the properties under nested-prop in some way ["id", "name", "label", "target"]?

Please let me know