New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

openapi-typescript-validator

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

openapi-typescript-validator - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

2

dist/templates.d.ts

@@ -1,3 +0,3 @@

export declare const decodersTemplate = "\n/* eslint-disable */\n/* tslint-disable */\nimport Ajv, { ErrorObject } from 'ajv';\nimport schema from './$SchemaName-schema.json';\nimport * as types from './$SchemaName-models'\n\n// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n// !!! AUTO GENERATED CODE, DON'T TOUCH !!!\n// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n\nconst ajv = new Ajv({ strict: false });\najv.addSchema(schema);\n\nfunction validateJson(json: any, schemaRef: string, definitionName: string): any {\n const schema = ajv.getSchema(schemaRef);\n if (!schema) {\n throw new Error(`Schema ${schemaRef} not found`);\n }\n\n const jsonObject = typeof json === 'string' ? JSON.parse(json) : json;\n\n if (schema(jsonObject)) {\n return jsonObject;\n }\n\n const jsonPreviewStr = (typeof json === 'string' ? json : JSON.stringify(jsonObject)).substring(0, 200);\n if (schema.errors) {\n throw Error(`${definitionName} ${errorsText(schema.errors)}. JSON-preview: ${jsonPreviewStr}`);\n }\n\n throw Error(`${definitionName} Unexpected data received. JSON: ${jsonPreviewStr}`);\n}\n\nfunction errorsText(errors: ErrorObject[]): string {\n return errors.map(error => `${error.dataPath}: ${error.message}`).join('\\n')\n}\n\n// Decoders\n$Decoders\n";
export declare const decodersTemplate = "\n/* eslint-disable */\n/* tslint-disable */\nimport Ajv, { ErrorObject } from 'ajv';\nimport schema from './$SchemaName-schema.json';\nimport * as types from './$SchemaName-models'\n\n// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n// !!! AUTO GENERATED CODE, DON'T TOUCH !!!\n// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n\nconst ajv = new Ajv({ strict: false });\najv.addSchema(schema);\n\nfunction validateJson(json: any, schemaRef: string, definitionName: string): any {\n const schema = ajv.getSchema(schemaRef);\n if (!schema) {\n throw new Error(`Schema ${schemaRef} not found`);\n }\n\n const jsonObject = typeof json === 'string' ? JSON.parse(json) : json;\n\n if (schema(jsonObject)) {\n return jsonObject;\n }\n\n const jsonPreviewStr = (typeof json === 'string' ? json : JSON.stringify(jsonObject)).substring(0, 200);\n if (schema.errors) {\n throw Error(`${definitionName} ${errorsText(schema.errors)}. JSON-preview: ${jsonPreviewStr}`);\n }\n\n throw Error(`${definitionName} Unexpected data received. JSON: ${jsonPreviewStr}`);\n}\n\nfunction errorsText(errors: ErrorObject[]): string {\n return errors.map(error => `${error.instancePath}: ${error.message}`).join('\\n')\n}\n\n// Decoders\n$Decoders\n";
export declare const decoderTemplate = "\nexport class $DecoderName {\n public static definitionName: string = '$Class';\n public static schemaRef: string = '#/definitions/$Class';\n\n public static decode(json: any): types.$Class {\n return validateJson(json, $DecoderName.schemaRef, $DecoderName.definitionName);\n }\n}\n";
export declare const modelsTemplate = "\n/* eslint-disable */\n\n$Models\n";
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.modelsTemplate = exports.decoderTemplate = exports.decodersTemplate = void 0;
exports.decodersTemplate = "\n/* eslint-disable */\n/* tslint-disable */\nimport Ajv, { ErrorObject } from 'ajv';\nimport schema from './$SchemaName-schema.json';\nimport * as types from './$SchemaName-models'\n\n// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n// !!! AUTO GENERATED CODE, DON'T TOUCH !!!\n// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n\nconst ajv = new Ajv({ strict: false });\najv.addSchema(schema);\n\nfunction validateJson(json: any, schemaRef: string, definitionName: string): any {\n const schema = ajv.getSchema(schemaRef);\n if (!schema) {\n throw new Error(`Schema ${schemaRef} not found`);\n }\n\n const jsonObject = typeof json === 'string' ? JSON.parse(json) : json;\n\n if (schema(jsonObject)) {\n return jsonObject;\n }\n\n const jsonPreviewStr = (typeof json === 'string' ? json : JSON.stringify(jsonObject)).substring(0, 200);\n if (schema.errors) {\n throw Error(`${definitionName} ${errorsText(schema.errors)}. JSON-preview: ${jsonPreviewStr}`);\n }\n\n throw Error(`${definitionName} Unexpected data received. JSON: ${jsonPreviewStr}`);\n}\n\nfunction errorsText(errors: ErrorObject[]): string {\n return errors.map(error => `${error.dataPath}: ${error.message}`).join('\\n')\n}\n\n// Decoders\n$Decoders\n";
exports.decodersTemplate = "\n/* eslint-disable */\n/* tslint-disable */\nimport Ajv, { ErrorObject } from 'ajv';\nimport schema from './$SchemaName-schema.json';\nimport * as types from './$SchemaName-models'\n\n// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n// !!! AUTO GENERATED CODE, DON'T TOUCH !!!\n// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n\nconst ajv = new Ajv({ strict: false });\najv.addSchema(schema);\n\nfunction validateJson(json: any, schemaRef: string, definitionName: string): any {\n const schema = ajv.getSchema(schemaRef);\n if (!schema) {\n throw new Error(`Schema ${schemaRef} not found`);\n }\n\n const jsonObject = typeof json === 'string' ? JSON.parse(json) : json;\n\n if (schema(jsonObject)) {\n return jsonObject;\n }\n\n const jsonPreviewStr = (typeof json === 'string' ? json : JSON.stringify(jsonObject)).substring(0, 200);\n if (schema.errors) {\n throw Error(`${definitionName} ${errorsText(schema.errors)}. JSON-preview: ${jsonPreviewStr}`);\n }\n\n throw Error(`${definitionName} Unexpected data received. JSON: ${jsonPreviewStr}`);\n}\n\nfunction errorsText(errors: ErrorObject[]): string {\n return errors.map(error => `${error.instancePath}: ${error.message}`).join('\\n')\n}\n\n// Decoders\n$Decoders\n";
exports.decoderTemplate = "\nexport class $DecoderName {\n public static definitionName: string = '$Class';\n public static schemaRef: string = '#/definitions/$Class';\n\n public static decode(json: any): types.$Class {\n return validateJson(json, $DecoderName.schemaRef, $DecoderName.definitionName);\n }\n}\n";
exports.modelsTemplate = "\n/* eslint-disable */\n\n$Models\n";
//# sourceMappingURL=templates.js.map
{
"name": "openapi-typescript-validator",
"version": "1.1.0",
"version": "1.2.0",
"description": "Generate typescript with ajv validation based on openapi schemas",

@@ -13,3 +13,3 @@ "main": "dist/index.js",

"build:watch": "tsc --build --watch",
"prepublish": "rm -rf dist && npm run build",
"prepublishOnly": "rm -rf dist && npm run build",
"postpublish": "git push && git push --tags"

@@ -16,0 +16,0 @@ },

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc