11 #include "JSONUtils.h" 12 #include "utils/Variant.h" 21 class JSONSchemaTypeDefinition;
22 typedef std::shared_ptr<JSONSchemaTypeDefinition> JSONSchemaTypeDefinitionPtr;
39 bool Parse(
const CVariant &value,
bool isParameter =
false);
41 void Print(
bool isParameter,
bool isGlobal,
bool printDefault,
bool printDescriptions,
CVariant &output)
const;
42 void ResolveReference();
44 std::string missingReference;
75 std::vector<JSONSchemaTypeDefinitionPtr>
extends;
85 JSONSchemaType
type = AnyValue;
153 std::vector<JSONSchemaTypeDefinitionPtr>
items;
187 void add(
const JSONSchemaTypeDefinitionPtr& property);
189 typedef std::map<std::string, JSONSchemaTypeDefinitionPtr>::const_iterator JSONSchemaPropertiesIterator;
190 JSONSchemaPropertiesIterator begin()
const;
191 JSONSchemaPropertiesIterator find(
const std::string& key)
const;
192 JSONSchemaPropertiesIterator end()
const;
193 unsigned int size()
const;
195 std::map<std::string, JSONSchemaTypeDefinitionPtr> m_propertiesmap;
233 std::string missingReference;
248 TransportLayerCapability transportneed = Response;
268 bool parseParameter(
const CVariant& value,
const JSONSchemaTypeDefinitionPtr& parameter);
269 bool parseReturn(
const CVariant &value);
271 const JSONSchemaTypeDefinitionPtr&
type,
272 unsigned int position,
274 unsigned int& handled,
321 static bool AddType(
const std::string &jsonType);
330 static bool AddMethod(
const std::string &jsonMethod, MethodCall method);
338 static bool AddBuiltinMethod(
const std::string &jsonMethod);
346 static bool AddNotification(
const std::string &jsonNotification);
348 static bool AddEnum(
const std::string &
name,
const std::vector<CVariant> &values, CVariant::VariantType
type = CVariant::VariantTypeNull,
const CVariant &
defaultValue = CVariant::ConstNullVariant);
349 static bool AddEnum(
const std::string &name,
const std::vector<std::string> &values);
350 static bool AddEnum(
const std::string &name,
const std::vector<int> &values);
357 static const char* GetVersion();
368 static JSONRPC_STATUS Print(
CVariant &result,
ITransportLayer *transport,
IClient *client,
bool printDescriptions =
true,
bool printMetadata =
false,
bool filterByTransport =
true,
const std::string &filterByName =
"",
const std::string &filterByType =
"",
bool printReferences =
true);
388 static JSONSchemaTypeDefinitionPtr GetType(
const std::string &identification);
390 static void ResolveReferences();
391 static void Cleanup();
394 static bool prepareDescription(std::string &
description,
CVariant &descriptionObject, std::string &name);
395 static bool addMethod(
const std::string &jsonMethod, MethodCall method);
396 static void parseHeader(
const CVariant &descriptionObject);
397 static bool parseJSONSchemaType(
const CVariant &value, std::vector<JSONSchemaTypeDefinitionPtr>& typeDefinitions, JSONSchemaType &schemaType, std::string &missingReference);
398 static void addReferenceTypeDefinition(
const JSONSchemaTypeDefinitionPtr& typeDefinition);
399 static void removeReferenceTypeDefinition(
const std::string &typeID);
401 static void getReferencedTypes(
const JSONSchemaTypeDefinitionPtr&
type,
402 std::vector<std::string>& referencedTypes);
404 class CJsonRpcMethodMap
411 typedef std::map<std::string, JsonRpcMethod>::const_iterator JsonRpcMethodIterator;
412 JsonRpcMethodIterator begin()
const;
413 JsonRpcMethodIterator find(
const std::string& key)
const;
414 JsonRpcMethodIterator end()
const;
418 std::map<std::string, JsonRpcMethod> m_actionmap;
421 static CJsonRpcMethodMap m_actionMap;
422 static std::map<std::string, JSONSchemaTypeDefinitionPtr> m_types;
423 static std::map<std::string, CVariant> m_notifications;
426 typedef enum SchemaDefinition
428 SchemaDefinitionType,
429 SchemaDefinitionMethod
432 typedef struct IncompleteSchemaDefinition
435 SchemaDefinition Type;
437 } IncompleteSchemaDefinition;
439 typedef std::map<std::string, std::vector<IncompleteSchemaDefinition> > IncompleteSchemaDefinitionMap;
440 static IncompleteSchemaDefinitionMap m_incompleteDefinitions;
JSONSchemaTypeDefinitionPtr additionalProperties
Type definition for additional properties.
Definition: JSONServiceDescription.h:213
double minimum
Minimum value for Integer or Number types.
Definition: JSONServiceDescription.h:109
int maxLength
Maximum length for String types.
Definition: JSONServiceDescription.h:142
std::vector< JSONSchemaTypeDefinitionPtr > unionTypes
JSON schema type definitions in case of a union type.
Definition: JSONServiceDescription.h:91
Structure mapping a json rpc method definition to an actual method implementation.
Definition: JSONServiceDescription.h:283
int minLength
Minimum length for String types.
Definition: JSONServiceDescription.h:137
bool optional
Whether or not the parameter is optional.
Definition: JSONServiceDescription.h:97
std::vector< CVariant > enums
(Optional) List of allowed values for the type
Definition: JSONServiceDescription.h:148
std::string ID
Id of the type (for referenced types) Renamed from "id" because of possible issues with Objective-C...
Definition: JSONServiceDescription.h:58
std::vector< JSONSchemaTypeDefinitionPtr > items
List of possible values in an array.
Definition: JSONServiceDescription.h:153
Maps a properties name to its json schema type definition.
Definition: JSONServiceDescription.h:182
bool referencedTypeSet
Whether the type has been set based on the referenced type.
Definition: JSONServiceDescription.h:69
std::string description
Description of the method.
Definition: JSONServiceDescription.h:257
std::vector< JSONSchemaTypeDefinitionPtr > parameters
List of accepted parameters.
Definition: JSONServiceDescription.h:261
CJsonSchemaPropertiesMap properties
List of properties of the parameter (only needed when the parameter is an object) ...
Definition: JSONServiceDescription.h:202
unsigned int divisibleBy
Integer by which the value (of type Integer) must be divisible without rest.
Definition: JSONServiceDescription.h:132
Definition: AddonsOperations.h:23
std::string name
Name of the represented method.
Definition: JSONServiceDescription.h:238
Helper class for json schema service descriptor based service descriptions for the json rpc API...
Definition: JSONServiceDescription.h:310
Structure for a published json rpc method.
Definition: JSONServiceDescription.h:225
MethodCall method
Pointer tot he implementation of the represented method.
Definition: JSONServiceDescription.h:243
CVariant defaultValue
Default value of the parameter (only needed when it is optional)
Definition: JSONServiceDescription.h:103
Class for a parameter of a json rpc method.
Definition: JSONServiceDescription.h:34
double maximum
Maximum value for Integer or Number types.
Definition: JSONServiceDescription.h:114
JSONRPC_STATUS
Possible statuc codes of a response to a JSON-RPC request.
Definition: JSONRPCUtils.h:29
bool hasAdditionalProperties
Whether the type can have additional properties or not.
Definition: JSONServiceDescription.h:208
OperationPermission
Permission categories for json rpc methods.
Definition: JSONRPCUtils.h:56
std::string name
Name of the json rpc method.
Definition: JSONServiceDescription.h:288
bool exclusiveMaximum
Whether to exclude the defined Maximum value from the valid range or not.
Definition: JSONServiceDescription.h:126
std::vector< JSONSchemaTypeDefinitionPtr > extends
Array of reference types which are extended by this type.
Definition: JSONServiceDescription.h:75
JSONSchemaTypeDefinitionPtr returns
Definition of the return value.
Definition: JSONServiceDescription.h:265
unsigned int minItems
Minimum amount of items in the array.
Definition: JSONServiceDescription.h:158
bool uniqueItems
Whether every value in the array must be unique or not.
Definition: JSONServiceDescription.h:169
Definition: ITransportLayer.h:27
bool exclusiveMinimum
Whether to exclude the defined Minimum value from the valid range or not.
Definition: JSONServiceDescription.h:120
std::string description
Description of the parameter.
Definition: JSONServiceDescription.h:80
JSONSchemaType type
JSON schema type of the parameter's value.
Definition: JSONServiceDescription.h:85
std::string name
Name of the parameter (for by-name calls)
Definition: JSONServiceDescription.h:50
JSONSchemaTypeDefinitionPtr referencedType
Referenced object.
Definition: JSONServiceDescription.h:63
unsigned int maxItems
Maximum amount of items in the array.
Definition: JSONServiceDescription.h:163
std::vector< JSONSchemaTypeDefinitionPtr > additionalItems
List of json schema definitions for additional items in an array with tuple typing (defined schemas i...
Definition: JSONServiceDescription.h:176
Helper class containing utility methods to handle json rpc method calls.
Definition: JSONUtils.h:46
MethodCall method
Pointer to the actual implementation of the json rpc method.
Definition: JSONServiceDescription.h:294