JSON Schema
json-schema.org โบ understanding-json-schema โบ reference โบ type
JSON Schema - Type-specific Keywords
The type keyword is fundamental to JSON Schema because it specifies the data type that a schema should expect.
Cswr
cswr.github.io โบ JsonSchema โบ spec โบ basic_types
Basic Types - JSON Schema
JSON Documents can be either basic values (strings, numbers, integers, the boolean constants or null), or ordered or unordered list of key:value pairs. We can use JSON Schema to specify that documents can be any of these. For now we concentrate on the specification for values.
JSON SCHEMA: Can we do an either/or (string/int) for type? - Stack Overflow
I'm doing a schema to validate contact information. In the phone number validation, we have a country code. I am really hoping there's a way to allow the country code to either be a string or an in... More on stackoverflow.com
It's 2023. Your API should have a schema
"It's {Current Year}" is the least compelling thing to put in the title I can think of. Maybe my API should have a schema, but looking at my calendar will give me no valid reasons as to why. More on reddit.com
JSON Schema Registry : r/webdev
Json schema form UI builder library
I think you're looking for formly: https://formly.dev/ More on reddit.com
Videos
PyPI
pypi.org โบ project โบ types-jsonschema
types-jsonschema ยท PyPI
This is a type stub package for the jsonschema package. It can be used by type checkers to check code that uses jsonschema.
ยป pip install types-jsonschema
JSON Schema
json-schema.org โบ understanding-json-schema โบ reference โบ numeric
JSON Schema - Numeric types
There are two numeric types in JSON Schema: integer and number. They share the same validation keywords ยท JSON has no standard way to represent complex numbers, so there is no way to test for them in JSON Schema
JSON Schema
json-schema.org โบ understanding-json-schema โบ reference
JSON Schema reference
Master the full power of JSON Schema with our reference documentation. From basic data types to advanced techniques like conditional validation and schema composition, you will learn everything about JSON Schema keywords through clear explanations and examples.
npm
npmjs.com โบ package โบ @types โบ json-schema
types/json-schema
November 7, 2023 - TypeScript definitions for json-schema. Latest version: 7.0.15, last published: 2 years ago. Start using @types/json-schema in your project by running `npm i @types/json-schema`. There are 697 other projects in the npm registry using @types/json-schema.
ยป npm install @types/json-schema
Published ย Nov 07, 2023
Version ย 7.0.15
Repository ย https://github.com/DefinitelyTyped/DefinitelyTyped
Cswr
cswr.github.io โบ JsonSchema โบ spec โบ multiple_types
Multiple Types - JSON Schema
So far we have only described how to specify types uniquely. But we could also specify that a certain document may be any number of types, such as string or integer, object or array, etc ยท The basic declaration of multiple types is through the "type" keyword, where we can now have an array ...
Hackage
hackage.haskell.org โบ package โบ json-schema-0.7.4.2 โบ docs โบ Data-JSON-Schema-Types.html
Data.JSON.Schema.Types
Types for defining JSON schemas. Synopsis ยท class JSONSchema a where ยท data Schema ยท = Choice [Schema] | Object [Field] | Map Schema ยท | Array LengthBound Bool Schema ยท | Tuple [Schema] | Value LengthBound ยท | Boolean ยท | Number Bound ยท | Constant Value ยท
GitHub
github.com โบ bwaidelich โบ types-jsonschema
GitHub - bwaidelich/types-jsonschema: Generator for JSON Schema files from PHP classes, see https://json-schema.org/
Integration for the wwwision/types package that allows to generate JSON Schema files from PHP code ... class Contact { public function __construct(public string $name, public int $age) {} } $schema = (new JsonSchemaGenerator())->fromClass(Contact::class); $expected = <<<JSON { "type": "object", "properties": { "name": { "type": "string" }, "age": { "type": "integer" } }, "additionalProperties": false, "required": [ "name", "age" ] } JSON; assert(json_encode($schema, JSON_PRETTY_PRINT) === $expected);
Author ย bwaidelich
JSON Schema
json-schema.org โบ understanding-json-schema โบ basics
JSON Schema - The basics
Of course, we wouldn't be using JSON Schema if we wanted to just accept any JSON document. The most common thing to do in a JSON Schema is to restrict to a specific type.
JSON Schema
json-schema.org โบ draft โบ 2020-12 โบ json-schema-core
JSON Schema: A Media Type for Describing JSON Documents
JSON Schema defines the media type "application/schema+json", a JSON-based format for describing the structure of JSON data. JSON Schema asserts what a JSON document must look like, ways to extract information from it, and how to interact with it. The "application/schema-instance+json" media ...
Opis
opis.io โบ json-schema โบ 2.x โบ structure.html
JSON Schema structure | Opis JSON Schema
The Basics Structure Generic keywords String type Number type Integer type Boolean type Null type Object type Array type Formats Default value Conditional subschemas Multiple subschemas
MuleSoft
docs.mulesoft.com โบ dataweave โบ latest โบ dataweave-type-reuse-json-schema
Reusing Types from a JSON Schema | MuleSoft Documentation
Including the import directive from the above example in the script header loads all the existing types in the JSON schema. In import * from jsonschema!example::schema::Person, the only existing type is the Root type, specified at the root which describes an Object that can have three properties (firstName, lastName, and age).
jsonschema
python-jsonschema.readthedocs.io
jsonschema 4.26.0 documentation
>>> validate(instance={"name" : "Eggs", "price" : 34.99}, schema=schema) >>> validate( ... instance={"name" : "Eggs", "price" : "Invalid"}, schema=schema, ... ) Traceback (most recent call last): ... ValidationError: 'Invalid' is not of type 'number' It can also be used from the command line by installing check-jsonschema.
Top answer 1 of 2
18
You can validate multiple types using :
"type": ["integer", "string"]
More info: https://cswr.github.io/JsonSchema/spec/multiple_types/
2 of 2
1
You have several options, please have a look at the docs:
- Use pattern property, and use a regular expression to enforce valid code.
- Use anyOf with two schemas. Each schema will validate integer or string type.
- If you have all country codes (very easy to get) you might enforce exact values with an enum list.
TutorialsPoint
tutorialspoint.com โบ json โบ json_schema.htm
JSON - Schema
{ "$schema": "http://json-schema.org/draft-04/schema#", "title": "Product", "description": "A product from Acme's catalog", "type": "object", "properties": { "id": { "description": "The unique identifier for a product", "type": "integer" }, "name": { "description": "Name of the product", "type": "string" }, "price": { "type": "number", "minimum": 0, "exclusiveMinimum": true } }, "required": ["id", "name", "price"] }