All Projects → wework → Json Schema To Openapi Schema

wework / Json Schema To Openapi Schema

A little NodeJS package to convert JSON Schema to OpenAPI Schema Objects

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Json Schema To Openapi Schema

Flasgger
Easy OpenAPI specs and Swagger UI for your Flask API
Stars: ✭ 2,825 (+1581.55%)
Mutual labels:  api, openapi, api-documentation
Openapi Viewer
Browse and test a REST API described with the OpenAPI 3.0 Specification
Stars: ✭ 82 (-51.19%)
Mutual labels:  api, openapi, api-documentation
Rest Layer
REST Layer, Go (golang) REST API framework
Stars: ✭ 1,068 (+535.71%)
Mutual labels:  api, json-schema, api-documentation
Api Development Tools
📚 A collection of useful resources for building RESTful HTTP+JSON APIs.
Stars: ✭ 2,519 (+1399.4%)
Mutual labels:  api, json-schema, api-documentation
Apispec
A pluggable API specification generator. Currently supports the OpenAPI Specification (f.k.a. the Swagger specification)..
Stars: ✭ 831 (+394.64%)
Mutual labels:  api, openapi, json-schema
Fastapi
FastAPI framework, high performance, easy to learn, fast to code, ready for production
Stars: ✭ 39,588 (+23464.29%)
Mutual labels:  api, openapi, json-schema
Angular Swagger Ui
An angularJS implementation of Swagger UI
Stars: ✭ 131 (-22.02%)
Mutual labels:  api, openapi, api-documentation
Cats
Generate tests at runtime based on OpenApi specs
Stars: ✭ 86 (-48.81%)
Mutual labels:  api, openapi
Japidocs
A magical api documentation generator without annotation for springboot.
Stars: ✭ 1,289 (+667.26%)
Mutual labels:  api, api-documentation
Api2html
A CLI tool to transform Swagger/OpenAPI/AsyncAPI docs to beautiful HTML pages via Shins/Widdershins.
Stars: ✭ 103 (-38.69%)
Mutual labels:  openapi, api-documentation
L5 Swagger
OpenApi or Swagger integration to Laravel
Stars: ✭ 1,781 (+960.12%)
Mutual labels:  api, openapi
Ogcapi Features
An open standard for querying geospatial information on the web.
Stars: ✭ 164 (-2.38%)
Mutual labels:  api, openapi
Drf Autodocs
Ultimately automated DRF documentation rendering(UNMAINTAINED)
Stars: ✭ 82 (-51.19%)
Mutual labels:  api, api-documentation
Swagger Combine
Combines multiple Swagger schemas into one dereferenced schema.
Stars: ✭ 102 (-39.29%)
Mutual labels:  api, openapi
Zeal
Offline documentation browser inspired by Dash
Stars: ✭ 9,164 (+5354.76%)
Mutual labels:  api, api-documentation
Tcases
A model-based test case generator
Stars: ✭ 103 (-38.69%)
Mutual labels:  api, openapi
Wizard
Wizard是一款开源的文档管理工具,支持Markdown/Swagger/Table类型的文档。
Stars: ✭ 1,733 (+931.55%)
Mutual labels:  api, openapi
Class Validator Jsonschema
Convert class-validator-decorated classes into JSON schema
Stars: ✭ 118 (-29.76%)
Mutual labels:  json-schema, api-documentation
Documentation Starter
Interactive REST API Documentation
Stars: ✭ 156 (-7.14%)
Mutual labels:  openapi, api-documentation
Awesome Documentation Tools
🔥 📚 All the tools, processes and resources you need to create an awesome API & Project documentation
Stars: ✭ 138 (-17.86%)
Mutual labels:  api, api-documentation

JSON Schema to OpenAPI Schema

A little NodeJS package to convert JSON Schema to OpenAPI Schema Objects.

Features

  • converts JSON Schema Draft 00 Wright (a.k.a draft v5) to OpenAPI 3.0 Schema Object
  • switches type: ['foo', 'null'] to type: foo and nullable: true
  • supports deep structures with nested allOfs etc.
  • switches patternProperties to x-patternProperties
  • converts dependencies to an allOf + oneOf OpenAPI-valid equivalent

Installation

npm install --save json-schema-to-openapi-schema

Usage

Here's a small example to get the idea:

const toOpenApi = require('json-schema-to-openapi-schema');

const schema = {
  '$schema': 'http://json-schema.org/draft-04/schema#',
  type: ['string', 'null'],
  format: 'date-time',
};

const convertedSchema = toOpenApi(schema);

console.log(convertedSchema);

The example prints out

{
  type: 'string',
  format: 'date-time',
  nullable: true
}

NOTE: $refs are not dereferenced. Use a dereferencer such as json-schema-ref-parser prior to using this package.

Options

The function accepts options object as the second argument.

cloneSchema (boolean)

If set to false, converts the provided schema in place. If true, clones the schema by converting it to JSON and back. The overhead of the cloning is usually negligible. Defaults to true.

Why?

OpenAPI is often described as an extension of JSON Schema, but both specs have changed over time and grown independently. OpenAPI v2 was based on JSON Schema draft v4 with a long list of deviations, but OpenAPI v3 shrank that list, upping their support to draft v4 and making the list of discrepancies shorter. Despite OpenAPI v3 closing the gap, the issue of JSON Schema divergence has not been resolved fully.

Diagram showing data model (the objects, payload bodies, etc) and service model (endpoints, headers, metadata, etc)

Carefully writing JSON Schema for your data model kiiiinda works, but it is possible to write JSON Schema that creates invalid OpenAPI, and vice versa. For more on this, read the article OpenAPI and JSON Schema Divergence.

This tool sets out to allow folks to convert from JSON Schema (their one source of truth for everything) to OpenAPI (a thing for HTML docs and making SDKs).

Versions

† Draft v5 is also known as Draft Wright 00, as the drafts are often named after the author, and this was the first one by A. Wright. Amongst other things, draft v5 aimed to rewrite the meta files, but the experiment failed, meaning we need to continue to use the draft v4 metafiles. Ugh.

TODO

Converting Back

To convert the other way, check out openapi-schema-to-json-schema, which this package was based on.

Tests

To run the test-suite:

npm test

Credits

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].