UNPKG

@stencila/schema

Version:

Extensions to schema.org to support semantic, composable, parameterize-able and executable documents

60 lines (59 loc) 1.9 kB
/** * A module providing helper functions that are useful when * generating languages bindings and documentation. */ import { JsonSchema } from '../JsonSchema'; /** * Read the schemas from `public/*.schema.json` and dereference * any inline references. */ export declare function readSchemas(glob?: string | string[]): Promise<JsonSchema[]>; /** * Get the 'primitive' schemas */ export declare function filterPrimitiveSchemas(schemas: JsonSchema[]): JsonSchema[]; /** * Get the 'interface' schemas (i.e. not union schema, not property schemas) which are * usually translated into `interface`s, `class`es or similar for the language. * * Types are sorted topologically so that schemas come before * any of their descendants. */ export declare function filterInterfaceSchemas(schemas: JsonSchema[]): JsonSchema[]; /** * Get the union types from the schemas */ export declare function filterUnionSchemas(schemas: JsonSchema[]): JsonSchema[]; /** * Get enumeration schemas */ export declare function filterEnumSchemas(schemas: JsonSchema[]): JsonSchema[]; /** * Interface for properties giving a little * more information on each property to be used in code generation */ interface Property { name: string; schema: JsonSchema; inherited: boolean; override: boolean; optional: boolean; } /** * Get properties for a schema. * * Properties are arranged in groups according to required (or not) * and inherited (or not). */ export declare function getSchemaProperties(schema: JsonSchema): { all: Property[]; inherited: Property[]; own: Property[]; required: Property[]; optional: Property[]; }; /** * Create a header for a language bindings file */ export declare function autogeneratedHeader(generateCommand: string, generator: string, commentDelimiter: string): string; export {};