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


##########
docs/en/latest/plugin-develop.md:
##########
@@ -228,55 +159,28 @@ local metadata_schema = {
     required = {"ikey", "skey"},
 }
 
-local plugin_name = "example-plugin"
-
-local _M = {
-    version = 0.1,
-    priority = 0,        -- TODO: add a type field, may be a good idea
-    name = plugin_name,
-    schema = schema,
-    metadata_schema = metadata_schema,
-}
-```
-
-You might have noticed the key-auth plugin has `type = 'auth'` in its 
definition.
-When we set the type of plugin to `auth`, it means that this plugin is an 
authentication plugin.
-
-An authentication plugin needs to choose a consumer after execution. For 
example, in key-auth plugin, it calls the `consumer.attach_consumer` to attach 
a consumer, which is chosen via the `apikey` header.
-
-To interact with the `consumer` resource, this type of plugin needs to provide 
a `consumer_schema` to check the `plugins` configuration in the `consumer`.
-
-Here is the consumer configuration for key-auth plugin:
-
-```json
-{
-  "username": "Joe",
-  "plugins": {
-    "key-auth": {
-      "key": "Joe's key"
-    }
-  }
-}
+function _M.check_schema(conf, schema_type)
+    --- check schema for metadata
+    if schema_type == core.schema.TYPE_METADATA then
+        return core.schema.check(metadata_schema, conf)
+    end
+    return core.schema.check(schema, conf)
+end
 ```
 
-It will be used when you try to create a [Consumer](./admin-api.md#consumer)
-
-To validate the configuration, the plugin uses a schema like this:
+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.
 
 ```lua

Review Comment:
   Can put the title like this:
   
   ```suggestion
   ```lua title="key-auth.lua"
   ```
   
   and remove the comment in the code block:
   
   <img width="149" alt="image" 
src="https://github.com/user-attachments/assets/5fffe4dc-c693-4cfb-8a7d-87b7abf4bed1";
 />
   



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to