Open brandonbloom opened 3 months ago
More generally, it seems like this part of the spec is not respected (emphasis mine):
8.2.3.1. Direct References with "$ref"
The "$ref" keyword is an applicator that is used to reference a statically identified schema. Its results are the results of the referenced schema. Note that this definition of how the results are determined means that other keywords can appear alongside of "$ref" in the same schema object.
openapi3.0 does not support the full JSON Schema spec. It is in openapi3.1 and this is still an open issue
Apologies for the noise. I realized this after some more exploration/experimentation. I've got a workaround now:
export const refExtrasToAllOf = (schema: Schema): Schema => {
if (RefSchema.guard(schema) && Object.keys(schema).length > 1) {
const { $ref, ...extra } = schema;
const allOf = AllOfSchema.guard(schema) ? schema.allOf : [];
allOf.push({ $ref });
return { ...extra, allOf };
}
return schema;
};