I am trying to use TJS to generate a JSONSchema object, and have successfully used it in the past. However, a specific types file that I am passing is being generated as a JSONSchema object, but without properties. This is tripping up some code downstream from these steps.
Note that there are definitions, but no properties.
This is the code used to generate the JSONSchema:
export const generateJSONSchema = async (type: string, typesFilename: string): Promise<$RefParser.JSONSchema> => {
console.log(`Generating JSONSchema for object ${type}`);
// Convert to JSONSchema
const jsonSchemaProgram = TJS.getProgramFromFiles([resolve(typesFilename)], {
strictNullChecks: true,
});
const jsonSchema = TJS.generateSchema(jsonSchemaProgram, type);
if (!jsonSchema) {
throw new Error(`Unable to generate JSONSchema for type ${type} and types file ${typesFilename}`);
}
// We need to de-reference types in the JSONSchema, otherwise the BigQuery schema library will complain
const derefSchema = await $RefParser.dereference(jsonSchema as JSONSchema7);
return derefSchema;
};
I am trying to use TJS to generate a JSONSchema object, and have successfully used it in the past. However, a specific types file that I am passing is being generated as a JSONSchema object, but without properties. This is tripping up some code downstream from these steps.
Types file: https://github.com/OlympusDAO/subgraph-cache/blob/6a7da6cf6e8a0a47e30ad9efb75e68081f20821a/generated/BondPurchase_types.ts
Generated JSONSchema: https://github.com/OlympusDAO/subgraph-cache/blob/6a7da6cf6e8a0a47e30ad9efb75e68081f20821a/generated/BondPurchase.jsonschema
Note that there are definitions, but no properties.
This is the code used to generate the JSONSchema: