### getExamples Source: https://github.com/dataunitylab/jsonoid-discovery/blob/main/_autodocs/api-reference/string-schema.md Retrieves the set of example string values discovered from the data for a StringSchema. ```APIDOC ## getExamples ### Description Returns example string values discovered from the data. ### Method ```scala def getExamples(): Option[Set[String]] ``` ### Returns `Option[Set[String]]` - set of example values or None ### Example ```scala val schema = StringSchema("test@example.com") implicit val params = JsonoidParams() val examples = schema.properties.getOrNone[ExamplesProperty].examples // Returns Some(Set("test@example.com")) ``` ``` -------------------------------- ### Get Example String Values Source: https://github.com/dataunitylab/jsonoid-discovery/blob/main/_autodocs/api-reference/string-schema.md Retrieves a set of example string values discovered from the data for a StringSchema. These examples can be used for validation or understanding typical values. ```scala def getExamples(): Option[Set[String]] ``` ```scala val examples = schema.properties.getOrNone[ExamplesProperty].examples // Returns Some(Set("hello@example.com", "user@domain.com", ...)) ``` -------------------------------- ### Complete Transformation Pipeline Example Source: https://github.com/dataunitylab/jsonoid-discovery/blob/main/_autodocs/api-reference/transformers.md A comprehensive Scala example demonstrating the full schema discovery and transformation pipeline. It configures all properties, applies all transformations, and outputs the resulting JSON schema. ```scala import io.github.dataunitylab.jsonoid.discovery._ import io.github.dataunitylab.jsonoid.discovery.schemas._ import io.github.dataunitylab.jsonoid.discovery.transformers._ import org.json4s.jackson.JsonMethods._ // Read data val source = scala.io.Source.fromFile("data.ndjson") val jsons = DiscoverSchema.jsonFromSource(source) // Configure with all properties implicit val params = JsonoidParams() .withPropertySet(PropertySets.AllProperties) .withER(EquivalenceRelations.KindEquivalenceRelation) // Discover schema val schema = DiscoverSchema.discover(jsons) // Apply all transformations val finalSchema = DiscoverSchema.transformSchema( schema, addDefinitions = true, detectDynamic = true, detectDisjoint = true, findEnums = true ) // Output val json = finalSchema.toJsonSchema() println(pretty(render(json))) ``` -------------------------------- ### Basic Array Discovery Example Source: https://github.com/dataunitylab/jsonoid-discovery/blob/main/_autodocs/api-reference/array-schema.md Demonstrates the basic process of discovering an ArraySchema from JSON data and merging multiple schemas. ```APIDOC ## Basic Array Discovery ### Description This example shows how to discover an ArraySchema from JSON data and merge discovered schemas. ### Example ```scala import io.github.dataunitylab.jsonoid.discovery._ import io.github.dataunitylab.jsonoid.discovery.schemas._ import org.json4s.jackson.JsonMethods._ implicit val params = JsonoidParams() // Discover from data val json1 = parse("["1", "2", "3"]) val json2 = parse("["5", "10"]) val schema1 = DiscoverSchema.discoverFromValue(json1).get.asInstanceOf[ArraySchema] val schema2 = DiscoverSchema.discoverFromValue(json2).get.asInstanceOf[ArraySchema] // Merge val merged = schema1.merge(schema2) // Result has item type StringSchema, minItems=2, maxItems=3 ``` ``` -------------------------------- ### ProductSchema Serialization Example Source: https://github.com/dataunitylab/jsonoid-discovery/blob/main/_autodocs/api-reference/other-schemas.md Example JSON representation of a ProductSchema using the 'oneOf' keyword. ```json { "oneOf": [ {"type": "string"}, {"type": "integer"} ] } ``` -------------------------------- ### Configure Maximum Examples Source: https://github.com/dataunitylab/jsonoid-discovery/blob/main/_autodocs/configuration.md Sets the maximum number of example values to preserve per property. Higher values preserve more diversity but increase memory usage. Set to 0 to disable examples. ```scala // Keep up to 1000 examples val params = JsonoidParams().withMaxExamples(1000) ``` -------------------------------- ### Format Detection Examples Source: https://github.com/dataunitylab/jsonoid-discovery/blob/main/_autodocs/api-reference/string-schema.md Provides examples of format detection for StringSchemas, showing how JSONoid identifies formats like 'date' and 'uuid' from string values. ```scala import io.github.dataunitylab.jsonoid.discovery._ import io.github.dataunitylab.jsonoid.discovery.schemas._ implicit val params = JsonoidParams() val dateSchema = StringSchema("2024-01-15") val format = dateSchema.properties.getOrNone[FormatProperty].format // format == Some("date") val uuidSchema = StringSchema("550e8400-e29b-41d4-a716-446655440000") val uuidFormat = uuidSchema.properties.getOrNone[FormatProperty].format // uuidFormat == Some("uuid") ``` -------------------------------- ### Scala: Example Usage of transformSchema Source: https://github.com/dataunitylab/jsonoid-discovery/blob/main/_autodocs/api-reference/discover-schema.md Demonstrates how to use the transformSchema function with specific parameters to detect dynamic objects and add definitions. ```scala val schema = DiscoverSchema.discover(jsonIterator) implicit val params = JsonoidParams() val transformedSchema = DiscoverSchema.transformSchema( schema, detectDynamic = true, addDefinitions = true ) ``` -------------------------------- ### Apply Transformers via CLI Source: https://github.com/dataunitylab/jsonoid-discovery/blob/main/_autodocs/api-reference/transformers.md Execute schema transformations from the command line using the `DiscoverSchema` class. This example enables definitions, dynamic object detection, and disjoint object detection. ```bash java -cp jsonoid-discovery.jar \ io.github.dataunitylab.jsonoid.discovery.DiscoverSchema \ -p All \ -d \ -y \ -j \ data.ndjson ``` -------------------------------- ### Tuple Detection Example Source: https://github.com/dataunitylab/jsonoid-discovery/blob/main/_autodocs/api-reference/array-schema.md Illustrates how to detect and identify tuple-like arrays using the `getItemTypes` method. ```APIDOC ## Tuple Detection ### Description This example demonstrates how to detect if an array is a tuple (heterogeneous) or a homogeneous array. ### Example ```scala val json = parse("[42, \"name\", true]") implicit val params = JsonoidParams() val schema = DiscoverSchema.discoverFromValue(json).get.asInstanceOf[ArraySchema] schema.properties.get[ItemTypeProperty].itemType match { case Right(types) => println(s"Tuple with ${types.length} positions") case Left(_) => println("Homogeneous array") } ``` ``` -------------------------------- ### DynamicObjectSchema Serialization Example Source: https://github.com/dataunitylab/jsonoid-discovery/blob/main/_autodocs/api-reference/other-schemas.md Example JSON representation of a DynamicObjectSchema using 'patternProperties'. ```json { "type": "object", "patternProperties": { ".*": {"type": "integer"} } } ``` -------------------------------- ### Get Item Types Example Source: https://github.com/dataunitylab/jsonoid-discovery/blob/main/_autodocs/api-reference/array-schema.md Demonstrates how to retrieve item types from an ArraySchema, distinguishing between homogeneous arrays and tuples. ```scala val homoArray = ArraySchema.array(StringSchema("")) homoArray.getItemTypes() match { case Left(itemType) => println(s"Item type: $itemType") case Right(types) => println(s"Tuple types: $types") } // Output: Item type: StringSchema ``` -------------------------------- ### CLI Option: Advanced Settings Source: https://github.com/dataunitylab/jsonoid-discovery/blob/main/_autodocs/README.md Provides advanced options for schema discovery, such as splitting discovery data, limiting the number of examples, and setting a random seed for reproducibility. ```bash # Advanced -s 0.8 # Split discovery (80% train) --max-examples 50 # Limit example collection --random-seed 12345 # Reproducible results ``` -------------------------------- ### MultipleOf Detection Example Source: https://github.com/dataunitylab/jsonoid-discovery/blob/main/_autodocs/api-reference/numeric-schemas.md Demonstrates how to detect the 'multipleOf' constraint for numeric schemas using the MultipleOfProperty and Euclid's GCD algorithm. ```APIDOC ## MultipleOf Detection ### Description Both `IntegerSchema` and `NumberSchema` support discovery of `multipleOf` constraints. The `MultipleOfProperty` uses Euclid's greatest common divisor (GCD) algorithm to find the largest common divisor of all observed values. ### Example ```scala val schema1 = IntegerSchema(10) val schema2 = IntegerSchema(20) val schema3 = IntegerSchema(30) implicit val params = JsonoidParams() val merged = schema1.merge(schema2).merge(schema3) val multipleOf = merged.properties.getOrNone[MultipleOfProperty].multipleOf // Returns Some(10) - all values are multiples of 10 ``` ``` -------------------------------- ### Output to JSON Schema Example Source: https://github.com/dataunitylab/jsonoid-discovery/blob/main/_autodocs/api-reference/array-schema.md Shows how to convert an ArraySchema object into its equivalent JSON Schema representation. ```APIDOC ## Output to JSON Schema ### Description This example demonstrates converting an ArraySchema object into its JSON Schema representation. ### Example ```scala val homoArray = ArraySchema.array(StringSchema("test")) implicit val params = JsonoidParams() val jsonSchema = homoArray.toJsonSchema() println(pretty(render(jsonSchema))) // Output: // { // "$schema": "https://json-schema.org/draft/2020-12/schema", // "type": "array", // "items": {"type": "string"} // } ``` ``` -------------------------------- ### Compile JSONoid Discovery JAR with sbt-extras Source: https://github.com/dataunitylab/jsonoid-discovery/blob/main/README.md This command compiles the JSONoid Discovery project into a JAR file using sbt assembly and sbt-extras. sbt-extras attempts to automatically download and install the appropriate sbt and Scala versions, simplifying the build process. ```bash ./sbtx assembly ``` -------------------------------- ### Configure Format Detection Threshold Source: https://github.com/dataunitylab/jsonoid-discovery/blob/main/_autodocs/api-reference/string-schema.md Adjusts the percentage of values required to match a format for it to be detected. This example sets the threshold to 80%. ```scala // Only accept format if 80% of values match val params = JsonoidParams().withFormatThreshold(0.8f) implicit val p = params val schema = StringSchema("test@example.com") val format = schema.properties.getOrNone[FormatProperty] // If 80%+ of values are emails, format will be detected ``` -------------------------------- ### Detect Dynamic Objects Example Source: https://github.com/dataunitylab/jsonoid-discovery/blob/main/jsonoid.1.md Demonstrates how dynamic object detection can simplify schemas for objects with data values as keys. The schema transforms from specific keys to a general 'additionalProperties' definition. ```json {"population": {"Rochester": 210606, "Boston": 654776}} ``` ```json {"type": "object", "additionalProperties": {"type": "integer"}} ``` -------------------------------- ### StringSchema.AllProperties Source: https://github.com/dataunitylab/jsonoid-discovery/blob/main/_autodocs/api-reference/string-schema.md Provides the complete set of string properties, including statistical analysis like length distribution and examples, along with format, pattern, and length constraints. ```APIDOC ## StringSchema.AllProperties ### Description Provides the complete set of string properties, including statistical analysis like length distribution and examples, along with format, pattern, and length constraints. ### Method `lazy val AllProperties` ### Parameters None ### Request Example None ### Response #### Success Response `SchemaProperties[String]` - Complete set of string properties. #### Response Example None ``` -------------------------------- ### Schema Discovery with Custom Configuration Source: https://github.com/dataunitylab/jsonoid-discovery/blob/main/_autodocs/README.md Perform schema discovery with custom parameters, including property sets, equivalence relations, and extended format detection. This example also demonstrates post-processing schema transformations. ```scala implicit val params = JsonoidParams() .withPropertySet(PropertySets.AllProperties) .withER(EquivalenceRelations.LabelEquivalenceRelation) .withExtendedFormats(true) val schema = DiscoverSchema.discover(jsons) val finalSchema = DiscoverSchema.transformSchema( schema, detectDynamic = true, addDefinitions = true ) ``` -------------------------------- ### Quick Start Schema Discovery Source: https://github.com/dataunitylab/jsonoid-discovery/blob/main/_autodocs/README.md Discover a JSON schema from a newline-delimited JSON file using the default configuration. This process involves reading the data, discovering the schema, and outputting it in JSON Schema format. ```scala import io.github.dataunitylab.jsonoid.discovery._ import io.github.dataunitylab.jsonoid.discovery.schemas._ import org.json4s.jackson.JsonMethods._ // 1. Read data val source = scala.io.Source.fromFile("data.ndjson") val jsons = DiscoverSchema.jsonFromSource(source) // 2. Discover schema (uses implicit default JsonoidParams) val schema = DiscoverSchema.discover(jsons) // 3. Output JSON Schema val jsonSchema = schema.toJsonSchema() println(pretty(render(jsonSchema))) ``` -------------------------------- ### Tuple Detection Example Source: https://github.com/dataunitylab/jsonoid-discovery/blob/main/_autodocs/api-reference/array-schema.md Demonstrates how to detect if an ArraySchema represents a tuple (heterogeneous array) or a homogeneous array based on its discovered item types. ```scala val json = parse("""[42, "name", true]""") implicit val params = JsonoidParams() val schema = DiscoverSchema.discoverFromValue(json).get.asInstanceOf[ArraySchema] schema.properties.get[ItemTypeProperty].itemType match { case Right(types) => println(s"Tuple with ${types.length} positions") case Left(_) => println("Homogeneous array") } ``` -------------------------------- ### Configure JsonoidParams using Builder Methods Source: https://github.com/dataunitylab/jsonoid-discovery/blob/main/_autodocs/configuration.md Demonstrates fluent configuration of `JsonoidParams` using various builder methods for customization. This allows setting multiple parameters like additional properties, equivalence relations, extended formats, format thresholds, max examples, property sets, and reset format length. ```scala val defaultParams = JsonoidParams() val customParams = defaultParams .withAdditionalProperties(true) .withER(EquivalenceRelations.LabelEquivalenceRelation) .withExtendedFormats(true) .withFormatThreshold(0.9f) .withMaxExamples(50) .withPropertySet(PropertySets.SimpleProperties) .withResetFormatLength(true) ``` -------------------------------- ### Compile JSONoid Discovery JAR Source: https://github.com/dataunitylab/jsonoid-discovery/blob/main/README.md This command compiles the JSONoid Discovery project into a JAR file using sbt assembly. This JAR can be run locally or submitted to a Spark cluster. It requires an sbt installation. ```bash sbt assembly ``` -------------------------------- ### Access StringSchema Properties Source: https://github.com/dataunitylab/jsonoid-discovery/blob/main/_autodocs/api-reference/string-schema.md Demonstrates accessing various properties of a StringSchema, including format, pattern, length bounds, and examples, using the SchemaProperties API. ```scala val schema = StringSchema("test@example.com") implicit val params = JsonoidParams() // Get detected format val format = schema.properties.getOrNone[FormatProperty].format // Some("email") // Get pattern val pattern = schema.properties.getOrNone[PatternProperty].pattern // Some(".*@.*\\..*") // Get length bounds val minLength = schema.properties.getOrNone[MinLengthProperty].minLength val maxLength = schema.properties.getOrNone[MaxLengthProperty].maxLength // Get examples val examples = schema.properties.getOrNone[ExamplesProperty].examples // Get length histogram (AllProperties only) val histogram = schema.properties.getOrNone[LengthHistogramProperty].histogram ``` -------------------------------- ### Memory Usage Optimization for Schema Discovery Source: https://github.com/dataunitylab/jsonoid-discovery/blob/main/_autodocs/api-reference/spark-api.md Reduce memory consumption during schema discovery for large datasets by using `SimpleProperties` and limiting the number of examples processed. ```scala // Use SimpleProperties for large datasets implicit val params = JsonoidParams() .withPropertySet(PropertySets.SimpleProperties) .withMaxExamples(10) // Reduce examples val schema = JsonoidRDD.fromStringRDD(jsonRdd) .treeReduceSchemas(depth = 2) ``` -------------------------------- ### Discover and Merge Object Schemas from Data Source: https://github.com/dataunitylab/jsonoid-discovery/blob/main/_autodocs/api-reference/object-schema.md Discovers ObjectSchemas from JSON data using `discoverFromValue` and then merges them. This example shows how to infer schema properties like required fields and optional fields from sample data. ```scala import io.github.dataunitylab.jsonoid.discovery._ import io.github.dataunitylab.jsonoid.discovery.schemas._ import org.json4s.jackson.JsonMethods._ implicit val params = JsonoidParams() // Discover from data val json1 = parse("{\"id\": 1, \"name\": \"Alice\", \"email\": \"alice@example.com\"}") val json2 = parse("{\"id\": 2, \"name\": \"Bob\"}") val schema1 = DiscoverSchema.discoverFromValue(json1).get.asInstanceOf[ObjectSchema] val schema2 = DiscoverSchema.discoverFromValue(json2).get.asInstanceOf[ObjectSchema] // Merge val merged = schema1.merge(schema2) // Result has "id" and "name" as required, "email" as optional ``` -------------------------------- ### Spark Integration for Schema Discovery Source: https://github.com/dataunitylab/jsonoid-discovery/blob/main/_autodocs/api-reference/README.md Integrates JSONoid schema discovery with Apache Spark. This example reads JSON data from a text file into a Spark RDD and then uses JsonoidRDD to discover schemas, performing a tree reduction with a specified depth. ```scala import io.github.dataunitylab.jsonoid.discovery.spark._ val sc = new SparkContext(...) val jsonRdd = sc.textFile("data.ndjson") implicit val params = JsonoidParams() val schema = JsonoidRDD.fromStringRDD(jsonRdd) .treeReduceSchemas(depth = 2) ``` -------------------------------- ### Basic CLI Usage Source: https://github.com/dataunitylab/jsonoid-discovery/blob/main/_autodocs/api-reference/README.md Execute schema discovery from the command line using the DiscoverSchema class and specifying the input data file. ```bash java -cp jsonoid-discovery.jar \ io.github.dataunitylab.jsonoid.discovery.DiscoverSchema \ data.ndjson ``` -------------------------------- ### Get Unique Constraint Example Source: https://github.com/dataunitylab/jsonoid-discovery/blob/main/_autodocs/api-reference/array-schema.md Checks if the array elements are constrained to be unique. ```scala val schema = ArraySchema.array(IntegerSchema(1)) val unique = schema.properties.getOrNone[UniqueProperty].unique // Returns true if all observed arrays had unique elements ``` -------------------------------- ### Get Max Items Example Source: https://github.com/dataunitylab/jsonoid-discovery/blob/main/_autodocs/api-reference/array-schema.md Retrieves the maximum number of items allowed in an array if specified. ```scala val maxItems = schema.properties.getOrNone[MaxItemsProperty].maxItems ``` -------------------------------- ### Bash: Command Line Usage for DiscoverSchema Source: https://github.com/dataunitylab/jsonoid-discovery/blob/main/_autodocs/api-reference/discover-schema.md Shows how to run the DiscoverSchema CLI tool, specifying input and output files, and various discovery options. ```bash java -cp jsonoid-discovery.jar io.github.dataunitylab.jsonoid.discovery.DiscoverSchema [options] [input] ``` -------------------------------- ### Get Min Items Example Source: https://github.com/dataunitylab/jsonoid-discovery/blob/main/_autodocs/api-reference/array-schema.md Retrieves the minimum number of items allowed in an array if specified. ```scala val schema = ArraySchema(List(StringSchema(""))) val minItems = schema.properties.getOrNone[MinItemsProperty].minItems ``` -------------------------------- ### Basic CLI Command for Schema Discovery Source: https://github.com/dataunitylab/jsonoid-discovery/blob/main/_autodocs/README.md This command demonstrates the basic usage of the JSONoid Discovery CLI to discover a schema from an input file. ```bash java -cp jsonoid-discovery.jar \ io.github.dataunitylab.jsonoid.discovery.DiscoverSchema \ input.ndjson ``` -------------------------------- ### Command Line Usage Source: https://github.com/dataunitylab/jsonoid-discovery/blob/main/_autodocs/api-reference/discover-schema.md Provides instructions on how to use the DiscoverSchema object via the command line, including common options for schema discovery and transformation. ```APIDOC ## Command Line Usage ### Description Use the `DiscoverSchema` object via its `main` method for command-line schema discovery and processing. ### Method Command Line Interface ### Endpoint `java -cp jsonoid-discovery.jar io.github.dataunitylab.jsonoid.discovery.DiscoverSchema [options] [input]` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Common CLI Options - **--help** (`-h`) - Show help message - **--write-output ** (`-w`) - Write schema to file (default: stdout) - **--values ** (`-v`) - Write value table to file - **--prop ** (`-p`) - Property set: All, Min, Simple (default: All) - **--equivalence-relation ** (`-e`) - Kind, Label, IntersectingLabel, TypeMatch - **--add-definitions** (`-d`) - Extract definitions from schema - **--detect-dynamic** (`-y`) - Detect dynamic object keys - **--detect-disjoint** (`-j`) - Detect disjoint object types - **--split-percentage ** (`-s`) - Use split discovery - **--extended-formats** - Include extended format hints - **--max-examples ** - Maximum examples per property - **--format-threshold ** - Minimum fraction for format detection - **--random-seed ** - Seed for random sampling ### Request Example ```bash java -cp jsonoid-discovery.jar io.github.dataunitylab.jsonoid.discovery.DiscoverSchema --add-definitions --detect-dynamic input.json ``` ### Response #### Success Response Schema output to stdout or specified file. #### Response Example ```json { "type": "object", "properties": { "key1": { "type": "string" }, "key2": { "type": "number" } } } ``` ``` -------------------------------- ### CLI Option: Property Set Source: https://github.com/dataunitylab/jsonoid-discovery/blob/main/_autodocs/README.md Specifies the property set to use for schema discovery. Options include All (default), Simple, and Min. ```bash # Property set: All (default), Simple, Min -p Simple ``` -------------------------------- ### Common CLI Options Source: https://github.com/dataunitylab/jsonoid-discovery/blob/main/_autodocs/api-reference/README.md Utilize common command-line options for Jsonoid Discovery, including property set selection, pattern detection, format detection, output file specification, value export, and split discovery. ```bash # SimpleProperties only -p Simple # Detect all patterns -d -y -j # Format detection with 80% threshold --extended-formats --format-threshold 0.8 # Output to file -w schema.json # Export values -v values.tsv # Split discovery -s 0.8 ``` -------------------------------- ### Get Schema Properties Source: https://github.com/dataunitylab/jsonoid-discovery/blob/main/_autodocs/api-reference/json-schema.md Access the `properties` of a schema to retrieve metadata such as histograms, statistics, and formats. ```scala val schema = StringSchema("test") val props = schema.properties val formatOpt = props.getOrNone[FormatProperty] ``` -------------------------------- ### Get Valid Types Source: https://github.com/dataunitylab/jsonoid-discovery/blob/main/_autodocs/api-reference/json-schema.md The `validTypes` property returns a set of valid JSON4s value types (e.g., `Class[_]`) for the schema. ```scala def validTypes: Set[Class[_]] ``` -------------------------------- ### JsonoidSpark CLI: Simplified Properties and Tree Reduction Source: https://github.com/dataunitylab/jsonoid-discovery/blob/main/_autodocs/api-reference/spark-api.md Runs schema discovery with simplified property set ('Simple') and enables tree reduction for efficiency. Supports S3 paths. ```bash spark-submit --class io.github.dataunitylab.jsonoid.discovery.spark.JsonoidSpark \ jsonoid-discovery.jar \ -p Simple \ -t \ s3://bucket/data.ndjson ``` -------------------------------- ### Performance Tuning for Large Datasets Source: https://github.com/dataunitylab/jsonoid-discovery/blob/main/_autodocs/api-reference/README.md Optimize performance for large datasets by skipping statistics, reducing the number of examples, and using KindEquivalenceRelation. ```scala implicit val params = JsonoidParams() .withPropertySet(PropertySets.SimpleProperties) // Skip statistics .withMaxExamples(10) // Reduce examples .withER(EquivalenceRelations.KindEquivalenceRelation) val schema = DiscoverSchema.discover(jsons) ``` -------------------------------- ### Get Maximum String Length Source: https://github.com/dataunitylab/jsonoid-discovery/blob/main/_autodocs/api-reference/string-schema.md Retrieves the maximum string length discovered for a StringSchema. This property is useful for setting validation constraints. ```scala def getMaxLength(): Option[Int] ``` ```scala val maxLen = schema.properties.getOrNone[MaxLengthProperty].maxLength ``` -------------------------------- ### Basic Object Discovery Source: https://github.com/dataunitylab/jsonoid-discovery/blob/main/_autodocs/api-reference/object-schema.md Demonstrates how to discover an ObjectSchema from JSON data and merge multiple schemas. ```APIDOC ## Basic Object Discovery ### Description Discover an ObjectSchema from data and merge multiple schemas. ### Example ```scala import io.github.dataunitylab.jsonoid.discovery._ import io.github.dataunitylab.jsonoid.discovery.schemas._ import org.json4s.jackson.JsonMethods._ implicit val params = JsonoidParams() // Discover from data val json1 = parse("{\"id\": 1, \"name\": \"Alice\", \"email\": \"alice@example.com\"}") val json2 = parse("{\"id\": 2, \"name\": \"Bob\"}") val schema1 = DiscoverSchema.discoverFromValue(json1).get.asInstanceOf[ObjectSchema] val schema2 = DiscoverSchema.discoverFromValue(json2).get.asInstanceOf[ObjectSchema] // Merge val merged = schema1.merge(schema2) // Result has "id" and "name" as required, "email" as optional ``` ``` -------------------------------- ### Get Minimum String Length Source: https://github.com/dataunitylab/jsonoid-discovery/blob/main/_autodocs/api-reference/string-schema.md Retrieves the minimum string length discovered for a StringSchema. This property is useful for setting validation constraints. ```scala def getMinLength(): Option[Int] ``` ```scala val minLen = schema.properties.getOrNone[MinLengthProperty].minLength ``` -------------------------------- ### Get Property Dependencies Source: https://github.com/dataunitylab/jsonoid-discovery/blob/main/_autodocs/api-reference/object-schema.md Retrieves property dependencies, where the presence of one property necessitates the presence of others. Returns None if no such dependencies are defined. ```scala def getDependencies(): Option[Map[String, Set[String]]] ``` ```scala // If "state" requires "country" schema.properties.get[DependenciesProperty].dependencies // Returns Some(Map("state" -> Set("country"))) ``` -------------------------------- ### Run JSONoid Discovery with Docker Source: https://github.com/dataunitylab/jsonoid-discovery/blob/main/README.md This command runs the latest version of JSONoid Discovery using Docker. It accepts newline-delimited JSON on standard input and will wait for input by default. Use `--help` to see configuration options. ```bash docker run -i --rm michaelmior/jsonoid-discovery ``` -------------------------------- ### Get Required Properties Source: https://github.com/dataunitylab/jsonoid-discovery/blob/main/_autodocs/api-reference/object-schema.md Retrieves the set of property names that are always required in an object. Returns None if no properties are explicitly marked as required. ```scala def getRequired(): Option[Set[String]] ``` ```scala val schema = ObjectSchema(Map("id" -> IntegerSchema(1))) schema.properties.get[RequiredProperty].required // Returns Some(Set("id")) if field is always present ``` -------------------------------- ### Create ProductSchema using Factory Methods Source: https://github.com/dataunitylab/jsonoid-discovery/blob/main/_autodocs/api-reference/other-schemas.md Use factory methods like oneOf, anyOf, or allOf to create ProductSchema instances. These methods accept a list of JsonSchema objects. ```scala implicit val params = JsonoidParams() // Via factory val schema = ProductSchema.oneOf(List( StringSchema("text"), IntegerSchema(42) )) ``` -------------------------------- ### JsonoidSpark CLI: Basic Discovery Source: https://github.com/dataunitylab/jsonoid-discovery/blob/main/_autodocs/api-reference/spark-api.md Submits a Spark job for schema discovery using the JsonoidSpark CLI from HDFS. Specify the main class, JAR, and input path. ```bash spark-submit --class io.github.dataunitylab.jsonoid.discovery.spark.JsonoidSpark \ jsonoid-discovery.jar \ hdfs://path/to/data.ndjson ``` -------------------------------- ### Merge Two String Schemas Source: https://github.com/dataunitylab/jsonoid-discovery/blob/main/_autodocs/api-reference/string-schema.md Illustrates merging two StringSchemas. When merged, their properties are combined intelligently, such as including examples from both schemas and determining a common format. ```scala val schema1 = StringSchema("alice@example.com") val schema2 = StringSchema("bob@example.com") implicit val params = JsonoidParams() val merged = schema1.merge(schema2) // Result: StringSchema with format=email, examples include both ``` -------------------------------- ### Extract Definitions Source: https://github.com/dataunitylab/jsonoid-discovery/blob/main/_autodocs/api-reference/README.md Discover a schema and then transform it to include definitions. This requires using the AllProperties set for comprehensive analysis. ```scala implicit val params = JsonoidParams() .withPropertySet(PropertySets.AllProperties) val schema = DiscoverSchema.discover(jsons) val withDefs = DiscoverSchema.transformSchema( schema, addDefinitions = true ) ``` -------------------------------- ### Get Schema Type Source: https://github.com/dataunitylab/jsonoid-discovery/blob/main/_autodocs/api-reference/json-schema.md Retrieve the JSON Schema type as a string (e.g., "object", "array") using the `schemaType` property. ```scala def schemaType: String ``` -------------------------------- ### Configure Property Set for Discovery Source: https://github.com/dataunitylab/jsonoid-discovery/blob/main/_autodocs/configuration.md Use `withPropertySet` to specify which schema properties to discover. `PropertySets.SimpleProperties` includes only standard JSON Schema keywords for faster discovery. ```scala val params = JsonoidParams().withPropertySet(PropertySets.SimpleProperties) ``` -------------------------------- ### Get Inferred Regex Pattern Source: https://github.com/dataunitylab/jsonoid-discovery/blob/main/_autodocs/api-reference/string-schema.md Retrieves the inferred regex pattern from a StringSchema's properties. This is useful when the string data follows a specific, discoverable pattern. ```scala def getPattern(): Option[String] ``` ```scala val pattern = schema.properties.getOrNone[PatternProperty].pattern ``` -------------------------------- ### Identify Primary Key Candidates from Schema Source: https://github.com/dataunitylab/jsonoid-discovery/blob/main/_autodocs/api-reference/utilities.md Shows how to use PrimaryKeyFinder to analyze a schema and identify potential primary key candidates based on features like cardinality and format patterns. ```scala val keyFeatures = PrimaryKeyFinder.walk(schema) // Identifies fields with high cardinality, uniqueness patterns ``` -------------------------------- ### Get Field Presence Source: https://github.com/dataunitylab/jsonoid-discovery/blob/main/_autodocs/api-reference/object-schema.md Retrieves the percentage of objects that contain each optional field, ranging from 0.0 to 1.0. Returns None if field presence information is not available. ```scala def getFieldPresence(): Option[Map[String, Double]] ``` ```scala // "email" present in 75% of objects schema.properties.getOrNone[FieldPresenceProperty].fieldPresence // Returns Some(Map("email" -> 0.75)) ``` -------------------------------- ### Use AllProperties for Schema Discovery with Reusable Definitions Source: https://github.com/dataunitylab/jsonoid-discovery/blob/main/_autodocs/README.md Configure JsonoidParams to use the 'AllProperties' set for maximum detail during schema discovery. This allows for the extraction of reusable definitions from the discovered schema. ```Scala implicit val params = JsonoidParams() .withPropertySet(PropertySets.AllProperties) val schema = DiscoverSchema.discover(jsons) val withDefs = DiscoverSchema.transformSchema(schema, addDefinitions = true) ``` -------------------------------- ### SchemaProperties Class Source: https://github.com/dataunitylab/jsonoid-discovery/blob/main/_autodocs/types.md A container for schema properties that supports typed access using ClassTag. Use get to retrieve a specific property type or getOrNone for an optional retrieval. ```scala class SchemaProperties[T] { def get[P <: SchemaProperty[T]](implicit ct: ClassTag[P]): P def getOrNone[P <: SchemaProperty[T]](implicit ct: ClassTag[P]): Option[P] def add[P <: SchemaProperty[T]](prop: P): Unit def replaceProperty[P <: SchemaProperty[T]](prop: P): SchemaProperties[T] def replacePropertyWithDefault[P <: SchemaProperty[T]](implicit ct: ClassTag[P]): SchemaProperties[T] def map[S](f: SchemaProperty[T] => SchemaProperty[S]): SchemaProperties[S] } ``` ```scala val schema = ObjectSchema(Map(...)) val props: SchemaProperties[Map[String, JsonSchema[_]]] = schema.properties val objectTypes = props.get[ObjectTypesProperty].objectTypes val required = props.getOrNone[RequiredProperty] ``` -------------------------------- ### ProductSchema Source: https://github.com/dataunitylab/jsonoid-discovery/blob/main/_autodocs/api-reference/other-schemas.md Represents schemas with alternative types, supporting oneOf, anyOf, and allOf. ```APIDOC ## ProductSchema ### Description Represents schemas with alternative types, supporting oneOf, anyOf, and allOf. ### Constructor ```scala def apply( properties: SchemaProperties[List[JsonSchema[_]]] )(implicit p: JsonoidParams): ProductSchema ``` ### Factory Methods ```scala def oneOf(schemas: List[JsonSchema[_]])(implicit p: JsonoidParams): ProductSchema def anyOf(schemas: List[JsonSchema[_]])(implicit p: JsonoidParams): ProductSchema def allOf(schemas: List[JsonSchema[_]])(implicit p: JsonoidParams): ProductSchema ``` ### Properties Access the product type and schemas via: ```scala val typesProp = schema.properties.get[ProductSchemaTypesProperty] val productType = typesProp.productType // OneOf, AnyOf, or AllOf val schemas = typesProp.types // Alternative schemas ``` ### Serialization ```json { "oneOf": [ {"type": "string"}, {"type": "integer"} ] } ``` ``` -------------------------------- ### Get Typed Object Properties Source: https://github.com/dataunitylab/jsonoid-discovery/blob/main/_autodocs/api-reference/object-schema.md The getProperties method returns a map of all typed object properties, equivalent to accessing the ObjectTypesProperty. This is useful for inspecting the defined schema properties. ```scala val schema = ObjectSchema(Map( "name" -> StringSchema("John"), "age" -> IntegerSchema(30) )) val props = schema.getProperties() // props("name") is StringSchema("John") // props("age") is IntegerSchema(30) ``` -------------------------------- ### EnumTransformer.transformSchema Source: https://github.com/dataunitylab/jsonoid-discovery/blob/main/_autodocs/api-reference/transformers.md Infers enum constraints from example values in a schema. This transformer is always enabled by default and is useful for identifying when a field consistently holds a small set of specific values. ```APIDOC ## EnumTransformer.transformSchema ### Description Infers `enum` constraints from example values when a small set of values is detected. This transformer is always enabled by default. ### Method `transformSchema(schema: JsonSchema[_], otherSchema: Option[JsonSchema[_]] = None)(implicit p: JsonoidParams): JsonSchema[_]` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response `JsonSchema[_]` - schema with enum constraints applied #### Response Example ```scala import io.github.dataunitylab.jsonoid.discovery.transformers._ import io.github.dataunitylab.jsonoid.discovery._ import io.github.dataunitylab.jsonoid.discovery.schemas._ implicit val params = JsonoidParams() val schema = StringSchema("red") // After discovering "red", "green", "blue" val transformed = EnumTransformer.transformSchema(schema) // Result: EnumSchema with {"enum": ["red", "green", "blue"]} ``` ``` -------------------------------- ### Basic Array Schema Discovery Source: https://github.com/dataunitylab/jsonoid-discovery/blob/main/_autodocs/api-reference/array-schema.md Shows how to discover an ArraySchema from JSON data and then merge multiple discovered schemas. ```scala import io.github.dataunitylab.jsonoid.discovery._ import io.github.dataunitylab.jsonoid.discovery.schemas._ import org.json4s.jackson.JsonMethods._ implicit val params = JsonoidParams() // Discover from data val json1 = parse("""[1, 2, 3]""") val json2 = parse("""[5, 10]""") val schema1 = DiscoverSchema.discoverFromValue(json1).get.asInstanceOf[ArraySchema] val schema2 = DiscoverSchema.discoverFromValue(json2).get.asInstanceOf[ArraySchema] // Merge val merged = schema1.merge(schema2) // Result has item type IntegerSchema, minItems=2, maxItems=3 ``` -------------------------------- ### IntegerSchema Constructor Source: https://github.com/dataunitylab/jsonoid-discovery/blob/main/_autodocs/api-reference/numeric-schemas.md Creates an IntegerSchema from a sample integer value. It requires the sample value and implicit JsonoidParams for configuration. ```APIDOC ## IntegerSchema Constructor ### Description Creates an IntegerSchema from a sample integer value. ### Method Signature ```scala def apply(value: BigInt)(implicit p: JsonoidParams): IntegerSchema ``` ### Parameters #### Path Parameters - **value** (BigInt) - Required - Sample integer value - **p** (JsonoidParams) - Required (implicit) - Configuration parameters ### Request Example ```scala implicit val params = JsonoidParams() val schema = IntegerSchema(42) ``` ``` -------------------------------- ### Configure JsonoidParams for Machine Learning/Data Analysis Source: https://github.com/dataunitylab/jsonoid-discovery/blob/main/_autodocs/configuration.md This configuration is suitable for machine learning and data analysis tasks. It includes all properties, kind equivalence, and limits the number of examples processed. ```scala val params = JsonoidParams() .withPropertySet(PropertySets.AllProperties) .withER(EquivalenceRelations.KindEquivalenceRelation) .withMaxExamples(500) .withResetFormatLength(false) .withAdditionalProperties(false) ``` -------------------------------- ### CLI Option: Format Detection Source: https://github.com/dataunitylab/jsonoid-discovery/blob/main/_autodocs/README.md Configures format detection, including enabling extended formats and setting a threshold for format detection confidence. ```bash # Format detection --extended-formats --format-threshold 0.8 ``` -------------------------------- ### Conservative Discovery Configuration Source: https://github.com/dataunitylab/jsonoid-discovery/blob/main/_autodocs/configuration.md Configures `JsonoidParams` for conservative schema discovery using minimal properties and strict equivalence relations. This setup prioritizes performance and minimal schema output. ```scala val params = JsonoidParams() .withPropertySet(PropertySets.MinProperties) .withER(EquivalenceRelations.LabelEquivalenceRelation) .withFormatThreshold(1.0f) .withMaxExamples(10) ``` -------------------------------- ### Implement SchemaWalker for Schema Counting Source: https://github.com/dataunitylab/jsonoid-discovery/blob/main/_autodocs/api-reference/utilities.md Example of subclassing SchemaWalker to create a transformer that recursively walks a schema tree and collects values of a specific type, in this case, counting schemas by type. ```scala // Count all schemas by type object SchemaCounter extends SchemaWalker[Map[String, Int]] { def walk(schema: JsonSchema[_]): Map[String, Int] = { // implementation } } ``` -------------------------------- ### StringSchema apply Source: https://github.com/dataunitylab/jsonoid-discovery/blob/main/_autodocs/api-reference/string-schema.md Creates a StringSchema from a sample string value. The schema will discover properties like format and length from the sample and subsequent merges. ```APIDOC ## StringSchema apply ### Description Creates a StringSchema from a sample string value. The schema will discover properties like format and length from the sample and subsequent merges. ### Method `apply` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```scala import io.github.dataunitylab.jsonoid.discovery._ import io.github.dataunitylab.jsonoid.discovery.schemas._ implicit val params = JsonoidParams() val schema = StringSchema("hello@example.com") ``` ### Response #### Success Response `StringSchema` - new string schema #### Response Example None ``` -------------------------------- ### Split Schema Discovery for Training and Testing Datasets Source: https://github.com/dataunitylab/jsonoid-discovery/blob/main/_autodocs/README.md Perform schema discovery on a dataset and split the results into training and testing schemas. The training schema can then be expanded to incorporate information from the testing schema. ```Scala val (trainSchema, testSchema) = DiscoverSchema.splitDiscover(jsons, 0.8) val expanded = trainSchema.expandTo(Some(testSchema)) ``` -------------------------------- ### Get Detected Format Hint Source: https://github.com/dataunitylab/jsonoid-discovery/blob/main/_autodocs/api-reference/string-schema.md Retrieves the detected format hint (e.g., 'date', 'email') from a StringSchema's properties. This method is useful for understanding the semantic type of the string data. ```scala def getFormat(): Option[String] ``` ```scala val schema = StringSchema("2024-01-15") implicit val params = JsonoidParams() val format = schema.properties.getOrNone[FormatProperty].format // Returns Some("date") ``` -------------------------------- ### Inferring Enum Constraints with EnumTransformer Source: https://github.com/dataunitylab/jsonoid-discovery/blob/main/_autodocs/api-reference/transformers.md Use EnumTransformer to convert a small set of example values into enum constraints within a schema. This transformer is enabled by default and examines string and number values from ExamplesProperty. ```scala import io.github.dataunitylab.jsonoid.discovery.transformers._ import io.github.dataunitylab.jsonoid.discovery._ import io.github.dataunitylab.jsonoid.discovery.schemas._ implicit val params = JsonoidParams() val schema = StringSchema("red") // After discovering "red", "green", "blue" val transformed = EnumTransformer.transformSchema(schema) // Result: EnumSchema with {"enum": ["red", "green", "blue"]} ``` -------------------------------- ### JSON Schema Draft 2020-12 Output Format Source: https://github.com/dataunitylab/jsonoid-discovery/blob/main/_autodocs/README.md This is an example of the JSON Schema draft 2020-12 format generated by JSONoid. It includes basic types, object properties, arrays, required fields, and definitions. ```json { "$schema": "https://json-schema.org/draft/2020-12/schema", "type": "object", "properties": { "id": {"type": "integer", "minimum": 1, "maximum": 100}, "email": {"type": "string", "format": "email"}, "created": {"type": "string", "format": "date-time"}, "tags": { "type": "array", "items": {"type": "string"}, "minItems": 0, "maxItems": 10, "uniqueItems": true } }, "required": ["id", "email"], "additionalProperties": false, "$defs": { "Address": { "type": "object", "properties": { "street": {"type": "string"}, "city": {"type": "string"} } } } } ``` -------------------------------- ### NumberSchema Constructor Source: https://github.com/dataunitylab/jsonoid-discovery/blob/main/_autodocs/api-reference/numeric-schemas.md Creates a NumberSchema from a sample decimal value. It requires the sample value and implicit JsonoidParams for configuration. ```APIDOC ## NumberSchema Constructor ### Description Creates a NumberSchema from a sample decimal value. ### Method Signature ```scala def apply(value: BigDecimal)(implicit p: JsonoidParams): NumberSchema ``` ### Parameters #### Path Parameters - **value** (BigDecimal) - Required - Sample decimal value - **p** (JsonoidParams) - Required (implicit) - Configuration parameters ### Request Example ```scala implicit val params = JsonoidParams() val schema = NumberSchema(3.14159) ``` ``` -------------------------------- ### JsonoidSpark CLI Source: https://github.com/dataunitylab/jsonoid-discovery/blob/main/_autodocs/api-reference/spark-api.md Provides a command-line interface for running schema discovery on Spark. ```APIDOC ## JsonoidSpark CLI ### Description The `JsonoidSpark` object provides a command-line interface for running schema discovery on Spark. ### Usage ```bash spark-submit --class io.github.dataunitylab.jsonoid.discovery.spark.JsonoidSpark \ jsonoid-discovery-.jar \ [options] ``` ### Command Line Options | Option | Short | Description | |--------|-------|-------------| | `--help` | `-h` | Show help message | | `--prop ` | `-p` | Property set: All, Min, Simple (default: All) | | `--add-definitions` | `-d` | Extract definitions from schema | | `--detect-dynamic` | `-y` | Detect dynamic object keys | | `--detect-disjoint` | `-j` | Detect disjoint object types | | `--tree-reduce` | `-t` | Use tree reduction instead of standard reduce | ### Examples **Basic discovery from HDFS:** ```bash spark-submit --class io.github.dataunitylab.jsonoid.discovery.spark.JsonoidSpark \ jsonoid-discovery.jar \ hdfs://path/to/data.ndjson ``` **With simplified property set and tree reduction:** ```bash spark-submit --class io.github.dataunitylab.jsonoid.discovery.spark.JsonoidSpark \ jsonoid-discovery.jar \ -p Simple \ -t \ s3://bucket/data.ndjson ``` **With definitions extraction:** ```bash spark-submit --class io.github.dataunitylab.jsonoid.discovery.spark.JsonoidSpark \ jsonoid-discovery.jar \ -p All \ -d \ /local/path/data.ndjson ``` ``` -------------------------------- ### JsonoidSpark CLI: Extract Definitions Source: https://github.com/dataunitylab/jsonoid-discovery/blob/main/_autodocs/api-reference/spark-api.md Executes schema discovery and extracts definitions from the schema. Supports local file paths. ```bash spark-submit --class io.github.dataunitylab.jsonoid.discovery.spark.JsonoidSpark \ jsonoid-discovery.jar \ -p All \ -d \ /local/path/data.ndjson ``` -------------------------------- ### Create NumberSchema from a sample value Source: https://github.com/dataunitylab/jsonoid-discovery/blob/main/_autodocs/api-reference/numeric-schemas.md Instantiates a NumberSchema using a BigDecimal value. Implicit JsonoidParams are required for configuration. ```scala implicit val params = JsonoidParams() val schema = NumberSchema(3.14159) ``` -------------------------------- ### DiscoverSchema API Source: https://github.com/dataunitylab/jsonoid-discovery/blob/main/_autodocs/MANIFEST.md The main entry point for schema discovery. Provides methods to discover schemas from various sources and transform them. ```APIDOC ## DiscoverSchema API ### Description Provides methods for discovering JSON schemas from data sources and performing transformations on them. ### Methods - **discover(source, params)**: Discovers a schema from a given data source. - **discoverFromValue(value, params)**: Discovers a schema from a single JSON value. - **splitDiscover(source, params)**: Performs a two-part discovery process on a data source. - **jsonFromSource(source)**: Reads JSON data from a specified source. - **transformSchema(schema, transformer, params)**: Applies a transformation to an existing schema. ``` -------------------------------- ### Property Access Patterns Source: https://github.com/dataunitylab/jsonoid-discovery/blob/main/_autodocs/api-reference/string-schema.md Demonstrates how to access various properties of a StringSchema using the SchemaProperties API. ```APIDOC ## Property Access Patterns Access StringSchema properties using the SchemaProperties API: ```scala val schema = StringSchema("test@example.com") implicit val params = JsonoidParams() // Get detected format val format = schema.properties.getOrNone[FormatProperty].format // Some("email") // Get pattern val pattern = schema.properties.getOrNone[PatternProperty].pattern // Some(".*@.*\\.") // Get length bounds val minLength = schema.properties.getOrNone[MinLengthProperty].minLength val maxLength = schema.properties.getOrNone[MaxLengthProperty].maxLength // Get examples val examples = schema.properties.getOrNone[ExamplesProperty].examples // Get length histogram (AllProperties only) val histogram = schema.properties.getOrNone[LengthHistogramProperty].histogram ``` ``` -------------------------------- ### Create StringSchema from Sample Value Source: https://github.com/dataunitylab/jsonoid-discovery/blob/main/_autodocs/api-reference/string-schema.md Constructs a StringSchema by inferring properties from a single sample string. This is useful for initial schema creation. ```scala import io.github.dataunitylab.jsonoid.discovery._ import io.github.dataunitylab.jsonoid.discovery.schemas._ implicit val params = JsonoidParams() val schema = StringSchema("hello@example.com") ``` -------------------------------- ### Using Implicit Default Params Source: https://github.com/dataunitylab/jsonoid-discovery/blob/main/_autodocs/configuration.md Shows how to use the implicit default `JsonoidParams` for schema discovery. The `DiscoverSchema.discover` function will automatically use the implicit instance if no explicit parameters are provided. ```scala // Uses implicit default JsonoidParams() val schema = DiscoverSchema.discover(jsonIterator) ``` -------------------------------- ### Write Value Table from Schema Source: https://github.com/dataunitylab/jsonoid-discovery/blob/main/_autodocs/api-reference/utilities.md Demonstrates writing a discovered schema's values into a tab-separated values (TSV) format to an output stream. Requires importing necessary classes. ```scala import io.github.dataunitylab.jsonoid.discovery._ import java.io.FileOutputStream val schema = ... // discovered schema val output = new FileOutputStream("values.tsv") ValueTableGenerator.writeValueTable(schema, output) ``` -------------------------------- ### Access ProductSchema Properties Source: https://github.com/dataunitylab/jsonoid-discovery/blob/main/_autodocs/api-reference/other-schemas.md Retrieve the product type (e.g., OneOf, AnyOf, AllOf) and the list of alternative schemas from a ProductSchema's properties. ```scala val typesProp = schema.properties.get[ProductSchemaTypesProperty] val productType = typesProp.productType // OneOf, AnyOf, or AllOf val schemas = typesProp.types // Alternative schemas ``` -------------------------------- ### AnySchema Constructor Source: https://github.com/dataunitylab/jsonoid-discovery/blob/main/_autodocs/api-reference/other-schemas.md Creates an AnySchema with no restrictions. This schema represents any value, equivalent to `true` in JSON Schema, and is used as a default when no type information is available. ```APIDOC ## AnySchema Constructor ### Description Creates an AnySchema with no restrictions. This schema represents any value, equivalent to `true` in JSON Schema, and is used as a default when no type information is available. ### Method `apply` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters Table | Parameter | Type | Required | Default | Description | |-----------|------|----------|---------|-------------| | p | JsonoidParams | Yes (implicit) | — | Configuration parameters | ### Request Example ```scala implicit val params = JsonoidParams() val schema = AnySchema() ``` ### Response #### Success Response - **AnySchema**: An instance of AnySchema. #### Response Example ```json true ``` ### Source `src/main/scala/io/github/dataunitylab/jsonoid/discovery/schemas/AnySchema.scala` ``` -------------------------------- ### Create IntegerSchema from a sample value Source: https://github.com/dataunitylab/jsonoid-discovery/blob/main/_autodocs/api-reference/numeric-schemas.md Instantiates an IntegerSchema using a BigInt value. Implicit JsonoidParams are required for configuration. ```scala implicit val params = JsonoidParams() val schema = IntegerSchema(42) ``` -------------------------------- ### getFormat Source: https://github.com/dataunitylab/jsonoid-discovery/blob/main/_autodocs/api-reference/string-schema.md Retrieves the detected format hint for a StringSchema, such as 'date' or 'email'. ```APIDOC ## getFormat ### Description Returns the detected format hint if any. ### Method ```scala def getFormat(): Option[String] ``` ### Returns `Option[String]` - format name or None ### Example ```scala val schema = StringSchema("2024-01-15") implicit val params = JsonoidParams() val format = schema.properties.getOrNone[FormatProperty].format // Returns Some("date") ``` ```