API model issue

I have an API layout that includes an object with varying properties. This object is a collection of security permissions that a user has. It is used by the web client to determine which items to show. So, the json looks like:

“user_info”:
{
“entities”:
{
“entity1”:
{
“description”: “description of this entity”,
“actions”: [
“action1”,
“action2”
]
},
“entity2”:
. . .

So each entity represents a security permission that the user has and is used by the web client to know how to represent the interface. The API server does not use this information, but validates against the actual user security. I can easily model the individual entity portion since it has a predetermined format, but cannot see how to model the repeating entity section of the entities object within the user_info object. The entity “list” does not have a predetermined set, but is actually database driven.

Hello, “entities” is an object whose elements are key-value maps. The “addtionalProperties” of the OpenAPI specification fit this case. You can define it using a JSON Schema like this:

{
“type”: “object”,
“properties”: {
“user_info”: {
“type”: “object”,
“properties”: {
“entities”: {
“type”: “object”,
“properties”: {},
“additionalProperties”: {
“type”: “object”,
“properties”: {
“description”: {
“type”: “string”
},
“actions”: {
“type”: “array”,
“items”: {
“type”: “string”
}
}
}
}
}
}
}
}
}

We are developing the feature of visual editing additionalProperties and will release it at the end of this month.

Hello, we have improved “additional properties” in version 2.5.12, and it is now easier to create this kind of Schema. Please update Apidog and try it out.