Skip to content

Generate types for external schema #169

Description

@hawyar

I am trying to generate types for the GS1 web vocabulary. I have included the context used

schema-dts-gen --ontology=https://schema.org/version/latest/schemaorg-all-https.nt --context=cc:http://creativecommons.org/ns#,cert:http://www.w3.org/ns/auth/cert#,dbp:http://dbpedia.org/property/,dc:http://purl.org/dc/elements/1.1/,dcterms:http://purl.org/dc/elements/1.1/,doap:http://usefulinc.com/ns/doap#,exif:http://www.w3.org/2003/12/exif/ns#,fn:http://www.w3.org/2005/xpath-functions#,foaf:http://xmlns.com/foaf/0.1/,geo:http://www.w3.org/2003/01/geo/wgs84_pos#,geonames:http://www.geonames.org/ontology#,gr:http://purl.org/goodrelations/v1#,gs1:https://gs1.org/voc/,log:http://www.w3.org/2000/10/swap/log#,owl:http://www.w3.org/2002/07/owl#,rdf:http://www.w3.org/1999/02/22-rdf-syntax-ns#,rdfs:http://www.w3.org/2000/01/rdf-schema#,rei:http://www.w3.org/2004/06/rei#,rsa:http://www.w3.org/ns/auth/rsa#,rss:http://purl.org/rss/1.0/,schema:http://schema.org/,sfn:http://www.w3.org/ns/sparql#,sioc:http://rdfs.org/sioc/ns#,skos:http://www.w3.org/2004/02/skos/core#,sw:http://www.w3.org/2003/06/sw-vocab-status/ns#,swrc:http://swrc.ontoware.org/ontology#,types:http://rdfs.org/sioc/types#,vann:http://purl.org/vocab/vann/,vcard:http://www.w3.org/2006/vcard/ns#,voaf:http://purl.org/vocommons/voaf#,wot:http://xmlns.com/wot/0.1/,xhtml:http://www.w3.org/1999/xhtml#,xsd:http://www.w3.org/2001/XMLSchema# > schema.ts

which results in the correct context

export type WithContext<T extends Thing> = T & {
    "@context": {
        "cc": "http://creativecommons.org/ns#";
        "cert": "http://www.w3.org/ns/auth/cert#";
        "dbp": "http://dbpedia.org/property/";
        "dc": "http://purl.org/dc/elements/1.1/";
        "dcterms": "http://purl.org/dc/elements/1.1/";
        "doap": "http://usefulinc.com/ns/doap#";
        "exif": "http://www.w3.org/2003/12/exif/ns#";
        "fn": "http://www.w3.org/2005/xpath-functions#";
        "foaf": "http://xmlns.com/foaf/0.1/";
        "geo": "http://www.w3.org/2003/01/geo/wgs84_pos#";
        "geonames": "http://www.geonames.org/ontology#";
        "gr": "http://purl.org/goodrelations/v1#";
        "gs1": "https://gs1.org/voc/";
        "log": "http://www.w3.org/2000/10/swap/log#";
        "owl": "http://www.w3.org/2002/07/owl#";
        "rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#";
        "rdfs": "http://www.w3.org/2000/01/rdf-schema#";
        "rei": "http://www.w3.org/2004/06/rei#";
        "rsa": "http://www.w3.org/ns/auth/rsa#";
        "rss": "http://purl.org/rss/1.0/";
        "schema": "http://schema.org/";
        "sfn": "http://www.w3.org/ns/sparql#";
        "sioc": "http://rdfs.org/sioc/ns#";
        "skos": "http://www.w3.org/2004/02/skos/core#";
        "sw": "http://www.w3.org/2003/06/sw-vocab-status/ns#";
        "swrc": "http://swrc.ontoware.org/ontology#";
        "types": "http://rdfs.org/sioc/types#";
        "vann": "http://purl.org/vocab/vann/";
        "vcard": "http://www.w3.org/2006/vcard/ns#";
        "voaf": "http://purl.org/vocommons/voaf#";
        "wot": "http://xmlns.com/wot/0.1/";
        "xhtml": "http://www.w3.org/1999/xhtml#";
        "xsd": "http://www.w3.org/2001/XMLSchema#";
    };
};

but then I am not sure how to use

const product: WithContext<Product> 

I think I am missing something here. Any feedback is appreciated

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions