-
Notifications
You must be signed in to change notification settings - Fork 9k
JSON Schema samples API
Vladimír Gorej edited this page Sep 5, 2023
·
6 revisions
This page explains how to use samples API
in a static way, without full instantiation of SwaggerUI. samples API
is an API that is responsible for transforming JSON Schema Draft 4/5 and JSON Schema Draft 2020-12 to example data delivered as POJOs, JSON, YAML or XML.
import SwaggerUI from 'swagger-ui';
const system = new SwaggerUI.System({
plugins: [
SwaggerUI.plugins.JSONSchema5Samples,
SwaggerUI.plugins.JSONSchema202012Samples
],
presets: [],
}).getSystem();
system.fn.jsonSchema5.getJsonSampleSchema({ type: "object", properties: { a: { type: "string" }} });
system.fn.jsonSchema202012.getJsonSampleSchema({ type: "object", properties: { a: { type: "string" }} });
import SwaggerUI from 'swagger-ui-react';
const system = new SwaggerUI.System({
plugins: [
SwaggerUI.plugins.JSONSchema5Samples,
SwaggerUI.plugins.JSONSchema202012Samples
],
presets: [],
}).getSystem();
system.fn.jsonSchema5.getJsonSampleSchema({ type: "object", properties: { a: { type: "string" }} });
system.fn.jsonSchema202012.getJsonSampleSchema({ type: "object", properties: { a: { type: "string" }} });
API describes the shape of object attached to system.fn
which serves as entry point to samples API
.
jsonSchema5: {
inferSchema,
sampleFromSchema,
sampleFromSchemaGeneric,
createXMLExample,
memoizedSampleFromSchema,
memoizedCreateXMLExample,
getJsonSampleSchema,
getYamlSampleSchema,
getXmlSampleSchema,
getSampleSchema,
}
jsonSchema202012: {
sampleFromSchema,
sampleFromSchemaGeneric,
sampleEncoderAPI,
sampleFormatAPI,
sampleMediaTypeAPI,
createXMLExample,
memoizedSampleFromSchema,
memoizedCreateXMLExample,
getJsonSampleSchema,
getYamlSampleSchema,
getXmlSampleSchema,
getSampleSchema,
}