jaymin2609 opened a new issue, #12597:
URL: https://github.com/apache/apisix/issues/12597
### Current Behavior
Hi APISIX team,
Iām trying to add a very simple custom plugin (`my-plugin`), but I always
get a schema validation error when enabling it on a route.
**Steps I did**
1. Created `my-plugin.lua` under `/usr/local/apisix/apisix/plugins/`:
```
local core = require("apisix.core")
local plugin_name = "my-plugin"
local schema = {
type = "object",
properties = {
message = { type = "string" }
},
additionalProperties = false
}
local _M = {
version = 0.1,
priority = 101010010,
name = plugin_name,
schema = schema,
}
function _M.check_schema(conf)
return core.schema.check(schema, conf)
end
function _M.access(conf, ctx)
core.response.set_header("X-My-Plugin", conf.message or "hello")
end
return _M
```
2. Added the plugin to `config.yaml`:
```
plugins:
- my-plugin
- ext-plugin-pre-req
- ext-plugin-post-resp
- prometheus
...
```
3. Verified plugin shows up in the list:
```
curl "http://127.0.0.1:9180/apisix/admin/plugins/list" \
-H "X-API-KEY: edd1c9f034335f136f87ad84b625c8f1"
```
4. Output includes `"my-plugin"` ā
Tried to create a route:
```
curl -X PUT "http://127.0.0.1:9180/apisix/admin/routes/1" \
-H "X-API-KEY: edd1c9f034335f136f87ad84b625c8f1" \
-d '{
"uri": "/test",
"upstream": {
"type": "roundrobin",
"nodes": {
"httpbin.org:80": 1
}
},
"plugins": {
"my-plugin": {
"message": "hello"
}
}
}'
```
Error
Every time I get:
```
Request Error Code: 10000
schema validate failed: schema not found, path: plugins.my-plugin
```
Logs
APISIX logs confirm the plugin is loaded:
`load(): new plugins: {"limit-count":true,"my-plugin":true,...}`
But schema validation still fails when using Admin API.
Question
Why does APISIX load the plugin but fail to find its schema?
Is there some extra step required (besides adding to `config.yaml` and
`apisix/plugins/`) to make the schema available to Admin API?
Any help would be appreciated š
### Expected Behavior
_No response_
### Error Logs
_No response_
### Steps to Reproduce
Add plugin in your route
```
"plugins": {
"my-plugin":{
"message":"hello"
},
```
### Environment
- APISIX version (run `apisix version`):
- Operating system (run `uname -a`):
- OpenResty / Nginx version (run `openresty -V` or `nginx -V`):
- etcd version, if relevant (run `curl
http://127.0.0.1:9090/v1/server_info`):
- APISIX Dashboard version, if relevant:
- Plugin runner version, for issues related to plugin runners:
- LuaRocks version, for installation issues (run `luarocks --version`):
--
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]