Open selodev opened 4 years ago
By JSON output, do you mean a https://json-schema.org/ definition of the Schema, or something else?
Hi yes, that would be great. There is a lot of work done by you to generate schema.d.ts file. Why not also create a json object representation of the entire schema.d.ts file, so that we can use it in our projects such as creating ui components based on the json file. https://github.com/ccpu/ts-to-json is an another example.
Hmm. There are separate libraries that create JSONschema for Schema.org as-is. They're useful especially if you have a .json file you want to represent as a specific SDO type.
Is your use case different? Do you want JSONschema representing actual SDO JSON-LD? or JSONschema consumable by TypeDoc for documentation on the "schema-dts" types themselves (including WithContext
I pretty much want some what JSON-LD that I can loop over without having the reshape https://schema.org/version/latest/all-layers.jsonld. I know you guys created all the interfaces by extracting or converting https://schema.org/version/latest/all-layers.jsonld to ts-dts, I wanted to stick the way you shaped the interfaces and I wanted to be able to the use extractions the way you did, so I have full blown schema with its relations but again stick to the interfaces. So pretty much a json-ld representation of the schema.d.ts so I can create components based on the same relation in the schema.d.ts like in https://json-ld.org/#developers. Sorry I am having hard time to explain.
What is SDO?
Sent from my iPhone
On Jul 7, 2020, at 7:51 AM, Eyas notifications@github.com wrote:
Hmm. There are separate libraries that create JSONschema for Schema.org as-is. They're useful especially if you have a .json file you want to represent as a specific SDO type.
Is your use case different? Do you want JSONschema representing actual SDO JSON-LD? or JSONschema consumable by TypeDoc for documentation on the "schema-dts" types themselves (including WithContext, etc)?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/google/schema-dts/issues/113#issuecomment-654918343, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AMXYIUGAMEJ3NR67TJCBRZ3R2MY7BANCNFSM4ORAIEBA.
Just a shorthand for "Schema.org" :)
There are separate libraries that create JSONschema for Schema.org as-is. They're useful especially if you have a .json file you want to represent as a specific SDO type.
@Eyas can you detail where those libraries are? My Google-fu is too weak to locate those projects.
Personally, I'd have loved to have found a Typebox implementation of Schema.org types. I did try modifying transform.ts:
import * as Codegen from '@sinclair/typebox-codegen';
// ...
for (const cls of sorted) {
if (cls.deprecated && !includeDeprecated) continue;
for (const node of cls.toNode(context, properties)) {
const result = printer.printNode(EmitHint.Unspecified, node, source);
// await write(result);
const code = Codegen.TypeScriptToTypeBox.Generate(result);
// const model = Codegen.TypeScriptToModel.Generate(result);
// const code = Codegen.ModelToJsonSchema.Generate(model); // This fails because the code generator needs the dependencies in scope
await write(code);
await write('\n');
}
await write('\n');
}
This... Sorta worked. I was able to get a typebox file output from schema-dts-gen
this way, however at transpile/run time there are too many calls to the program stack. That suggests some infinite looping due to the awkward hierarchy created by typescript. E.g. the Text
type is a union of its subtypes like PronounceableText
, but PronounceableText
includes a property of the Text
type.
Such as --options Specify a json option file that should be loaded. If not specified TypeDoc will look for 'schema.json' in the current directory.
--json <path/to/output.json> Specifies the location and file name a json file describing the project is written to. When specified no documentation will be generated.
https://github.com/TypeStrong/typedoc repository is an example of json output.