slow-groovin commented on code in PR #12242: URL: https://github.com/apache/apisix/pull/12242#discussion_r2123237839
########## docs/en/latest/plugin-develop.md: ########## @@ -205,18 +129,25 @@ local schema = { The schema defines a non-negative number `i`, a string `s`, a non-empty array of `t`, and `ip` / `port`. Only `i` is required. -At the same time, we need to implement the __check_schema(conf)__ method to complete the specification verification. +At the same time, we need to implement the __check_schema(conf, schema_type)__ method to complete the specification verification. ```lua function _M.check_schema(conf, schema_type) + if schema_type == core.schema.TYPE_METADATA then + return core.schema.check(metadata_schema, conf) + end return core.schema.check(schema, conf) end ``` +:::note + Note: the project has provided the public method "__core.schema.check__", which can be used directly to complete JSON verification. -In addition, if the plugin needs to use some metadata, we can define the plugin `metadata_schema`, and then we can dynamically manage these metadata through the `Admin API`. Example: +::: + +The input parameter **schema_type** is used to distinguish between different schemas types. For example, many plugins need to use some [metadata](./terminology/plugin-metadata.md), so they define the plugin's `metadata_schema`. Another example, the [key-auth](https://github.com/apache/apisix/blob/master/apisix/plugins/key-auth.lua) plugin needs to provide a `consumer_schema` to check the configuration of the `plugins` attribute of the `consumer` resource in order to be used with the [Consumer](./admin-api.md#consumer) resource. Review Comment: For the reader, the purpose of this paragraph is simply to indicate that the function can be used to check different schemas, so I removed the excessive content, including `consumer_schema`. However, `consumer_schema` might still be worth keeping. I have reorganized this paragraph. -- 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: notifications-unsubscr...@apisix.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org