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/11/04 07:05:29 UTC

[GitHub] [apisix] liuxiran commented on issue #2082: request help: Update plugin's schema

liuxiran commented on issue #2082:
URL: https://github.com/apache/apisix/issues/2082#issuecomment-721552396


   > Added here for tracking #2432 .
   > 
   > * [x]  request-validation
   
   After the schema draft updated in APISIX, **request-validation** also needs to transform the schema at plugin componet, so that it can work properly in dashboard, just like proxy-rewrite do. @juzhiyuan 
   
   - the schema turned by APISIX:
   ```json
   {
   	"anyOf": [{
   		"properties": {
   			"body_schema": {
   				"type": "object"
   			}
   		},
   		"required": ["body_schema"],
   		"title": "Body schema"
   	}, {
   		"properties": {
   			"header_schema": {
   				"type": "object"
   			}
   		},
   		"required": ["header_schema"],
   		"title": "Header schema"
   	}],
   	"type": "object"
   }
   ```
   - dashboard needs to transform the schema to:
   ```json
   {
       "type": "object",
       "properties": {
         "requestParams": {
           "title": "define request paramers",
           "type": "array",
           "items": {
             "type": "object",
             "anyOf": [{
                 "title": "define body params",
                 "properties": {
                   "body_schema": {
                     "type": "object",
                     "properties": {
                       "key": {
                         "type": "string"
                       },
                       "valueType": {
                         "type": "string",
                         "enum": [
                           "string",
                           "array",
                           "integer",
                           "number",
                           "object",
                           "boolean"
                         ]
                       },
                       "required": {
                         "type": "boolean"
                       }
                     }
                   }
                 },
                 "required": ["body_schema"],
                 "miniItems": 1
               },
               {
                 "title": "define header params",
                 "properties": {
                   "header_schema": {
                     "type": "object",
                     "properties": {
                       "key": {
                         "type": "string"
                       },
                       "valueType": {
                         "type": "string",
                         "enum": [
                           "string",
                           "array",
                           "integer",
                           "number",
                           "object",
                           "boolean"
                         ]
                       },
                       "required": {
                         "type": "boolean"
                       }
                     }
                   }
                 }
               }
             ]
           }
         }
       }
     }
   ``` 
   
   - the config page in dashboard looks like:
   
   
   
   ![2020-11-04 15-04-20屏幕截图](https://user-images.githubusercontent.com/2561857/98079645-1e379000-1eaf-11eb-8633-cd90e22c0f24.png)
   
   


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