Skip to content
This repository has been archived by the owner on Nov 8, 2024. It is now read-only.

Support top level Reference Element when translating API Elements to JSON & JSON Schema #710

Merged
merged 3 commits into from
May 31, 2019

Conversation

tjanc
Copy link
Contributor

@tjanc tjanc commented May 31, 2019

Fixes #709 .

so::Object& renderSchema(so::Object& schema, const IElement& e, TypeAttributes options);

template <typename T>
void renderProperty(ObjectSchema&, const T& e, so::Object&, TypeAttributes)
{
LOG(error) << "invalid property element: " << e.element();
assert(false);
abort();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain the rationale behind changing assert to abort please, not sure I understand the reason

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we want to avoid continuing the program flow because we should never arrive there. Specifically, bug #709 caused a SIGSEGV by overflowing the stack through unchecked recursion - with an abort here, there would be the much nicer SIGABORT.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, perhaps it would be better to avoid exiting the process though? Perhaps throwing std::exception would be better, the drafter_parse/validate function could catch and return appropriate error to caller?

@@ -284,6 +285,12 @@ namespace
return renderValue(*merged, options);
}

so::Value renderValueSpecific(const RefElement& element, TypeAttributes options)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder, could there be other cases where we would render a ref element outside an enum here? Trying to understand if there is perhaps some other test-coverage we should add for other types.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we should explore that. Also, minim has that generateValue function that probably manifests the same bug.

@tjanc tjanc merged commit 8d6762d into master May 31, 2019
@tjanc tjanc deleted the tjanc/fix-709 branch July 17, 2019 14:56
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enum with include causes segmentation fault
2 participants