Convert JSON examples into JSON schema (supports Swagger 2, OpenAPI 3 and 3.1)

Overview

json-to-json-schema

npm version bundle size dependency size Coverage Status

Convert JSON examples into JSON schema.

Supports JSON Schema draft-05 used in Swagger 2.0 and OpenAPI 3.0 and new draft draft-2020-12 used in OpenAPI 3.1.

Usage

import { convert, format } from '@redocly/json-to-json-schema';

const example = { firstname: 'John', surname: 'Doe', birthday: '1990-02-23' };

const schema = convert(example, {
  target: 'draft-05-oas', // or draft-2020-12
  includeExamples: false,
  disableAdditionalProperties: false,
  inferRequired: false,
});

Output:

firstname:
  type: string
surname:
  type: string
birthday:
  type: string
  format: date

Similar tools

https://github.com/mohsen1/json-to-json-schema

You might also like...

FieldVal - multipurpose validation library. Supports both sync and async validation.

FieldVal-JS The FieldVal-JS library allows you to easily validate data and provide readable and structured error reports. Documentation and Examples D

Sep 24, 2022

GUI for editing, visualizing, and manipulating JSON data

GUI for editing, visualizing, and manipulating JSON data

JSON-Splora JSON-Splora is a GUI for editing, visualizing, and manipulating JSON data with jq or JavaScript. Design Built with Electron Editor and out

Dec 25, 2022

This Login Form made using React hooks , React Js , Css, Json. This form have 3 inputs, it also validate those inputs & it also having length limitations.

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

Jan 3, 2022

A simple and composable way to validate data in JavaScript (and TypeScript).

A simple and composable way to validate data in JavaScript (and TypeScript).

A simple and composable way to validate data in JavaScript (and TypeScript). Usage • Why? • Principles • Demo • Examples • Documentation Superstruct m

Jan 9, 2023

Codestamp - Stamp and verify your files and contents

A language-agnostic tool for signing and verifying your (codegen'd) files and contents.

Jan 26, 2022

jQuery library to validate html forms. compatible with bootstrap v4 and bootstrap v3

jQuery library to validate html forms. compatible with bootstrap v4 and bootstrap v3

jQuery form validation jQuery form validation is a library that helps you to validate your HTML form, it's completable with both Bootstrap 3 and Boots

Jun 10, 2021

ForgJs is a javascript lightweight object validator. Go check the Quick start section and start coding with love

ForgJs is a javascript lightweight object validator. Go check the Quick start section and start coding with love

Hey every one im really happy that this repo reached this many stars 🎉 ,but this repo needs your contibution I started to better document the code th

Dec 21, 2022
Comments
  • chore: setup ci

    chore: setup ci

    What/Why/How?

    Add github actions

    Reference

    Testing

    Screenshots (optional)

    Check yourself

    • [x] Code is linted
    • [x] Tested with dependencies
    • [x] All new/updated code is covered with tests

    Security

    • [x] Security impact of change has been considered
    • [x] Code follows company security practices and guidelines
    opened by RomanHotsiy 0
  • Added a Documentation template in this project

    Added a Documentation template in this project

    There is no documentation improvement template so we can add also that one image Like This and it is useful for documentation update in the project It Looks like this image

    opened by Ayush7614 1
  • Added Issue Templates

    Added Issue Templates

    Currently the repo has no issue templates like bug, feature request and many Markdown templates often made it difficult to capture the whole context, by expecting the contributors to read the markup, uncomment lines and delete relevant context.

    Issue forms beta was released for public repositories last month, as mentioned by GitHub on this blog. We would like to migrate the issue templates to YAML-based forms which are easy to fill up and maintain, helping us capture relevant context.

    There is no issue templates in the project so i would like to work on the issue

    opened by Ayush7614 1
Owner
Redocly
At last, API docs you can be proud of
Redocly
A library that generates OpenAPI (Swagger) docs from Zod schemas

Zod to OpenAPI A library that uses zod schemas to generate an Open API Swagger documentation. Purpose and quick example Usage Installation The openapi

Astea Solutions 130 Dec 30, 2022
Command line utility to split OpenAPI documents into smaller, self contained, service oriented documents and prepare StackQL provider interfaces

openapi-doc-util Command line utility to split OpenAPI documents into smaller, self contained, service oriented documents and prepare StackQL provider

StackQL Studios 9 Sep 29, 2022
Schema-Inspector is an JSON API sanitisation and validation module.

Schema-Inspector is a powerful tool to sanitize and validate JS objects. It's designed to work both client-side and server-side and to be scalable wit

null 494 Oct 3, 2022
A JavaScript function to convert a number into words

Number to Words by Nicholas C. Zakas If you find this useful, please consider supporting my work with a donation. Description A function that accepts

Human Who Codes 29 Aug 7, 2022
Tiny Validator for JSON Schema v4

Tiny Validator (for v4 JSON Schema) Use json-schema draft v4 to validate simple values and complex objects using a rich validation vocabulary (example

Geraint 1.2k Dec 21, 2022
Validate for XML schema and returns all the possible failures

detailed-xml-validator Validate for XML schema and returns all the possible failures Sample Rules file <?xml version = "1.0"?> <students nillable="fa

Natural Intelligence 11 Dec 20, 2022
TypeScript-first schema validation for h3 and Nuxt applications

h3-zod Validate h3 and Nuxt 3 requests using zod schema's. Install npm install h3-zod Usage import { createServer } from 'http' import { createApp } f

Robert Soriano 48 Dec 28, 2022
Dead simple Object schema validation

Yup Yup is a JavaScript schema builder for value parsing and validation. Define a schema, transform a value to match, validate the shape of an existin

Jason Quense 19.2k Jan 2, 2023
Validate graphql operations against a schema

@graphql-validate With the power of GraphQL-Tools and GraphQL-JS, we are able to provide a smooth experience for validation your GraphQL operations du

Saihajpreet Singh 13 Dec 23, 2022
Schema validation utilities for h3, using typebox & ajv

h3-typebox JSON schema validation for h3, using typebox & ajv. Install # Using npm npm install h3-typebox # Using yarn yarn install h3-typebox # Usi

Kevin Marrec 43 Dec 10, 2022