Product
Introducing Ruby Support in Socket
Socket is launching Ruby support for all users. Enhance your Rails projects with AI-powered security scans for vulnerabilities and supply chain threats. Now in Beta!
[![npm version][npm-version-src]][npm-version-href] [![npm downloads][npm-downloads-src]][npm-downloads-href] [![Github Actions][github-actions-src]][github-actions-href] [![Codecov][codecov-src]][codecov-href] [![bundle][bundle-src]][bundle-href]
▶️ Check online playground
Install untyped
npm package:
yarn add untyped
# or
npm i untyped
First we have to define a reference object that describes types, defaults and normalizer
const defaultPlanet = {
name: 'earth',
specs: {
gravity: {
$resolve: val => parseFloat(val),
$default: '9.8'
},
moons: {
$resolve: (val = ['moon']) => [].concat(val),
$schema: {
title: 'planet moons'
}
}
}
}
import { resolveSchema } from 'untyped'
const schema = resolveSchema(defaultPlanet)
Output:
{
"properties": {
"name": {
"type": "string",
"default": "earth"
},
"specs": {
"properties": {
"gravity": {
"default": 9.8,
"type": "number"
},
"moons": {
"title": "planet moons",
"default": [
"moon"
],
"type": "array",
"items": [
{
"type": "string"
}
]
}
},
"type": "object"
}
},
"type": "object"
}
import { resolveSchema, generateTypes } from 'untyped'
const types = generateTypes(resolveSchema(defaultPlanet))
Output:
interface Untyped {
/** @default "earth" */
name: string,
specs: {
/** @default 9.8 */
gravity: number,
/**
* planet moons
* @default ["moon"]
*/
moons: string[],
},
}
import { resolveSchema, generateTypes, generateMarkdown } from 'untyped'
const markdown = generateMarkdown(generateTypes(resolveSchema(defaultPlanet)))
Output:
# `name`
- **Type**: `string`
- **Default**: `"earth"`
# `specs`
## `gravity`
- **Type**: `number`
- **Default**: `9.8`
## `moons`
- **Type**: `array`
- **Default**: `["moon"]`
yarn install
yarn web
to start playground websiteyarn test
before push to ensure all tests and lint checks passingThanks to @dominikschreiber for donating package name.
FAQs
<!-- automd:badges bundlejs -->
The npm package untyped receives a total of 643,670 weekly downloads. As such, untyped popularity was classified as popular.
We found that untyped demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 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.
Product
Socket is launching Ruby support for all users. Enhance your Rails projects with AI-powered security scans for vulnerabilities and supply chain threats. Now in Beta!
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.