I have two schemas that share request part. How to extract shared part from them and put…
- User
I have two schemas that share request part. How to extract shared part from them and put in separate schema : { "properties": { "action": { "description": "some action", "type": "string" }, "request": { "properties": { "allowedUsers": { "items": { "additionalProperties": false, "properties": { "UserName": { "description": "Account user name", "type": "string" } }, "required": [ "UserName" ], "type": "object" }, "type": "array" } }, "required": [ "allowedUsers" ], "type": "object" } }, "required": [ "request", "action" ], "type": "object" }
{ "properties": { "state": { "description": "some state", "type": "string" }, "request": { "properties": { "allowedUsers": { "items": { "additionalProperties": false, "properties": { "UserName": { "description": "Account user name", "type": "string" } }, "required": [ "UserName" ], "type": "object" }, "type": "array" } }, "required": [ "allowedUsers" ], "type": "object" } }, "required": [ "request", "action" ], "type": "object" }
- Assistant
To extract the shared "request" part from the two schemas and put it in a separate schema, you can create a new schema specifically for the shared "request" part and then reference that schema in both original schemas. Here is how you can do it:
Shared "request" schema:
{ "properties": { "allowedUsers": { "items": { "additionalProperties": false, "properties": { "UserName": { "description": "Account user name", "type": "string" } }, "required": [ "UserName" ], "type": "object" }, "type": "array" } }, "required": [ "allowedUsers" ], "type": "object" }
Updated original schemas: