nfx-json 1.5.2
Modern C++20 JSON library with schema validation and generation
Loading...
Searching...
No Matches
nfx::json::SchemaGenerator Class Referencefinal

JSON Schema generator from Document instances. More...

#include <nfx/json/SchemaGenerator.h>

Classes

struct  Options
 Configuration options for schema generation. More...

Public Member Functions

 SchemaGenerator (const Document &document)
 Generate JSON Schema from a single document.
 SchemaGenerator (const Document &document, const Options &options)
 Generate JSON Schema from a single document.
 SchemaGenerator (const std::vector< Document > &documents)
 Generate JSON Schema from multiple sample documents.
 SchemaGenerator (const std::vector< Document > &documents, const Options &options)
 Generate JSON Schema from multiple sample documents.
 SchemaGenerator (const SchemaGenerator &)=default
 Copy constructor.
 SchemaGenerator (SchemaGenerator &&) noexcept=default
 Move constructor.
 ~SchemaGenerator ()=default
 Destructor.
SchemaGeneratoroperator= (const SchemaGenerator &)=default
 Copy assignment operator.
SchemaGeneratoroperator= (SchemaGenerator &&) noexcept=default
 Move assignment operator.
const Documentschema () const noexcept
 Get the generated schema.

Detailed Description

JSON Schema generator from Document instances.

Analyzes JSON data to generate JSON Schema Draft 2020-12 compliant schemas. Infers types, detects string formats (email, date, URI, UUID, etc.), and generates constraints based on observed values.

Definition at line 54 of file SchemaGenerator.h.

Constructor & Destructor Documentation

◆ SchemaGenerator() [1/4]

nfx::json::SchemaGenerator::SchemaGenerator ( const Document & document)
explicit

Generate JSON Schema from a single document.

Parameters
documentThe JSON document to analyze

◆ SchemaGenerator() [2/4]

nfx::json::SchemaGenerator::SchemaGenerator ( const Document & document,
const Options & options )

Generate JSON Schema from a single document.

Parameters
documentThe JSON document to analyze
optionsGeneration options

◆ SchemaGenerator() [3/4]

nfx::json::SchemaGenerator::SchemaGenerator ( const std::vector< Document > & documents)
explicit

Generate JSON Schema from multiple sample documents.

Analyzes multiple samples to infer required properties, detect enums, and generate more accurate constraints.

Parameters
documentsVector of JSON documents to analyze

◆ SchemaGenerator() [4/4]

nfx::json::SchemaGenerator::SchemaGenerator ( const std::vector< Document > & documents,
const Options & options )

Generate JSON Schema from multiple sample documents.

Analyzes multiple samples to infer required properties, detect enums, and generate more accurate constraints.

Parameters
documentsVector of JSON documents to analyze
optionsGeneration options

Member Function Documentation

◆ operator=() [1/2]

SchemaGenerator & nfx::json::SchemaGenerator::operator= ( const SchemaGenerator & )
default

Copy assignment operator.

Returns
Reference to this generator

◆ operator=() [2/2]

SchemaGenerator & nfx::json::SchemaGenerator::operator= ( SchemaGenerator && )
defaultnoexcept

Move assignment operator.

Returns
Reference to this generator

◆ schema()

const Document & nfx::json::SchemaGenerator::schema ( ) const
inlinenoexcept

Get the generated schema.

Returns
Const reference to the generated JSON Schema

The documentation for this class was generated from the following file: