#include <Pt/Mcp/Type.h>
JSON object schema with named properties. More...
Inherits Type.
Public Types | |
| enum | TypeId { Null = 0 , Integer = 1 , Number = 2 , String = 3 , Boolean = 4 , Object = 5 , Array = 6 } |
| JSON Schema kind of a Type. More... | |
Public Member Functions | |
| ObjectType () | |
| Creates an empty object schema. | |
| ~ObjectType () | |
| Destroys the object schema. | |
| ObjectType & | addProperty (const std::string &name, const Type &type, const std::string &description="") |
| Adds a required property named name of type. | |
| ObjectType & | setOptional (const std::string &name) |
| Marks the property named name as optional. | |
| ObjectType & | setStrict () |
| Forbids properties that are not listed in the schema. | |
| const std::vector< Property > & | properties () const |
| Returns the properties of this object schema. | |
| bool | isStrict () const |
| Returns true when additional properties are forbidden. | |
| void | toSchema (std::ostream &os, const std::string &description="") const override |
| Writes this object as a JSON Schema object to os. | |
| TypeId | typeId () const |
| Returns the JSON Schema kind of this type. | |
ObjectType is a composed Type whose schema is a JSON object. addProperty() appends a required property. setOptional() makes an existing property optional by name; a name that is not present is ignored. setStrict() writes additionalProperties as false so undeclared members are rejected.
Each property stores a pointer to its Type. Those types must outlive this object type. The object type must outlive every Tool that uses it as a parameter.
|
inherited |
| ObjectType & addProperty | ( | const std::string & | name, |
| const Type & | type, | ||
| const std::string & | description = "" ) |
description is the schema description of the property.