potiuk commented on a change in pull request #17682:
URL: https://github.com/apache/airflow/pull/17682#discussion_r710340282



##########
File path: airflow/provider.yaml.schema.json
##########
@@ -195,11 +195,33 @@
     },
     "hook-class-names": {
       "type": "array",
-      "description": "Hook class names that provide connection types to core",
+      "description": "Hook class names that provide connection types to core 
(deprecated by connection-types)",
       "items": {
-        "type": "string"
+          "type": "string"
+      },
+      "deprecated": {
+        "description": "The hook-class-names property has been deprecated in 
favour of connection-types which is more performant version allowing to only 
import individual Hooks rather than all hooks at once",
+        "deprecatedVersion": "2.2"
       }
     },
+    "connection-types": {
+      "type": "array",
+      "description": "Map of connection types mapped to hook class names",

Review comment:
       The Map was really a copy&paste victim not intention.
   
   It could also work with Map - because we have no possibility to duplicate 
connection_type. But map does not give us much here,  the uniqueness has to be 
checked anyway for every connection type, because it is cross-provider and we 
just drop any connection_type that we already have registered. 
   
   But one reason why it is "better" is how jsonschema works nicer with hints 
and validation when you edit it.
   
   Compare:
   
   ```
       "connection-types": {
         "type": "array",
         "description": "Array of connection types mapped to hook class names",
         "items": {
             "type": "object",
             "properties": {
                 "connection-type": {
                     "description": "Type of connection defined by the 
provider",
                     "type": "string"
                 },
                 "hook-class-name": {
                     "description": "Hook class name that implements the 
connection type",
                     "type": "string"
                 }
             }
         },
   ```
   
   with (that's how it would look like if we use map:
   
   
   ```
       "additional-extras": {
         "type": "object",
         "description": "Additional extras that the provider should have"
       },
   ```
   
   I have my provider.yaml mapped to the schema in IntelliJ and it does not 
only display the hints but also it validates if the fields are of the "string" 
type. It's a  bit trivial, but It makes me want to be a bit more verbose to 
give a better hint/validation to users. 
   
   
![image](https://user-images.githubusercontent.com/595491/133659323-e6276c42-15de-4638-bfbf-bac47a93d00c.png)
   
   
   
![image](https://user-images.githubusercontent.com/595491/133659483-7a5a9500-a938-4ebd-a37a-854886626278.png)
   
   
   Also I think it reads a bit better when you have array of (effectitvely) 
named tuples. It's more read-optimised than  write-optimised. 
   
   




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@airflow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to