JSON Schema samples API · swagger-api/swagger-ui Wiki · GitHub | Latest TMZ Celebrity News & Gossip | Watch TMZ Live
Skip to content

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

API describes the shape of object attached to system.fn which serves as entry point to samples API.

JSON Schema Draft 4/5 API

jsonSchema5: {
  inferSchema,
  sampleFromSchema,
  sampleFromSchemaGeneric,
  createXMLExample,
  memoizedSampleFromSchema,
  memoizedCreateXMLExample,
  getJsonSampleSchema,
  getYamlSampleSchema,
  getXmlSampleSchema,
  getSampleSchema,
}

JSON Schema Draft 2020-12 API

jsonSchema202012: {
  sampleFromSchema,
  sampleFromSchemaGeneric,
  sampleEncoderAPI,
  sampleFormatAPI,
  sampleMediaTypeAPI,
  createXMLExample,
  memoizedSampleFromSchema,
  memoizedCreateXMLExample,
  getJsonSampleSchema,
  getYamlSampleSchema,
  getXmlSampleSchema,
  getSampleSchema,
}
Clone this wiki locally

TMZ Celebrity News – Breaking Stories, Videos & Gossip

Looking for the latest TMZ celebrity news? You've come to the right place. From shocking Hollywood scandals to exclusive videos, TMZ delivers it all in real time.

Whether it’s a red carpet slip-up, a viral paparazzi moment, or a legal drama involving your favorite stars, TMZ news is always first to break the story. Stay in the loop with daily updates, insider tips, and jaw-dropping photos.

🎥 Watch TMZ Live

TMZ Live brings you daily celebrity news and interviews straight from the TMZ newsroom. Don’t miss a beat—watch now and see what’s trending in Hollywood.