🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more →

next-rest-framework

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

next-rest-framework - npm Package Compare versions

Comparing version

to
0.7.1

@@ -31,2 +31,11 @@ "use strict";

};
const isZodEnum = (schema) => {
return schema._def.typeName === 'ZodEnum';
};
const isZodNullable = (schema) => {
return schema._def.typeName === 'ZodNullable';
};
const isZodIntersection = (schema) => {
return schema._def.typeName === 'ZodIntersection';
};
const convertZodSchema = (schema) => {

@@ -64,2 +73,23 @@ let jsonSchema = {};

}
if (isZodEnum(value)) {
jsonSchema[key] = {
type: 'array',
items: {
type: 'string',
enum: value._def.values
}
};
}
if (isZodIntersection(value)) {
jsonSchema[key] = {
type: 'array',
items: {
...(0, exports.convertZodSchema)(value._def.left),
...(0, exports.convertZodSchema)(value._def.right)
}
};
}
if (isZodNullable(value)) {
jsonSchema[key] = (0, exports.convertZodSchema)(value._def.innerType);
}
});

@@ -95,2 +125,20 @@ return jsonSchema;

}
if (isZodEnum(schema)) {
jsonSchema = {
type: 'string',
enum: convertZodShape(schema._def.values)
};
}
if (isZodIntersection(schema)) {
jsonSchema = {
type: 'array',
items: {
...(0, exports.convertZodSchema)(schema._def.left),
...(0, exports.convertZodSchema)(schema._def.right)
}
};
}
if (isZodNullable(schema)) {
jsonSchema = (0, exports.convertZodSchema)(schema._def.innerType);
}
return jsonSchema;

@@ -97,0 +145,0 @@ };

{
"name": "next-rest-framework",
"version": "0.7.0",
"version": "0.7.1",
"description": "Next REST Framework - write type-safe, self-documenting REST APIs in Next.js",

@@ -5,0 +5,0 @@ "keywords": [

@@ -125,5 +125,5 @@ <p align="center">

- `/api/openapi.yaml`: An auto-generated openapi.yaml document.
- A local `openapi.json` file that will be generated as you call any of the above endpoints. This file should be under version control and you should always keep it in the project root. It will dynamically update itself as you develop your application locally and is used by Next REST Framework when you run your application in production. Remember that it will be dynamically regenerated every time you call any of the above endpoints in development mode.
- A local `openapi.json` file that will be generated as you run `npx next-rest-framework generate` or call any of the above endpoints in development mode. This file should be under version control and you should always keep it in the project root. It will dynamically update itself as you develop your application locally and is used by Next REST Framework when you run your application in production. Remember that it will be dynamically regenerated every time you call any of the above endpoints in development mode. A good practice is also to generate this file before you run `next build` when going to production, so your build script would look something like: `npx next-rest-framework generate && next build`.
All of these are configurable with the [Config options](#config-options) that you can pass for your `NextRestFramework` client. You can also use your existing catch-all logic simply by passing a [Route config](#route-config) to your `defineCatchAllHandler` if you want to use e.g. custom 404 handlers, redirections etc.
The reserved OpenAPI paths are configurable with the [Config options](#config-options) that you can pass for your `NextRestFramework` client. You can also use your existing catch-all logic simply by passing a [Route config](#route-config) to your `defineCatchAllHandler` if you want to use e.g. custom 404 handlers, redirections etc.

@@ -130,0 +130,0 @@ ### [Add an API Route](#add-an-api-route)

Sorry, the diff of this file is not supported yet