UNPKG

json-schema-spell-checker

Version:

Check the spelling of your JSON Schema (including OpenAPI!) documents

25 lines (21 loc) 466 B
import { JSONPath } from "jsonpath-plus"; /** * Extracts all titles and descriptions from a specification */ const extract = (document, fields = []) => { let path; if (typeof fields == "string") { path = fields; } else { path = `$..[${fields.join(",")}]`; } return JSONPath({ path, json: document, resultType: "all" }).map( ({ path, value }) => { return { path, value, }; }, ); }; export default extract;