🔠 Tool for generation samples based on OpenAPI(fka Swagger) payload/response schema
JavaScript
228
199 commits
updated Oct 8, 2026
Tool for generation samples based on OpenAPI payload/response schema
allOf, oneOf, anyOf, if/then/elseadditionalProperties with x-additionalPropertiesNameconst, examples, enum and default where possible - in this ordercontains, minItems, maxItems, and tuples (items as an array)minLength, maxLength, min, max, exclusiveMinimum, exclusiveMaximum, (limited) patternstring formats:
$ref resolvingInstall using npm
npm install openapi-sampler
or using yarn
yarn add openapi-sampler
Then require it in your code:
var OpenAPISampler = require('openapi-sampler');
OpenAPISampler.sample(schema, [options], [spec])object
An OpenAPI Schema Object or a JSON Schema Draft 7 document.object
Available options:
boolean
Don't include non-required object properties not specified in required property of the schema objectboolean
Don't include readOnly object propertiesboolean
Don't include writeOnly object propertiesboolean
Don't log console warning messages$ref. spec must not contain any external referencesconst 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' }
Overall
Maintained
Code review
Latest release
Releases this year
107 followers · starred Nov 2021
8 followers · starred Mar 2026
🔠 Tool for generation samples based on OpenAPI(fka Swagger) payload/response schema
JavaScript
228
199 commits
updated Oct 8, 2026
Tool for generation samples based on OpenAPI payload/response schema
allOf, oneOf, anyOf, if/then/elseadditionalProperties with x-additionalPropertiesNameconst, examples, enum and default where possible - in this ordercontains, minItems, maxItems, and tuples (items as an array)minLength, maxLength, min, max, exclusiveMinimum, exclusiveMaximum, (limited) patternstring formats:
$ref resolvingInstall using npm
npm install openapi-sampler
or using yarn
yarn add openapi-sampler
Then require it in your code:
var OpenAPISampler = require('openapi-sampler');
OpenAPISampler.sample(schema, [options], [spec])object
An OpenAPI Schema Object or a JSON Schema Draft 7 document.object
Available options:
boolean
Don't include non-required object properties not specified in required property of the schema objectboolean
Don't include readOnly object propertiesboolean
Don't include writeOnly object propertiesboolean
Don't log console warning messages$ref. spec must not contain any external referencesconst 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' }
Overall
Maintained
Code review
Latest release
Releases this year
107 followers · starred Nov 2021
8 followers · starred Mar 2026