diff --git a/package-lock.json b/package-lock.json index 5db69cc..c792c93 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@hckrnews/openapi-model", - "version": "0.2.3", + "version": "0.2.4", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@hckrnews/openapi-model", - "version": "0.2.3", + "version": "0.2.4", "license": "LGPL-3.0", "dependencies": { "ajv": "^8.12.0", @@ -1554,6 +1554,18 @@ "url": "https://opencollective.com/eslint" } }, + "node_modules/eslint-compat-utils": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/eslint-compat-utils/-/eslint-compat-utils-0.1.2.tgz", + "integrity": "sha512-Jia4JDldWnFNIru1Ehx1H5s9/yxiRHY/TimCuUc0jNexew3cF1gI6CYZil1ociakfWO3rRqFjl1mskBblB3RYg==", + "dev": true, + "engines": { + "node": ">=12" + }, + "peerDependencies": { + "eslint": ">=6.0.0" + } + }, "node_modules/eslint-config-airbnb-base": { "version": "15.0.0", "resolved": "https://registry.npmjs.org/eslint-config-airbnb-base/-/eslint-config-airbnb-base-15.0.0.tgz", @@ -1663,13 +1675,14 @@ } }, "node_modules/eslint-plugin-es-x": { - "version": "7.3.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-es-x/-/eslint-plugin-es-x-7.3.0.tgz", - "integrity": "sha512-W9zIs+k00I/I13+Bdkl/zG1MEO07G97XjUSQuH117w620SJ6bHtLUmoMvkGA2oYnI/gNdr+G7BONLyYnFaLLEQ==", + "version": "7.4.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-es-x/-/eslint-plugin-es-x-7.4.0.tgz", + "integrity": "sha512-WJa3RhYzBtl8I37ebY9p76s61UhZyi4KaFOnX2A5r32RPazkXj5yoT6PGnD02dhwzEUj0KwsUdqfKDd/OuvGsw==", "dev": true, "dependencies": { "@eslint-community/eslint-utils": "^4.1.2", - "@eslint-community/regexpp": "^4.6.0" + "@eslint-community/regexpp": "^4.6.0", + "eslint-compat-utils": "^0.1.2" }, "engines": { "node": "^14.18.0 || >=16.0.0" @@ -4563,9 +4576,9 @@ } }, "node_modules/v8-to-istanbul": { - "version": "9.1.3", - "resolved": "https://registry.npmjs.org/v8-to-istanbul/-/v8-to-istanbul-9.1.3.tgz", - "integrity": "sha512-9lDD+EVI2fjFsMWXc6dy5JJzBsVTcQ2fVkfBvncZ6xJWG9wtBhOldG+mHkSL0+V1K/xgZz0JDO5UT5hFwHUghg==", + "version": "9.2.0", + "resolved": "https://registry.npmjs.org/v8-to-istanbul/-/v8-to-istanbul-9.2.0.tgz", + "integrity": "sha512-/EH/sDgxU2eGxajKdwLCDmQ4FWq+kpi3uCmBGpw1xJtnAxEjlD8j8PEiGWpCIMIs3ciNAgH0d3TTJiUkYzyZjA==", "dev": true, "dependencies": { "@jridgewell/trace-mapping": "^0.3.12", diff --git a/package.json b/package.json index 8c9d123..21d6a2f 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@hckrnews/openapi-model", "description": "OpenAPI Model", - "version": "0.2.3", + "version": "0.2.4", "author": { "name": "Pieter Wigboldus", "url": "https://hckr.news/" diff --git a/src/model.js b/src/model.js index 4695506..3f128d7 100644 --- a/src/model.js +++ b/src/model.js @@ -32,11 +32,6 @@ const createBaseObjectFromSchema = (schema) => Object.fromEntries( Object.entries(schema.properties).map(createPropertyWithDefaultValue) ) -/** - * @param {BaseSchemaObject} schema - * @param {Options=} options - * @returns {any} - */ const openapiToModel = (schema, options = {}) => { const { validate = true } = options const emptyObject = createBaseObjectFromSchema(schema) diff --git a/src/schema.d.ts b/src/schema.d.ts index 0a39997..3765fd5 100644 --- a/src/schema.d.ts +++ b/src/schema.d.ts @@ -36,13 +36,17 @@ export interface Options { strict?: boolean; extraAjvFormats?: any[]; } -export class Model { - constructor(data?: object); - set data(data: object); + +export declare class Model { + constructor(data: object); + data: object; + value: object; + set data(data: object): void; get data(): object; - valueOf(): any; + valueOf(): object; } + export function openapiToModel( schema: BaseSchemaObject, options?: Options -): Model; +): typeof Model;