1.6.1 • Published 1 year ago
openapi-sampler v1.6.1
openapi-sampler
Tool for generation samples based on OpenAPI payload/response schema
Features
- Deterministic (given a particular input, will always produce the same output)
- Supports compound keywords:
allOf,oneOf,anyOf,if/then/else - Supports
additionalPropertieswithx-additionalPropertiesName - Uses
const,examples,enumanddefaultwhere possible - in this order - Good array support: supports
contains,minItems,maxItems, and tuples (itemsas an array) - Supports
minLength,maxLength,min,max,exclusiveMinimum,exclusiveMaximum, (limited)pattern - Supports the following
stringformats:- idn-email
- password
- date-time
- date
- time
- ipv4
- ipv6
- hostname
- idn-hostname
- uri
- uri-reference
- uri-template
- iri
- iri-reference
- uuid
- json-pointer
- relative-json-pointer
- regex
- Infers schema type automatically following same rules as json-schema-faker
- Support for
$refresolving - Has basic supports for JSON Schema draft 7 (thanks to @P0lip from @stoplightio for contributing)
Installation
Install using npm
npm install openapi-sampleror using yarn
yarn add openapi-samplerThen require it in your code:
var OpenAPISampler = require('openapi-sampler');Usage
OpenAPISampler.sample(schema, [options], [spec])
- schema (required) -
objectAn OpenAPI Schema Object or a JSON Schema Draft 7 document. - options (optional) -
objectAvailable options:- skipNonRequired -
booleanDon't include non-required object properties not specified inrequiredproperty of the schema object - skipReadOnly -
booleanDon't includereadOnlyobject properties - skipWriteOnly -
booleanDon't includewriteOnlyobject properties - quiet -
booleanDon't log console warning messages
- skipNonRequired -
- spec - whole specification where the schema is taken from. Required only when schema may contain
$ref. spec must not contain any external references
Example
const OpenAPISampler = require('.');
OpenAPISampler.sample({
type: 'object',
properties: {
a: {type: 'integer', minimum: 10},
b: {type: 'string', format: 'password', minLength: 10},
c: {type: 'boolean', readOnly: true}
}
}, {skipReadOnly: true});
// { a: 10, b: 'pa$$word_q' }1.6.1
1 year ago
1.6.0
1 year ago
1.5.1
2 years ago
1.5.0
2 years ago
1.4.0
2 years ago
1.3.1
3 years ago
1.3.0
4 years ago
1.2.3
4 years ago
1.2.2
4 years ago
1.2.0
4 years ago
1.2.1
4 years ago
1.1.1
4 years ago
1.1.0
5 years ago
1.0.1
5 years ago
1.0.0
5 years ago
1.0.0-beta.18
5 years ago
1.0.0-beta.17
5 years ago
1.0.0-beta.16
6 years ago
1.0.0-beta.15
7 years ago
1.0.0-beta.14
8 years ago
1.0.0-beta.13
8 years ago
1.0.0-beta.12
8 years ago
1.0.0-beta.11
8 years ago
1.0.0-beta.10
8 years ago
1.0.0-beta.9
8 years ago
1.0.0-beta.8
8 years ago
1.0.0-beta.7
8 years ago
1.0.0-beta.6
8 years ago
1.0.0-beta.5
8 years ago
1.0.0-beta.4
8 years ago
1.0.0-beta.3
8 years ago
1.0.0-beta.2
8 years ago
1.0.0-beta.1
8 years ago
1.0.0-beta.0
8 years ago
0.4.3
9 years ago
0.4.2
9 years ago
0.4.1
9 years ago
0.4.0
9 years ago
0.3.3
9 years ago
0.3.2
9 years ago
0.3.1
9 years ago
0.3.0
10 years ago
0.2.0
10 years ago
0.1.2
10 years ago
0.1.1
10 years ago
0.1.0
10 years ago
0.0.3
10 years ago
0.0.2
10 years ago
0.0.1
10 years ago