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

Autocompletion / links on hover for Registry types #199

Closed
PatMyron opened this issue Sep 28, 2021 · 2 comments
Closed

Autocompletion / links on hover for Registry types #199

PatMyron opened this issue Sep 28, 2021 · 2 comments

Comments

@PatMyron
Copy link
Contributor

PatMyron commented Sep 28, 2021

Could ideally re-use schemas already passed in for linting itself:
aws-cloudformation/cfn-lint#1732


schema/all-spec.json just needs another definition per schema:

  "RESOURCE_TYPE" : {
    "type" : "object",
    "description" : "URL",
    "properties" : {
      # attributes: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-product-attribute-reference.html
      "Type" : {
        "description" : "URL",
        "type" : "string",
        "enum" : [ "RESOURCE_TYPE" ]
      },
      "Properties" : RESOURCE_SCHEMA
    },
    "required" : [ "Type", "Properties" ], # Properties required only if some properties are required
    "additionalProperties" : false
  },
attributes snippet:
      "DependsOn" : {
        "type" : [ "string", "array" ],
        "items" : {
          "type" : "string"
        }
      },
      "Metadata" : {
        "description" : "https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-metadata.html",
        "type" : "object"
      },
      "DeletionPolicy" : {
        "description" : "https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-deletionpolicy.html",
        "type" : "string",
        "enum" : [ "Delete", "Retain", "Snapshot" ]
      },
      "UpdateReplacePolicy" : {
        "description" : "https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-updatereplacepolicy.html",
        "type" : "string",
        "enum" : [ "Delete", "Retain", "Snapshot" ]
      },
      "CreationPolicy" : {
        "description" : "https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-creationpolicy.html",
        "type" : "object"
      },
      "UpdatePolicy" : {
        "description" : "https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-updatepolicy.html",
        "type" : "object"
      },

and resources patternProperties needs to reference that definition:

         , {
          "$ref" : "#/definitions/RESOURCE_TYPE"
        }

although VSCode may need to be restarted between schema patches? Only way I've been able to get it to pick up edits so far.. but maybe just the extension's client server could be restarted or something? @kddejong would know more than me on that side of things :)

@PatMyron
Copy link
Contributor Author

PatMyron commented Sep 28, 2021

debating JSON patch for the implementation:

[
   {
      "op":"add",
      "path":"/definitions/RESOURCE_TYPE",
      "value":{}
   },
   {
      "op":"add",
      "path":"/definitions/resources/patternProperties/^[a-zA-Z0-9]{1,255}$/oneOf/-",
      "value":{
        "$ref" : "#/definitions/RESOURCE_TYPE"
      }
   }
]
full definition:
[
   {
      "op":"add",
      "path":"/definitions/RESOURCE_TYPE",
      "value":{
         "type":"object",
         "properties":{
            "DependsOn":{
               "type":[
                  "string",
                  "array"
               ],
               "items":{
                  "type":"string"
               }
            },
            "Metadata":{
               "description":"https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-metadata.html",
               "type":"object"
            },
            "DeletionPolicy":{
               "description":"https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-deletionpolicy.html",
               "type":"string",
               "enum":[
                  "Delete",
                  "Retain",
                  "Snapshot"
               ]
            },
            "UpdateReplacePolicy":{
               "description":"https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-updatereplacepolicy.html",
               "type":"string",
               "enum":[
                  "Delete",
                  "Retain",
                  "Snapshot"
               ]
            },
            "CreationPolicy":{
               "description":"https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-creationpolicy.html",
               "type":"object"
            },
            "UpdatePolicy":{
               "description":"https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-updatepolicy.html",
               "type":"object"
            },
            "Type":{
               "type":"string",
               "enum":[
                  "RESOURCE_TYPE"
               ]
            },
            "Properties": RESOURCE_SCHEMA
         },
         "required":[
            # "Properties", # required only if some properties are required
            "Type"
         ],
         "additionalProperties":false
      }
   },
   {
      "op":"add",
      "path":"/definitions/resources/patternProperties/^[a-zA-Z0-9]{1,255}$/oneOf/-",
      "value":{
         "$ref":"#/definitions/RESOURCE_TYPE"
      }
   }
]

@kddejong
Copy link
Contributor

We have this in now. There may be ways to improve it but those are future issues.

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

No branches or pull requests

2 participants