-
Notifications
You must be signed in to change notification settings - Fork 568
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
Use MP OpenAPI 1.2 and adapt to SmallRye OpenAPI 2.0.26 which supports it #3294
Conversation
@@ -37,7 +37,7 @@ paths: | |||
type: integer | |||
format: int32 | |||
responses: | |||
200: | |||
'200': |
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.
Is this required? This seems like quite a big backward incompatible change - if somebody uses numbers in current version, will this fail?
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.
A document which excludes the quotes around the HTTP status codes for response is in violation of the OpenAPI spec: https://swagger.io/specification/#responses-object:
HTTP status code field: ...This field MUST be enclosed in quotation marks (for example, "200") for compatibility between JSON and YAML.
Our test file should never have omitted the quotation marks. That said, in the past we would accept this error in documents. I am looking at how complicated it would be to customize the parsing to continue to accept this type of error (and log warnings as we do so).
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.
Flagging these with warnings while accepting them is relatively simple. Another push will arrive shortly.
…uments (they should be quoted)
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
I am seeing intermittent failures in an OpenAPI MP test, both in the pipelines and locally. The symptom is that during |
…set the 'openapi' element when merging documents (because SmallRye skips that during merge)
…annotation processing, add some logging, and use method reference instead of a lambda
…r reporting in TestUtil, and update pom.xml for testing changes
The preceding commits took care of the intermittent test failures. |
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
Resolves #2671
Adopting MP OpenAPI 1.2 is simple in concept. There were no API changes.
We have been layering on SmallRye's OpenAPI implementation 1.x, and SmallRye built against MP OpenAPI 1.2 only starting with 2.0.26. That means we needed to step up to that release also.
There were several API changes in the SmallRye implementation, but almost all are internal to our code.
Customer-visible changes
Backward-incompatible changes
OpenAPI documents permit the use of
$ref
in input and output declarations to point to definitions elsewhere, rather than in-lining them (perhaps repeatedly). SmallRye used to support a config flag to disable that but in 2.0.26 that support is always on.Helidon exposed an OpenAPI config setting
schema-references.enable
for this. With this PR Helidon logs a warning if the user sets this to any value, announcing that references are always supported now.We expect it is extremely rare that users would have set this value, and even rarer that they would have set it to
false
. This should be a minimal-impact change.To preserve the behavior, we would have to add significant code in Helidon's OpenAPI implementation to disable
$ref
and the cost seems far higher than the benefit.An internal Helidon class
OpenAPIConfigImpl
implements a SmallRye OpenAPI interface. That interface has changed four method return types fromSet<String>
toPattern
and removed two methods. This Helidon class ispublic
inhelidon/openapi
only so our code inhelidon/microprofile/openapi
can use it. In fact, it resides in theio.helidon.openapi.internal
package (which, yes, goes against our coding conventions but turns out to be useful for situations such as this!) to reinforce that users should not use it. Users have no need to use this class directly, in fact.We will document these changes in a release note with 2.4.0 but impact on real users is very unlikely.
New warnings
Earlier releases of Helidon silently accepted illegal OpenAPI documents which did not enclose HTTP status values (keys in the
responses
section` in quotes. The OpenAPI spec says they should be quoted.With this PR, Helidon will continue to accept such documents but will log warnings about unquoted HTTP status values.
Changes in SmallRye -> Changes in Helidon
Here are the changes in SmallRye and, in parentheses, the Helidon files that changed as a result.
io.smallrye.openapi.core
artifact/module (pom.xml
,module-info.java
).Format
class fromOpenApiSerializer
to its own class (OpenAPISupport
).MergeUtil.merge
method which combines two in-memory OpenAPI models now skips theopenapi
element in the input models, so we have to supply it ourselves explicitly in the resulting new document. (OpenAPISupport
).OpenApiAnnotationScanner#scan
changed its return type fromOpenAPIImpl
toOpenAPI
(OpenAPISupport
).OpenAPIConfig
supported a setting to control whether$ref
references were followed or not, defaulted totrue
. This is not a standard setting from the MP OpenAPI spec. We let users assign this setting in previous Helidon releases, but because SmallRye no longer honors it we cannot either. It is very unlikely that users would have turned this off, but the PR preserves the now-obsolete methods and logs a warning if the user explicitly sets the value, either via the API directly (they should not be using the class anyway) or in config. (OpenAPIConfigImpl
)ReferenceImpl
class changed field name from$ref
toref
. (ExpandedTypeDescription
,ImplTypeDescription
,Serializer
, new tests)Set<String>
, but now they arePattern
s. Helidon never exposed this to users, except via an internal public class which users should not ever use. (OpenAPIConfigImpl
,MPOpenAPIBuilder
)Signed-off-by: [email protected] [email protected]