We value your input! Please participate in Archicad 28 Home Screen and Tooltips/Quick Tutorials survey
2021-07-11 08:58 PM - last edited on 2021-09-14 09:27 AM by Noemi Balogh
GS::Optional<GS::UniString>MyAddInCommand::GetInputParametersSchema() const { //ACAPI_WriteReport("inside keynotecommand getinputparamschema", true); return GS::UniString::Printf(R"({ "type": "object", "properties": { "%s": { "type": "string", "description": "The name of the Library Shape", "minLength": 1 } "%s": { "type": "integer", "description": "Text Pen Number.", "minLength": 1 }, }, "additionalProperties": false, "required": [ "%s" ] })", SymbolShapeParameterField, TextPenParameterField, SymbolShapeParameterField); // fails at "type" : "integer" ,Also will need types for boolean & Double
Solved! Go to Solution.
2021-07-12 01:19 PM
2021-07-12 10:35 AM
2021-07-12 01:19 PM
2021-07-13 03:27 PM
poco2013 wrote:I'm happy that you managed to solve the issue.
The problem in the above, which I did not see for the tenth time, is a misplaced comma.
{ "MyInputParametersSchema": { "type": "object", "properties": { "shapeName": { "type": "string", "description": "The name of the Library Shape", "minLength": 1 }, "pen": { "type": "integer", "description": "Text Pen Number.", "minLength": 1 } }, "additionalProperties": false, "required": [ "shapeName", "pen" ] }, "MyResponseSchema": { "type": "object", "properties": { "error": { "$ref": "APITypes.json#/definitions/Error" } }, "additionalProperties": false, "required": [] } }Add it as a DATA resource into your GRC file:
'DATA' 1000 "JSON file containing the JSON schemas of commands" { "JSONSchemas.json" }Finally read the JSON resource from your C++ code:
GS::Optional<GS::UniString> MyJSONCommand::GetSchemaDefinitions () const { GSHandle myJSONFileContent = RSLoadResource ('DATA', ACAPI_GetOwnResModule (), 1000); return GS::UniString (*myJSONFileContent); } GS::Optional<GS::UniString> MyJSONCommand::GetInputParametersSchema () const { return GS::UniString (R"({ "$ref": "#/MyInputParametersSchema" })"); } GS::Optional<GS::UniString> MyJSONCommand::GetResponseSchema () const { return GS::UniString (R"({ "$ref": "#/MyResponseSchema" })"); }
2021-07-13 05:25 PM