https://github.com/52cik/mock2schema
mock-json to json-schema
https://github.com/52cik/mock2schema
Last synced: 2 months ago
JSON representation
mock-json to json-schema
- Host: GitHub
- URL: https://github.com/52cik/mock2schema
- Owner: 52cik
- License: mit
- Created: 2018-01-18T09:16:59.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-01-19T12:23:28.000Z (over 7 years ago)
- Last Synced: 2025-03-02T08:17:09.070Z (3 months ago)
- Language: JavaScript
- Size: 6.84 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# mock2schema
> mock-json to json-schema
[中文文档](README.zh-CN.md)
## Requirements
> node6 or higher
## How to use it
### Install
```sh
$ yarn add mock2schema
# or
$ npm i -S mock2schema
```### Usage
```js
const mock2schema = require('mock2schema');const schema = mock2schema({
"code": 0,
"message": "ok"
});console.log(schema);
```The return data is as follows:
```json
{
"title": "接口描述",
"type": "object",
"properties": {
"code": {
"type": "number",
"description": "字段 {code} 描述"
},
"message": {
"type": "string",
"description": "字段 {message} 描述"
}
},
"required": [
"code",
"message"
]
}
```## API
### mock2schema(data)
#### data
Type: `Object`