@har-sdk/openapi-sampler
Version:
[](https://codeclimate.com/github/NeuraLegion/har-sdk/maintainability) [) {
this.vendorExampleExtractor = vendorExampleExtractor;
}
extractFromExamples(schema, options) {
let value = this.extractFromSchemaExamples(schema);
value =
value === undefined
? this.extractFromVendorExamples(schema, options)
: value;
return value;
}
extractFromProperties(schema) {
let value;
if (hasDefault(schema)) {
value = schema.default;
}
else if (schema.const !== undefined) {
value = schema.const;
}
else if (schema.enum && schema.enum.length) {
value = firstArrayElement(schema.enum);
}
return value;
}
extractFromSchemaExamples(schema) {
if (hasExample(schema)) {
return schema.example;
}
else if (schema.examples !== undefined &&
schema.examples.length > 0) {
return firstArrayElement(schema.examples);
}
}
extractFromVendorExamples(schema, { includeVendorExamples }) {
return includeVendorExamples
? this.vendorExampleExtractor.extract(schema)
: undefined;
}
}
//# sourceMappingURL=SchemaExampleExtractor.js.map