Generate Typescript Types out of Google schema definition

79 views Asked by At

So in order to generate a proper feed based on Google's schema definition for e.g. TVSeries it is possible to fetch this definition from this url: TVSeries Definition

and run tools like AJV in order to validate your generated feed. This is all good and fine. However what would be even more developer friendly is to have already a static typing for the required validation schema. Currently I'm using this library in order to get static types for my schema definition: Schema-DTS and what is even more annoying is that those types are sometimes conflicting with the schema definition that google allows. For example very simple comparison:

  • TVSeries from Schema.org does only allow for the @context to have https://schema.org, see: https://schema.org/TVSeries
  • While the google schema definition allows
              "enum": [
                "http://schema.org/",
                "http://schema.org",
                "http://schema.googleapis.com/",
                "http://schema.googleapis.com"
              ]

I've seen there is a library that allows for the generation of typescript types based on a specific schema called schema-dts-gen but this library expects the path of an .nt NTriple file as argument. Maybe you guys have some good input how to generate typescript typings based out of this Google schema definition

0

There are 0 answers