Skip to content

Commit

Permalink
Generate JSON Schema definitions from types
Browse files Browse the repository at this point in the history
  • Loading branch information
ddbeck committed Feb 17, 2023
1 parent 476e18c commit dba5eba
Show file tree
Hide file tree
Showing 6 changed files with 379 additions and 82 deletions.
29 changes: 24 additions & 5 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,38 @@ import path from 'path';
import { fdir } from 'fdir';
import YAML from 'yaml';

interface FeatureData {
spec: string,
caniuse?: string,
status?: SupportStatus
/** Web platform feature */
export interface FeatureData {
/** Specification URL
* @format uri
*/
spec: string;
/** caniuse.com identifier */
caniuse?: string;
/** Whether a feature is considered a "baseline" web platform feature and when it achieved that status */
status?: SupportStatus;
/** Sources of support data for this feature */
compat_features?: string[];
/** Usage stats */
usage_stats?: usage_stats_url | [usage_stats_url, usage_stats_url, ...usage_stats_url[]]; // A single URL or an array of two or more
}

type browserIdentifier = "chrome" | "firefox" | "safari";

interface SupportStatus {
is_baseline: boolean, since?: string, support?: {[K in browserIdentifier]?: string}
/** Whether the feature achieved baseline status */
is_baseline: boolean;
/** Date the feature achieved baseline status */
since?: string;
/** Browser versions that most-recently introduced the feature */
support?: {[K in browserIdentifier]?: string};
}

/** Usage stats URL
* @format uri
*/
type usage_stats_url = string;

// Some FeatureData keys aren't (and may never) be ready for publishing.
// They're not part of the public schema (yet).
// They'll be removed.
Expand Down
Loading

0 comments on commit dba5eba

Please sign in to comment.