TypeScript help library to help building OpenAPI 3.1.x compliant API contracts.
For OpenAPI 3.0.x contracts see instead: openapi3-ts.
This library provides an internal DSL and Typescript interfaces to help to build and produce OpenAPI Specfications and to format them as JSON and YAML.
See the test in the *.spec.ts
files to see how to use it.
For working with OpenAPI v. 3.1.0 use this library, for OpenAPI 3.0.0 use this other twin one: openapi3-ts.
Main differences in implementation are:
- Semantic version is dropped.
- Different JSON Schema rules applies (this library is not providing support for JSON Schema validation).
- OpenAPI 3.0.0 uses JSON Schema Specification Wright Draft 00
- OpenAPI 3.1.0 uses JSON Schema Specification Draft 2020-12
- Derived from the JSON Schema version change:
exclusiveMaximum
was aboolean
on OpenAPI 3.0, now is a number in OpenAPI 3.1.exclusiveMinimum
was aboolean
on OpenAPI 3.0, now is a number in OpenAPI 3.1.
- Added support for Webhooks on OpenAPI 3.1.0
- Single
example
is deprecated in favour ofexamples
. - Type can now be an array.
- Type can be null with:
nullable: true
. - Paths are optional.
Read for a more detailed comparison.
/src/model
TS typed interfaces for helping building a contract./src/dsl
Fluent DSL for building a contract.
Install package via npm:
npm i --save openapi31-ts
See changelog.
- OpenAPI spec 3.1.0. https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md
Licensed under the MIT License.
Contact: Pedro J. Molina | github: pjmolina | twitter: pmolinam
(c) 2017-2023. Pedro J. Molina at Metadev S.L. https://metadev.pro & contributors.