Registry / devops / core-types-json-schema

core-types-json-schema

JSON →
library2.2.0jsnpmunverified

Conversion functions between core-types and JSON Schema/OpenAPI. Current version 2.2.0. Part of the typeconv ecosystem, this library is typically used indirectly via typeconv, which provides CLI and programmatic conversion between TypeScript, JSON Schema, GraphQL, and OpenAPI. It offers four main functions: convertCoreTypesToJsonSchema, convertJsonSchemaToCoreTypes, convertCoreTypesToOpenApi, and convertOpenApiTpCoreTypes (note the typo in the function name). All return wrapped ConversionResult values. Requires Node >=14.13.1 or >=16.0.0. Ships TypeScript types. Not intended for direct use; prefer typeconv for end-user conversion tasks.

npm install core-types-json-schema
INSTALL
IMPORT
SIG · CORE-TYPES-JSON-SC
C
core-types-json-schema
devopsjavascriptv2.2.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

convertCoreTypesToJsonSchema
import { convertCoreTypesToJsonSchema } from 'core-types-json-schema'
const convertCoreTypesToJsonSchema = require('core-types-json-schema').convertCoreTypesToJsonSchema
ESM-only since Node >=14.13.1. CommonJS require still works via import syntax in TypeScript if esModuleInterop is enabled, but direct require may fail.
convertJsonSchemaToCoreTypes
import { convertJsonSchemaToCoreTypes } from 'core-types-json-schema'
import { convertJsonSchemaToCoreTypes } from 'core-types-json-schema'
Named export, no default export. Use exact name.
convertCoreTypesToOpenApi
import { convertCoreTypesToOpenApi } from 'core-types-json-schema'
import { convertCoreTypesToOpenAPI } from 'core-types-json-schema'
Note capitalization: 'OpenApi' not 'OpenAPI'. The function name uses camelCase.
convertOpenApiTpCoreTypes
import { convertOpenApiTpCoreTypes } from 'core-types-json-schema'
import { convertOpenApiToCoreTypes } from 'core-types-json-schema'
Function name has a typo: 'Tp' instead of 'To'. Keep as is.

Demonstrates converting a core-types document to JSON Schema using the primary export function.

import { convertCoreTypesToJsonSchema } from 'core-types-json-schema'; // Example core-types document const doc = { version: 1, types: [ { name: 'Person', fields: [ { name: 'name', type: 'string' }, { name: 'age', type: 'number', optional: true }, ], }, ], }; const { data: jsonSchema } = convertCoreTypesToJsonSchema(doc); console.log(JSON.stringify(jsonSchema, null, 2)); // Output: // { // "$schema": "http://json-schema.org/draft-07/schema#", // "type": "object", // "properties": { // "name": { "type": "string" }, // "age": { "type": "number" } // }, // "required": ["name"] // }
Debug
Known issues
gotchaFunction name typo: convertOpenApiTpCoreTypes should be spelled 'To' not 'Tp'.
fix
Use the exact function name as exported: convertOpenApiTpCoreTypes (with 'Tp').
affects: >=1.0.0
gotchaRequires peer dependency 'core-types'. Missing dependency may cause runtime errors.
fix
Install core-types: npm install core-types
affects: >=1.0.0
deprecatedOpenAPI conversion functions may change in future versions; prefer using typeconv package directly.
fix
Use typeconv CLI or programmatic API instead for end-user conversion.
affects: >=1.0.0
breakingVersion 2.x may have changes in return type shape compared to 1.x. ConversionResult structure is defined in core-types package.
fix
Check core-types documentation for ConversionResult type. Ensure you handle the wrapped result.
affects: >=2.0.0
Errors
Common errors & fixes
TypeError: core_types__WEBPACK_IMPORTED_MODULE_0__ is not a function
Trying to use default import instead of named import.
fix
Use named import: import { convertCoreTypesToJsonSchema } from 'core-types-json-schema'
Cannot find module 'core-types-json-schema'
Package not installed or not in node_modules.
fix
Run: npm install core-types-json-schema core-types
TypeError: convertOpenApiToCoreTypes is not a function
Using wrong function name (correct name has typo: 'Tp').
fix
Use: import { convertOpenApiTpCoreTypes } from 'core-types-json-schema'
Upgrade
Version history
2.2.0latest on npm
Audit
Dependencies
core-typesrequiredcore-types-json-schema operates on core-types documents, which are defined in the core-types package.
openapi-json-schemarequiredUsed for OpenAPI-specific conversion functions (jsonSchemaTypeToOpenApi, openApiToJsonSchemaType).
Agent activity
10 hits · last 30 days
node
10
Resources
core-types-json-schema — npm install core-types-json-schema · libregistry