You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by "kayx23 (via GitHub)" <gi...@apache.org> on 2025/06/03 04:37:52 UTC

Re: [PR] docs: improve `plugin-develop` docs [apisix]

kayx23 commented on code in PR #12242:
URL: https://github.com/apache/apisix/pull/12242#discussion_r2122635738


##########
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:
   A couple issues regarding this rearrangement:
   
   1. it is easier to read if this info is moved down to its corresponding content:
   
   <img width="894" alt="image" src="https://github.com/user-attachments/assets/5e5ec305-2ca8-4cda-bf59-281af20ea9f2" />
   
   2. Missing information - `consumer_schema` was removed in this PR. Why?
   



-- 
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-unsubscribe@apisix.apache.org

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