I am trying to create a parent - child relationship using json schemas. I have tried different approaches but all are failing. I have the abstract definition of AbstractRequest:
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://example.com/schemas/abstractReply",
"type": "object",
"properties": {
"transactionType": {
"type": "string",
"enum": ["PORTFOLIO_REQUEST", "ADD_STOCK_REQUEST", "GET_STOCK_REQUEST"]
}
},
"required": ["transactionType"]
}
and I want a child request that is linked to this one. This is what I have currently:
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://example.com/schemas/portfolioRequest",
"description": "Portfolio Request",
"unevaluatedProperties": false,
"allOf": [
{
"$ref": "https://example.com/schemas/abstractReply"
},
{
"properties": {
"portfolioId": {
"type": "string",
"description": "Id of the portfolio"
},
"userId": {
"type": "string",
"description": "User Id of the request"
}
},
"required": ["portfolioId"]
}
]
}
I have also tried referencing the abstractRequest directly within the child but nothing happens.
Right know if I use this set up 2 things will happen:
- AbstractRequest is generated but is not abstract (is a normal class)
- PortfolioRequest is not generated at all
I am using jsonschema2pojo-maven-plugin to autogenerate.
I appreciate the help :)