# schema-construct

> takes in jsonschema and returns a constructor for that model

Latest version **0.1.0** (published 2016-09-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install schema-construct
pnpm add schema-construct
yarn add schema-construct
bun add schema-construct
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2016-09-19 |
| First published | 2016-09-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | chemdrew |
| Maintainers | chemdrew |
| Keywords | jsonschema, swagger, spec, model, object, instantiate, constructor |

## Links

- npm: https://www.npmjs.com/package/schema-construct
- Repository: https://github.com/chemdrew/schema-construct
- Homepage: https://github.com/chemdrew/schema-construct#readme
- Issues: https://github.com/chemdrew/schema-construct/issues
- npm.io page: https://npm.io/package/schema-construct

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 0.1.0 (latest) — 2016-09-19

## README

here is how you use it

works great for swagger - kinda the point of it

###model class
```javascript
var schemaConstruct = require('schema-construct');

var error = schemaConstruct({
  type: 'object',
  properties: {
    code: {
      type: 'string'
    },
    message: {
      type: 'string'
    },
    stack: {
      type: 'string'
    }
  },
  additionalProperties: false
});

error.prototype.toXml = function() {
  // whatever you wanna do to make this happen
}

module.exports = error;
```

###something that uses that model
```javascript
var Error = require('./models/error');
var error = new Error();

console.log(error);
/*
{
  code: null,
  message: null,
  stack: null
}
*/

console.log(error.schema);
/*
{
  type: 'object',
  properties: {
    code: {
      type: 'string'
    },
    message: {
      type: 'string'
    },
    stack: {
      type: 'string'
    }
  },
  additionalProperties: false
}
*/

console.log(error.toXml());
/*
  hopefully whatever you did to make this xml worked lol
*/
```

---
_Source: https://npm.io/package/schema-construct · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
