
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
@codeperate/json-schema-builder
Advanced tools
A powerful TypeScript library for building, manipulating, and transforming JSON schemas with a fluent API.
A powerful TypeScript library for building, manipulating, and transforming JSON schemas with a fluent API.
npm install @codeperate/json-schema-builder
import { schemaBuilder } from '@codeperate/json-schema-builder';
// Create a schema
const schema = {
type: 'object',
properties: {
name: { type: 'string' },
age: { type: 'integer' },
email: { type: 'string' },
address: {
type: 'object',
properties: {
street: { type: 'string' },
city: { type: 'string' },
},
required: ['street', 'city'],
},
},
required: ['name', 'age', 'email', 'address'],
};
// Use the builder to transform the schema
const updatedSchema = schemaBuilder(schema).pick(['name', 'email']).schema;
console.log(updatedSchema);
schemaBuilder(schema: JSONSchema)Creates a new SchemaBuilder instance.
pick(props: (keyof T)[] | RegExp, options?: { removeRequired?: boolean }): SchemaBuilder<T>
omit(props: (keyof T)[] | RegExp, options?: { removeRequired?: boolean }): SchemaBuilder<T>
optional(props: (keyof T)[]): SchemaBuilder<T>
required(props: (keyof T)[]): SchemaBuilder<T>
set<K extends keyof JSONSchema>(key: K, value: JSONSchema[K] | ((curVal: JSONSchema[K]) => JSONSchema[K])): SchemaBuilder<T>
setProps<K extends keyof T, V extends JSONSchema>(key: K, value: V | ((curVal: JSONSchema) => V)): SchemaBuilder<Omit<T, K> & { [key in K]: FromSchema<V> }>
setPropsRaw<K extends keyof T, V = any>(key: K, value: JSONSchema | ((curVal: JSONSchema) => JSONSchema)): SchemaBuilder<Omit<T, K> & { [key in K]: V }>
clone(): SchemaBuilder<T>
toArray(): SchemaBuilder<Array<T>>
noRef(options?: { removeRequired?: boolean }): SchemaBuilder<T>
const schema = schemaBuilder(originalSchema).pick(['name', 'email']).schema;
const schema = schemaBuilder(originalSchema).optional(['age', 'address']).schema;
const arraySchema = schemaBuilder(originalSchema).toArray().schema;
const cleanSchema = schemaBuilder(originalSchema).noRef().schema;
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
FAQs
A powerful TypeScript library for building, manipulating, and transforming JSON schemas with a fluent API.
We found that @codeperate/json-schema-builder demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.