Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add quiet option to inhibit console warnings #9

Merged
merged 1 commit into from
Jun 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Install using [npm](https://docs.npmjs.com/getting-started/what-is-npm)
or using [yarn](https://yarnpkg.com)

yarn add openapi-sampler

Then require it in your code:

```js
Expand All @@ -51,6 +51,8 @@ Available options:
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
Expand Down
2 changes: 1 addition & 1 deletion src/allOf.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export function allOfSample(into, children, options, spec) {
} else {
if (res.type === 'array') {
// TODO: implement arrays
console.warn('OpenAPI Sampler: found allOf with "array" type. Result may be incorrect');
if (!options.quiet) console.warn('OpenAPI Sampler: found allOf with "array" type. Result may be incorrect');
}
const lastSample = subSamples[subSamples.length - 1];
res.value = lastSample != null ? lastSample : res.value;
Expand Down
2 changes: 1 addition & 1 deletion src/traverse.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export function traverse(schema, options, spec) {

if (schema.oneOf && schema.oneOf.length) {
if (schema.anyOf) {
console.warn('oneOf and anyOf are not supported on the same level. Skipping anyOf');
if (!options.quiet) console.warn('oneOf and anyOf are not supported on the same level. Skipping anyOf');
}
return traverse(schema.oneOf[0], options, spec);
}
Expand Down