New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

@codeperate/entity-schema-to-json-schema

Package Overview
Dependencies
Maintainers
2
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@codeperate/entity-schema-to-json-schema

Here is a basic

latest
Source
npmnpm
Version
1.0.15
Version published
Weekly downloads
13
1200%
Maintainers
2
Weekly downloads
 
Created
Source

Here is a basic

README.md

for your project:

# JSON Schema Builder

A TypeScript library for building and manipulating JSON schemas.

## Installation

To install the library, run:

```sh
npm install @codeperate/json-schema-builder
```

Usage

Here is an example of how to use the schemaBuilder:

import { schemaBuilder } from '@codeperate/json-schema-builder';

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'],
};

const updatedSchema = schemaBuilder(schema).pick(['name', 'email']).schema;
console.log(updatedSchema);

API

schemaBuilder(schema: JSONSchema)

Creates a new SchemaBuilder instance.

Methods

  • pick(props: (keyof T)[] | RegExp, options?: { removeRequired?: boolean }): SchemaBuilder<T>
  • omit(props: (keyof T)[] | RegExp, options?: { removeRequired?: boolean }): 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 }>
  • optional(props: (keyof T)[]): SchemaBuilder<T>
  • required(props: (keyof T)[]): SchemaBuilder<T>
  • clone(): SchemaBuilder<T>
  • toArray(): SchemaBuilder<Array<T>>
  • noRef(options?: { removeRequired?: boolean }): SchemaBuilder<T>

License

This project is licensed under the MIT License - see the LICENSE file for details.

FAQs

Package last updated on 28 Jan 2025

Did you know?

Socket

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.

Install

Related posts