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 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" }} });