-
Notifications
You must be signed in to change notification settings - Fork 56
Conversation
… remaining description is not a new node
Actually, I wanted to ask you about what to do for that issue. https://app.apiary.io/sandbox22/editor |
What is the issue? Please provide concise information when asking such a question. |
Regarding Unexpected nodes with keywords do not stop the parsing: Objective
Break current section parser's parsing on keyword-defining section nodes that are not nested to the current node section. SolutionEvery section must define it's nested sections recursively (that is – including nested sections nested sections) Code
NOTE: The code snippets shown above are to demostrate proof of concenpt – feel free to shuffle and rename variables, types and function names as weel as adding any further improvements. The test accompanying this is: TEST_CASE("Parsing unexpected blocks", "[blueprint][now]")
{
mdp::ByteBuffer source = \
"FORMAT: 1A\n"\
"\n"\
"# S\n"\
"\n"\
"Hello\n"\
"\n"\
"+ Response\n"\
"\n"\
"Moar text\n"\
"\n"\
"# GET /\n";
Blueprint blueprint;
Report report;
parse(source, 0, report, blueprint);
REQUIRE(report.error.code == Error::OK);
REQUIRE(report.warnings.size() == 1); // no response
REQUIRE(report.warnings[0].code == EmptyDefinitionWarning);
REQUIRE(blueprint.name == "S");
REQUIRE(blueprint.description == "Hello\n\n+ Response\n\nMoar text\n\n");
REQUIRE(blueprint.metadata.size() == 1);
REQUIRE(blueprint.metadata[0].first == "FORMAT");
REQUIRE(blueprint.metadata[0].second == "1A");
REQUIRE(blueprint.resourceGroups.size() == 1);
REQUIRE(blueprint.resourceGroups[0].resources.size() == 1);
REQUIRE(blueprint.resourceGroups[0].resources[0].actions.size() == 1);
REQUIRE(blueprint.resourceGroups[0].resources[0].uriTemplate == "/");
REQUIRE(blueprint.resourceGroups[0].resources[0].actions[0].method == "GET");
} |
It would be good to issue a warning when parser treats a keyword defined section as a description. For this the return value of |
There is only more issue left to fix which I encountered yesterday. Meanwhile please review.