Repository: cloud-custodian/cloud-custodian

Issue:
azure - Error with schema and VS Studio Code
**Describe the bug**
I tried a lot of times even with different schemas but I always receive:
`[Error - 1:15:59 PM] Request textDocument/completion failed.
  Message: Request textDocument/completion failed with message: Cannot read property '$ref' of null
  Code: -32603 `
or `Unable to parse content from '(working directory deleted for issue reporting but file is there)\schemu.json': Parse error at offset 0.`

**To Reproduce**
$ python3 -m venv custodian
$ source custodian/bin/activate
(custodian) $ pip install c7n
(custodian) $ pip install c7n_azure
custodian schema --json > schema.json

**Expected behavior**
Auto completion working in VS Studio Code


**Background (please complete the following information):**
 - OS: W10
 - Python Version: 3.9 but tried with 3.8 too
 - Custodian Version: 0.9.6
 - Cloud Provider: aws and azure



Discussion:
what's your user configuration file for the jsonschema look like in vscode? you may have to give an absolute path to the file
![image](https://user-images.githubusercontent.com/12020620/95987907-71617a00-0dfe-11eb-914d-484bfed25ffb.png)

just to note in your example you have the file called `schema.json` in your vscode config you have it called `schemu.json` which are different names.
just changed the name because I was testing with different files but is the same file.
I tested with docker and the same result when generate the file and importing into the schema VS
Tried with the 0.9.7 and the same error appears. 
![image](https://user-images.githubusercontent.com/12020620/96183744-bb855100-0f0d-11eb-9282-ae13ce92b1d3.png)

@gussj I will take a look at this tonight or tomorrow as I have never set the VS Code integration and this would be a good time for me to test it out

Thanks so much for taking this into account. Really appreciate the effort and work on this project :)

> Thanks so much for taking this into account. Really appreciate the effort and work on this project :)
@gussj 
I worked on this last night and found the issue to be within the c7n_azure tool.  If I uninstalled c7n_azure and then outputted my schema.json for VS Code it works.  Not sure what exactly in the Azure schema is causing an issue but if you want to get it working for AWS and GCP now you can, we just need to further investigate the azure issue piece

Thanks so much. I will check to see if you found the error in the future since I'm really interested in this schema for azure.
Once I got it working in VS Code I played around with it some and while it is useful in the sense that it shows you what options there are, it doesn't allow you to write policies without referring to the docs as it doesn't format the syntax properly when building filters/actions with it and it doesn't provide what different fields are under certain actions and filters so I still found referencing the docs more useful.  I could seeing it being useful to auto-complete some things for you which are simple 1 value options such as resource: or single value actions/filters like ** - delete** etc.  I have thought about reinventing this wheel and making it easier to install (maybe just via a VS Code extension) and adding additional functionality, notes on schemas for the different filters/actions etc but that would be down the road a ways.  If you have any experience building VS Code extensions or schemas, you are more than welcome to contribute and make the process smoother and better
Also another thing to note is that it only worked with .yaml file extensions with the way it is setup via the custodian docs and it doesn't work with .yml files.  Not sure why but if you are having issues getting it to work without the azure bits that could be a cause

through a lot of trial and error i was able to narrow this down to the logic app action which appears to have a broken schema.
just a note I was able to get intelli-sense to work with VSCode and neovim with the COC-TSServer running in node. 


Resolving patch:
diff --git a/c7n/utils.py b/c7n/utils.py
--- a/c7n/utils.py
+++ b/c7n/utils.py
@@ -142,6 +142,10 @@ def type_schema(
         s['additionalProperties'] = False
 
     s['properties'].update(props)
+
+    for k, v in props.items():
+        if v is None:
+            del s['properties'][k]
     if not required:
         required = []
     if isinstance(required, list):


Test patch:
diff --git a/tools/c7n_azure/tests_azure/test_logic_app.py b/tools/c7n_azure/tests_azure/test_logic_app.py
--- a/tools/c7n_azure/tests_azure/test_logic_app.py
+++ b/tools/c7n_azure/tests_azure/test_logic_app.py
@@ -15,6 +15,9 @@
 
 class LogicAppTest(BaseTest):
 
+    def test_valid_schema(self):
+        assert 'url' not in LogicAppAction.schema['properties']
+
     def test_valid_policy(self):
         policy = {
             "name": "logic-app",