Kong 1.0 configuration plugin schema changes


#1

Trying to convert a custom plugin schema, my intent is to have an array of Routes, each having properties.

Config:
  Routes:
  - name: route1
    otherProp: prop
  - name: route2
    otherProp: prop2

Note that each route has properties { name, otherProp }, and there can be many Routes.

I am trying this (below). However it does not validate in Kong. It seems to have an issue with a Record in an Array structure.

Error from Kong:

nginx: [warn] [kong] plugins.lua:240 schema for plugin ‘myplugin’ is invalid: [postgres] schema violation (fields.fields: {
elements = {
fields = “expected an array”
}
})

Also note that this is just Kong validating the schema, at this point it doesnt even have data in their to validate the route against. It just doesnt like the stand-alone schema definition.

This is in my schema.lua

If I make the Record a simple type like String, there’s no validation error. So an Array of strings seems to be possible. But not an array of Structs.

Am I missing something??

return {
  name = "myplugin",
  fields = {
    { config = {
        type = "record",
        fields = {
          { routes = {
              type = "array",
              required = true,
              default = {},
	      elements = {
                type = "record",
				required = true,
				fields = { 
				  name = { type = "string", default = "", required = false }, 
				  otherProp = { type = "string", default = "", required = false }, 
				},
              },
            },
          },
        },
      },
    },
  },
}