Closed tadamovsky closed 1 year ago
This is probably what you want I imagine:
const result = merge(
{
$ref: "#/components/schemas/MySchema",
allOf: [
{
$ref: "#/components/schemas/2",
},
],
},
{
complexResolvers: {
$ref: {
keywords: ["$ref"],
resolver(values, path, mergeSchemas, options) {
return {
...values[0],
allOf: values.slice(1).map((v) => v),
};
},
},
},
}
);
produces:
{
"$ref": "#/components/schemas/MySchema",
"allOf": [
{
"$ref": "#/components/schemas/2"
}
]
}
Could probably be a easier way to achieve this though.
I'd like to eliminate allOf but to keep the references, in fact I have to keep them, because the schema is recursive. If not, can you consider supporting local refs. json-schema-ref-parser has a mode to make all refs local.