A Zod Schema for OpenAPI Schemas v3.X.X
npm install @buildwithlayer/openapi-zod-spec

> This is a simple Zod Schema for Open API specs version 3.X.X.
This project requires NodeJS (version 18 or later) and NPM.
Node and NPM are really easy to install.
To make sure you have them available on your machine,
try running the following command.
``sh`
$ npm -v && node -v
10.2.4
v20.11.0
- OpenAPI Zod Spec
- Prerequisites
- Table of contents
- Installation
- Usage
- Loading an OpenAPI Spec
- Upgrading an OpenAPI Spec
- Contributing
- Versioning
- License
BEFORE YOU INSTALL: please read the prerequisites
To install and set up the library, run:
`sh`
$ npm install @buildwithlayer/openapi-zod-spec
Or if you prefer using Yarn:
`sh`
$ yarn add @buildwithlayer/openapi-zod-spec
From JSON:
`ts
import {OpenAPISpec} from '@buildwithlayer/openapi-zod-spec/index.js';
import {rawSpec} from './openapi.json';
const spec = OpenAPISpec.parse(rawSpec);
`
From YAML:
`ts
import {OpenAPISpec} from '@buildwithlayer/openapi-zod-spec/index.js';
import fs from 'fs';
import yaml from 'js-yaml';
const pathToYamlFile = './path/to/openapi.yml';
const fileContents = fs.readFileSync(pathToYamlFile, 'utf-8');
const rawSpec = yaml.load(fileContents);
const spec = OpenAPISpec.parse(rawSpec);
`
`ts
import {OpenAPISpec, upgrade} from '@buildwithlayer/openapi-zod-spec/index.js';
import {oldSpec} from './openapi.json';
const upgradedSpec = upgrade(OpenAPISpec.parse(oldSpec));
`
> These instructions will be updated soon.
Please read CONTRIBUTING.md for details on our code of conduct and the process for submitting pull requests to us.
1. Fork it!
2. Create your feature branch: git checkout -b my-new-featuregit add .
3. Add your changes: git commit -am 'Add some feature'
4. Commit your changes: git push origin my-new-feature`
5. Push to the branch:
6. Submit a pull request :sunglasses:
We use SemVer for versioning. For the versions available, see the tags on this repository.
MIT License © Andrea SonnY