openapi-sampler

WebJar for openapi-sampler

License

License

MIT
GroupId

GroupId

org.webjars.bower
ArtifactId

ArtifactId

openapi-sampler
Last Version

Last Version

1.0.0-beta.15
Release Date

Release Date

Type

Type

jar
Description

Description

openapi-sampler
WebJar for openapi-sampler
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/Redocly/openapi-sampler

Download openapi-sampler

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.bower/openapi-sampler/ -->
<dependency>
    <groupId>org.webjars.bower</groupId>
    <artifactId>openapi-sampler</artifactId>
    <version>1.0.0-beta.15</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.bower/openapi-sampler/
implementation 'org.webjars.bower:openapi-sampler:1.0.0-beta.15'
// https://jarcasting.com/artifacts/org.webjars.bower/openapi-sampler/
implementation ("org.webjars.bower:openapi-sampler:1.0.0-beta.15")
'org.webjars.bower:openapi-sampler:jar:1.0.0-beta.15'
<dependency org="org.webjars.bower" name="openapi-sampler" rev="1.0.0-beta.15">
  <artifact name="openapi-sampler" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.bower', module='openapi-sampler', version='1.0.0-beta.15')
)
libraryDependencies += "org.webjars.bower" % "openapi-sampler" % "1.0.0-beta.15"
[org.webjars.bower/openapi-sampler "1.0.0-beta.15"]

Dependencies

compile (1)

Group / Artifact Type Version
org.webjars.bower » json-pointer jar [0.6.0,0.7)

Project Modules

There are no modules declared in this project.

openapi-sampler

Travis build status Coverage Status Dependency Status devDependency Status

Tool for generation samples based on OpenAPI payload/response schema

Features

  • deterministic (given a particular input, will always produce the same output)
  • Supports allOf
  • Supports additionalProperties
  • Uses default, const, enum and examples where possible
  • Full array support: supports minItems, and tuples (items as an array)
  • Supports minLength, maxLength, min, max, exclusiveMinimum, exclusiveMaximum
  • Supports the next string formats:
    • email
    • password
    • date-time
    • date
    • ipv4
    • ipv6
    • hostname
    • uri
    • uuid
  • Infers schema type automatically following same rules as json-schema-faker
  • Support for $ref resolving

Installation

Install using npm

npm install openapi-sampler --save

or using yarn

yarn add openapi-sampler

Then require it in your code:

var OpenAPISampler = require('openapi-sampler');

Usage

OpenAPISampler.sample(schema, [options], [spec])

  • schema (required) - object A OpenAPI Schema Object
  • options (optional) - object Available options:
    • skipNonRequired - boolean Don't include non-required object properties not specified in required property of the schema object
    • skipReadOnly - boolean Don't include readOnly object properties
    • skipWriteOnly - boolean Don't include writeOnly object properties
    • quiet - boolean Don't log console warning messages
  • 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' }
org.webjars.bower

Redocly

At last, API docs you can be proud of

Versions

Version
1.0.0-beta.15