Skip to content

feat: property snippets jigx#35

Merged
p-spacek merged 7 commits into
jigxfrom
feat/property-snippets-JIGX
Mar 19, 2025
Merged

feat: property snippets jigx#35
p-spacek merged 7 commits into
jigxfrom
feat/property-snippets-JIGX

Conversation

@p-spacek
Copy link
Copy Markdown
Collaborator

@p-spacek p-spacek commented Mar 12, 2025

What does this PR do?

the main purpose of this PR is to add support for property snippets
but it also fixes a few other issues

What issues does this PR fix or reference?

https://app.clickup.com/t/868c50fu6
the base of this branch is feat/property-snippets it's base is main

  • it means that all changes should be made in feat/property-snippets to include it into the official redhat repo
    feat: property snippets #36

some schema examples:

    "snippets": {
      "type": "object",
      "properties": {
        "hyphen": {
          "type": "object",
          "properties": {
            "array1": {
              "type": "array",
              "items": {
                "type": "object",
                "defaultSnippets": [
                  {
                    "label": "My array item",
                    "body": { "item1": "$1" }
                  }
                ],
                "required": ["thing1"],
                "properties": {
                  "thing1": {
                    "type": "object",
                    "required": ["item1"],
                    "properties": {
                      "item1": { "type": "string" }
                    }
                  }
                }
              }
            }
          }
        },
        "aaa": {
          "type": "array",
          "items": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "fooBar": {
                    "type": "object",
                    "properties": {
                      "name": {
                        "type": "string"
                      },
                      "aaa": {
                        "type": "array"
                      }
                    },
                    "required": ["name", "aaa"]
                  }
                }
              }
            ]
          }
        },
        "examples": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "objectWithArray": {
                "type": "array",
                "items": {
                  "type": "object",
                  "required": ["item", "item2"],
                  "properties": {
                    "item": { "type": "string" },
                    "item2": { "type": "string" }
                  }
                }
              }
            }
          }
        },
        "snippetString": {
          "type": "string",
          "$comment": "OK, property, value",
          "defaultSnippets": [
            {
              "label": "labelSnippetString",
              "body": "test"
            }
          ]
        },
        "snippetObject": {
          "type": "object",
          "$comment": "OK, property, value, value nested",
          "properties": {
            "item1": { "type": "string" },
            "item2": {
              "type": "object",
              "defaultSnippets": [
                {
                  "label": "labelSnippetObject",
                  "body": {
                    "item2.1": "test",
                    "item2.2": "string"
                  }
                }
              ]
            }
          },
          "required": ["item1", "item2"]
        },
        "snippetArray": {
          "type": "array",
          "$comment": "property - Not implemented, OK: value, value nested, value nested with -, OK on 2nd index without or with -",
          "items": {
            "type": "object",
            "properties": {
              "item1": { "type": "string" },
              "item2": { "type": "object" }
            },
            "required": ["item1", "item2"]
          },
          "defaultSnippets": [
            {
              "label": "labelSnippetArray",
              "body": {
                "value": "test",
                "valueType": "string"
              }
            }
          ]
        },
        "snippetArray2": {
          "type": "array",
          "$comment": "property - Not implemented, OK: value, value nested, NOT OK value nested with -",
          "items": {
            "type": "string"
          },
          "defaultSnippets": [
            {
              "label": "labelSnippetArray2",
              "body": ["string", false, 5, null]
            }
          ]
        },
        "snippetArrayInsideItems": {
          "type": "array",
          "$comment": "property - Ok, NOT OK: value, OK value nested, OK value nested with -, OK on 2nd index without or with -",
          "items": {
            "type": "object",
            "properties": {
              "item1": { "type": "string" },
              "item2": { "type": "object" }
            },
            "required": ["item1", "item2"],
            "defaultSnippets": [
              {
                "label": "snippetArrayInsideItems",
                "body": {
                  "value": "test",
                  "valueType": "string"
                }
              }
            ]
          }
        },
        "snippetArrayInsideItems2": {
          "type": "array",
          "$comment": "not ok",
          "items": {
            "ztype": ["string", "boolean", "number", "null"],
            "zzadditionalProperties": true,
            "defaultSnippets": [
              {
                "label": "snippetArrayInsideItems2",
                "body": ["string", false, 5, null]
              }
            ]
          }
        }
      }
    },

Is it tested? How?

tests

@p-spacek p-spacek merged commit a5e9d7f into jigx Mar 19, 2025
@p-spacek p-spacek deleted the feat/property-snippets-JIGX branch March 19, 2025 08:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant