-
Notifications
You must be signed in to change notification settings - Fork 562
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove dependency on Jackson via SmallRye - 1.x #1457
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…opyright, styles, etc.
…e model interface and impl classes
…ces (which the TCK's parser cannot handle)
…ather than a separate boolean managed from the code generated by the plug-in, in determining whether such a property exists and needs special handling
…module (out of plug-in)
…ata structures for enums
…pply only to SmallRye impl classes
romain-grecourt
previously approved these changes
Mar 4, 2020
ljnelson
previously approved these changes
Mar 4, 2020
ljnelson
approved these changes
Mar 9, 2020
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Not ready for approval yet -- need to update the
helidon-build-tools
version in the top-level Helidon pom once we have a newhelidon-build-tools
release.Overview - removing our dependency on Jackson
(fixes #1109)
Our OpenAPI implementation layers on SmallRye’s OpenAPI module, which on its own uses Jackson to parse the OpenAPI JSON or YAML and to parse the JSON in OpenAPI
@Extension
annotations. The SmallRye API has for some time allowed the calling code to — and Helidon now does — completely bypass the main parsing (doing so itself before invoking SmallRye), and a recent SmallRye enhancement allows the caller to provide its own way to do the@Extension
parsing.Removing the Jackson dependency involves three main areas of change:
helidon-build-tools
SnakeYAML plug-in, (merged separately)enhance the SnakeYAML-created object model for OpenAPI in important ways,
to parse YAML and JSON using SnakeYAML (rather than leaving that to SmallRye), and
driving the SmallRye API slightly differently to accomplish the above.
The plug-in
SnakeYAML does a good job identifying properties from the MicroProfile OpenAPI interfaces, but SnakeYAML cannot (nor can any tool that looks only at compiled byte code) build a complete map between the JSON/YAML serialization and the object model. The SnakeYAML API allows callers to provide this additional information.
The plug-in analyzes the MP OpenAPI interfaces and the SmallRye implementation classes and generates a class that includes this helper logic for SnakeYAML.
The Helidon OpenAPI module component
pom.xml
The pom:
dependency
plug-in to extract the source code for the MicroProfile OpenAPI interfaces and the SmallRye implementations, andhelidon-build-tools
SnakeYAML plug-in to generate the helper class.The Helidon OpenAPI changes
The new plug-in is independent of OpenAPI, yet there are some aspects of the OpenAPI interfaces and the SmallRye implementations that need special attention to correctly map between JSON/YAML and the object model. These adjustments to the model occur in the
OpenAPISupport#adjustTypeDescriptions
method.In MP OpenAPI 1.1.2, several interfaces extend
Map<X, Y>
. This “confuses” SnakeYAML slightly, in that when deserializing a document it instantiates anObject
for the children instead of the actual implementation class for the interfaceY
. MP OpenAPI seems to be abandoning this approach in 2.0, but we still need to deal with it now. That happens inCustomConstructor
.The SnakeYAML API relies heavily on the
TypeDescription
class for conveying non-default information about mapping between documents and the object model. In OpenAPI several interfaces have the same unusual needs, and those are collected in the Helidon OpenAPI-specificExpandedTypeDescription
class. (The class which the plug-in generates takes a type parameter which extendsTypeDescription
and a factory function for creating new instances of the desired type.)For parsing the OpenAPI
@Extension
annotation (always JSON), SmallRye accepts anAnnotationScannerExtension
which, among other things, supports theparseExtension
method. The Helidon version of this is based heavily on the source from SmallRye, the key difference being in how the JSON is parsed and handled. There might be ways of doing this with less code but patterning closely after the (working) SmallRye implementation that uses Jackson seemed wise.Oru custom
Serializer
class mostly sets SnakeYAML formatting configuration before invoking SnakeYAML’sYaml#dump
method to serialize the object model. We need to tailor some of the processing beyond what the config settings support, hence theCustomRepresenter
andTagSuppressingWriter
inner classes. Note that one of those customizations is to work around a bug in the MP OpenAPI TCK (see the comments in the code).