You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2020/08/19 12:12:55 UTC

[GitHub] [apisix] juzhiyuan opened a new issue #2086: request help: Update plugin's schema limit-count

juzhiyuan opened a new issue #2086:
URL: https://github.com/apache/apisix/issues/2086


   refer to https://github.com/apache/apisix/issues/2082#issue-681772868
   
   ## Currently
   ```json
   {
       "additionalProperties":false,
       "id":"root:/",
       "properties":{
           "count":{
               "minimum":0,
               "type":"integer"
           },
           "key":{
               "enum":[
                   "remote_addr",
                   "server_addr",
                   "http_x_real_ip",
                   "http_x_forwarded_for"
               ],
               "type":"string"
           },
           "policy":{
               "enum":[
                   "local",
                   "redis"
               ],
               "type":"string"
           },
           "redis_host":{
               "minLength":2,
               "type":"string"
           },
           "redis_password":{
               "minLength":0,
               "type":"string"
           },
           "redis_port":{
               "minimum":1,
               "type":"integer"
           },
           "redis_timeout":{
               "minimum":1,
               "type":"integer"
           },
           "rejected_code":{
               "default":503,
               "maximum":600,
               "minimum":200,
               "type":"integer"
           },
           "time_window":{
               "minimum":0,
               "type":"integer"
           }
       },
       "required":[
           "count",
           "time_window",
           "key"
       ],
       "type":"object"
   }
   ```
   
   ## Expected
   No expected schema currently, please refer to `dependencies` in JSONSchema, this can help us to build dynamically schema. e.g https://react-jsonschema-form.readthedocs.io/en/latest/usage/dependencies/#unidirectional


----------------------------------------------------------------
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.

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



[GitHub] [apisix] juzhiyuan edited a comment on issue #2086: request help: Update plugin's schema limit-count

Posted by GitBox <gi...@apache.org>.
juzhiyuan edited a comment on issue #2086:
URL: https://github.com/apache/apisix/issues/2086#issuecomment-677498495


   ```json
   {
       "properties":{
           "a":{
               "type":"string",
               "enum": ["a1", "a2"]
           },
           "b":{
               "type":"string"
           }
       },
       "dependencies":{
           "a":{
               "oneOf":[
                   {
                       "properties":{
                           "b":{
                               "type":"string"
                           },
                           "a":{
                               "enum":[
                                   "a1"
                               ]
                           }
                       },
                       "required":[
                               "a",
                               "b"
                           ]
                   }
               ]
           }
       },
       "type":"object"
   }
   ```


----------------------------------------------------------------
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.

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



[GitHub] [apisix] juzhiyuan commented on issue #2086: request help: Update plugin's schema limit-count

Posted by GitBox <gi...@apache.org>.
juzhiyuan commented on issue #2086:
URL: https://github.com/apache/apisix/issues/2086#issuecomment-677498495


   ```json
   **{
       "properties":{
           "a":{
               "type":"string",
               "enum": ["a1", "a2"]
           },
           "b":{
               "type":"string"
           }
       },
       "dependencies":{
           "a":{
               "oneOf":[
                   {
                       "properties":{
                           "b":{
                               "type":"string"
                           },
                           "a":{
                               "enum":[
                                   "a1"
                               ]
                           }
                       },
                       "required":[
                               "a",
                               "b"
                           ]
                   }
               ]
           }
       },
       "type":"object"
   }
   ```


----------------------------------------------------------------
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.

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



[GitHub] [apisix] juzhiyuan commented on issue #2086: request help: Update plugin's schema limit-count

Posted by GitBox <gi...@apache.org>.
juzhiyuan commented on issue #2086:
URL: https://github.com/apache/apisix/issues/2086#issuecomment-677466608


   Here is a working well schema with `dependencies`.
   
   ```json
   {
     "additionalProperties": false,
     "id": "root:/",
     "properties": {
       "count": {
         "minimum": 0,
         "type": "integer"
       },
       "key": {
         "enum": [
           "remote_addr",
           "server_addr",
           "http_x_real_ip",
           "http_x_forwarded_for"
         ],
         "type": "string"
       },
       "policy": {
         "enum": ["local", "redis"],
         "type": "string",
         "default": "local"
       },
       "rejected_code": {
         "default": 503,
         "maximum": 600,
         "minimum": 200,
         "type": "integer"
       },
       "time_window": {
         "minimum": 0,
         "type": "integer"
       }
     },
     "required": ["count", "time_window", "key"],
     "type": "object",
     "dependencies": {
       "policy": {
         "oneOf": [
           {
             "properties": {
               "policy": {
                 "enum": ["local"]
               }
             }
           },
           {
             "properties": {
               "policy": {
                 "enum": ["redis"]
               },
               "redis_host": {
                 "minLength": 2,
                 "type": "string"
               },
               "redis_password": {
                 "minLength": 0,
                 "type": "string"
               },
               "redis_port": {
                 "minimum": 1,
                 "type": "integer"
               },
               "redis_timeout": {
                 "minimum": 1,
                 "type": "integer"
               }
             }
           }
         ]
       }
     }
   }
   ```


----------------------------------------------------------------
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.

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



[GitHub] [apisix] membphis commented on issue #2086: request help: Update plugin's schema limit-count

Posted by GitBox <gi...@apache.org>.
membphis commented on issue #2086:
URL: https://github.com/apache/apisix/issues/2086#issuecomment-676255278


   many thx for reporting. I'll fix it soon.


----------------------------------------------------------------
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.

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



[GitHub] [apisix] juzhiyuan edited a comment on issue #2086: request help: Update plugin's schema limit-count

Posted by GitBox <gi...@apache.org>.
juzhiyuan edited a comment on issue #2086:
URL: https://github.com/apache/apisix/issues/2086#issuecomment-677466608


   Here is a working well schema with `dependencies`, [playground](https://rjsf-team.github.io/react-jsonschema-form/#eyJmb3JtRGF0YSI6eyJwb2xpY3kiOiJsb2NhbCIsInJlamVjdGVkX2NvZGUiOjUwMywiZmlyc3ROYW1lIjoiQ2h1Y2siLCJsYXN0TmFtZSI6Ik5vcnJpcyIsImFnZSI6NzUsImJpbyI6IlJvdW5kaG91c2Uga2lja2luZyBhc3NlcyBzaW5jZSAxOTQwIiwicGFzc3dvcmQiOiJub25lZWQiLCJ0aW1lX3dpbmRvdyI6MjIyfSwic2NoZW1hIjp7ImFkZGl0aW9uYWxQcm9wZXJ0aWVzIjpmYWxzZSwiaWQiOiJyb290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In0sImxhc3ROYW1lIjp7InVpOmVtcHR5VmFsdWUiOiIiLCJ1aTphdXRvY29tcGxldGUiOiJnaXZlbi1uYW1lIn0sImFnZSI6eyJ1aTp3aWRnZXQiOiJ1cGRvd24iLCJ1aTp0aXRsZSI6IkFnZSBvZiBwZXJzb24iLCJ1aTpkZXNjcmlwdGlvbiI6IihlYXJ0aGlhbiB5ZWFyKSJ9LCJiaW8iOnsidWk6d2lkZ2V0IjoidGV4dGFyZWEifSwicGFzc3dvcmQiOnsidWk6d2lkZ2V0IjoicGFzc3dvcmQiLCJ1aTpoZWxwIjoiSGludDogTWFrZSBpdCBzdHJvbmchIn0sImRhdGUiOnsidWk6d2lkZ2V0IjoiYWx0LWRhdGV0aW1lIn0sInRlbGVwaG9uZSI6eyJ1aTpvcHRpb25zIjp7ImlucHV0VHlwZSI6InRlbCJ9fX0sInRoZW1lIjoiZGVmYXVsdCIsI
 mxpdmVTZXR0aW5ncyI6eyJ2YWxpZGF0ZSI6ZmFsc2UsImRpc2FibGUiOmZhbHNlLCJvbWl0RXh0cmFEYXRhIjpmYWxzZSwibGl2ZU9taXQiOmZhbHNlfX0=)
   
   ```json
   {
     "additionalProperties": false,
     "id": "root:/",
     "properties": {
       "count": {
         "minimum": 0,
         "type": "integer"
       },
       "key": {
         "enum": [
           "remote_addr",
           "server_addr",
           "http_x_real_ip",
           "http_x_forwarded_for"
         ],
         "type": "string"
       },
       "policy": {
         "enum": ["local", "redis"],
         "type": "string",
         "default": "local"
       },
       "rejected_code": {
         "default": 503,
         "maximum": 600,
         "minimum": 200,
         "type": "integer"
       },
       "time_window": {
         "minimum": 0,
         "type": "integer"
       }
     },
     "required": ["count", "time_window", "key"],
     "type": "object",
     "dependencies": {
       "policy": {
         "oneOf": [
           {
             "properties": {
               "policy": {
                 "enum": ["local"]
               }
             }
           },
           {
             "properties": {
               "policy": {
                 "enum": ["redis"]
               },
               "redis_host": {
                 "minLength": 2,
                 "type": "string"
               },
               "redis_password": {
                 "minLength": 0,
                 "type": "string"
               },
               "redis_port": {
                 "minimum": 1,
                 "type": "integer"
               },
               "redis_timeout": {
                 "minimum": 1,
                 "type": "integer"
               }
             }
           }
         ]
       }
     }
   }
   ```


----------------------------------------------------------------
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.

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



[GitHub] [apisix] membphis commented on issue #2086: request help: Update plugin's schema limit-count

Posted by GitBox <gi...@apache.org>.
membphis commented on issue #2086:
URL: https://github.com/apache/apisix/issues/2086#issuecomment-676283463


   I just learned about JSON Schema, `dependencies` can't handle this situation. We need to find other way.
   
   It seems that `if--else--then` is the one we need. but the [jsonschema](https://github.com/api7/jsonschema) does not support this feature.
   
   https://stackoverflow.com/questions/51539586/how-do-i-use-the-if-then-else-condition-in-json-schema


----------------------------------------------------------------
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.

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



[GitHub] [apisix] moonming closed issue #2086: request help: Update plugin's schema limit-count

Posted by GitBox <gi...@apache.org>.
moonming closed issue #2086:
URL: https://github.com/apache/apisix/issues/2086


   


----------------------------------------------------------------
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.

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



[GitHub] [apisix] membphis commented on issue #2086: request help: Update plugin's schema limit-count

Posted by GitBox <gi...@apache.org>.
membphis commented on issue #2086:
URL: https://github.com/apache/apisix/issues/2086#issuecomment-677516006


   many thx, that is a better way. I'll make a try with this way later


----------------------------------------------------------------
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.

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