Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add completion for additionalProperties propertyName #720

Conversation

p-spacek
Copy link
Contributor

What does this PR do?

Add the possibility to have code completion on properties of 'anonymous/unknown' object.
Example:
typescript:

object: Record<string,string>

will produce approximately this schema:

"object": {
  "type": "object",
  "additionalProperties": {
    "type": "string"
  }
}

then in the yaml it could be complicated for users to guest what can be inside the object

object:
  # no codecompletion result, no possibility for documentation

But jsonschema standard allows propertyNames element to extend properties json schema doc

So by this PR, this schema:

{
  "type": "object",
  "additionalProperties": true,
  "propertyNames": {
    "title": "key of obj",
    "description": "desc",
    "markdownDescription": "*md description*"
  }
}

will produce this result:
image

Additional notes

Note that defaultSnippets can do almost the same:

{
  "type": "object",
  "properties": {
    "prop1": {
      "type": "string"
    }
  },
  "additionalProperties": true,
  "propertyNames": {
    "title": "key of obj",
    "description": "desc",
    "markdownDescription": "*md description*"
  },
  "defaultSnippets": [
    {
      "label": "snippet property",
      "body": "${1:property}",
      "suggestionKind": 7,
      "markdownDescription": "*md description*"
    }
  ]
}

image

But with propertyNames implementation it will be possible to add some documentation info about pattern, min, max in the future.

What issues does this PR fix or reference?

no ref

Is it tested? How?

add UT

@coveralls
Copy link

coveralls commented May 30, 2022

Coverage Status

Coverage increased (+0.04%) to 82.435% when pulling 591b7b9 on p-spacek:feat/add-completion-for-additionalProperties-propertyNames into d0e26bc on redhat-developer:main.

Copy link
Contributor

@msivasubramaniaan msivasubramaniaan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Thanks for your contribution

@msivasubramaniaan msivasubramaniaan merged commit 85156a6 into redhat-developer:main Jun 8, 2022
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.

None yet

3 participants