-
Notifications
You must be signed in to change notification settings - Fork 306
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
FISH-663 MicroProfile OpenAPI 2.0 (MP 4.0) #5065
Conversation
Upgraded the dependencies and fixed compilation errors. Signed-off-by: Matthew Gill <[email protected]>
All data returned from the API should be deterministically ordered, so all HashMaps have been replaced with LinkedHashMap. Signed-off-by: Matthew Gill <[email protected]>
For some reason, the upgrade is causing the ContentImpl instance to be counted as not-empty, which is causing the current serialization inclusion settings to include it. This breaks several classes and tests that expect any items with $ref tags to be otherwise empty (but it contains 'content: {}'). This commit changes the inclusion settings to disable this behaviour. Signed-off-by: Matthew Gill <[email protected]>
Some errors were thrown at runtime, so a new test has been added and they have been patched. Signed-off-by: Matthew Gill <[email protected]>
If a Schema was declared in the OpenAPIDefinition, the @Schema class annotations would totally replace the initial definition. It is now merged correctly. Signed-off-by: Matthew Gill <[email protected]>
The TCK now checks that the get*() methods return immutable types. Signed-off-by: Matthew Gill <[email protected]>
The set methods would allow you to set unserializable types or types such as unmodifiableCollections which could cause issues. Signed-off-by: Matthew Gill <[email protected]>
The node was printed, but not the context for the node. The errors now print the OpenAPI document, with all the problems added as causes. Signed-off-by: Matthew Gill <[email protected]>
If a property Schema had a ref, type=OBJECT was still added. A check has now been added for this. Signed-off-by: Matthew Gill <[email protected]>
The TCK requires that the collections be nullable, where it wasn't previously possible. Technically only one collection is tested, but in the name of consistency, this functionality has been replicated everywhere. The collection types have also been abstracted, to allow them to be changed if required. Signed-off-by: Matthew Gill <[email protected]>
Prevent scanning all Config API Properties multiple times. The methods have been refactored to take less time to scan for OpenAPI properties. Signed-off-by: Matthew Gill <[email protected]>
Config Properties that specify schema objects are now parsed and included in the final object. Schema objects with parents also include all the parent class properties. Signed-off-by: Matthew Gill <[email protected]>
The extractAnnotations methods hadunused variables, which have been removed. The ServerVariables weren't being added as they were being added directly, then replaced with a blank map. This has been fixed, as well as the UnmodifiableCollection modification issues caused by fixing it. Signed-off-by: Matthew Gill <[email protected]>
OpenAPI should now scan and handle exception mappers. content annotation values with only one @content value now set the content value immediately, as they assume they're the only one. Signed-off-by: Matthew Gill <[email protected]>
Signed-off-by: Matthew Gill <[email protected]>
When parsing the @parameters annotation, the information wouldn' be retained as the method looks for the result of @PathParam etc, which hasn't been parsed as the method annotations are found first. The Schema implementation handling is done earlier, to allow annotation values to override the implementation class information. Signed-off-by: Matthew Gill <[email protected]>
Schemas created as part of a @callback annotation didn't parse the implementation properly. The implementation logic is now performed as part of the initial creation, and also uses the ARRAY type properly. Signed-off-by: Matthew Gill <[email protected]>
The TCK passes JSON in uppercase to the format query parameter to test it. The field isnow case insensitive. Signed-off-by: Matthew Gill <[email protected]>
Implemented annotation parsing for the new annotation. Signed-off-by: Matthew Gill <[email protected]>
Properties marked as 'required' weren't added correctly to their parent schemas. Signed-off-by: Matthew Gill <[email protected]>
@Schema annotations are now parsed correctly when attached to accessor methods. @XmlRootElement annotations are also now allowed to denote Schema classes. Signed-off-by: Matthew Gill <[email protected]>
Signed-off-by: Matthew Gill <[email protected]>
Enums were including HK2 data in the enumeration object, rather than the enum value name. This commit tests and fixes this behaviour. Signed-off-by: Matthew Gill <[email protected]>
Sad panda |
I've just realised, this comes with an HK2 patch! |
Upgraded HK2 to support exception type parsing Signed-off-by: Matthew Gill <[email protected]>
Indices in paths should be accessed by using square brackets. The syntax without this is ambiguous ans interferes with fetching response codes e.g. 500 as this will be interpreted as an index in the array. Signed-off-by: Matthew Gill <[email protected]>
When encountered in the wrong order, exception mappers weren't respected. @APIResponseSchema also broke on exception mappers. This commit fixes this basic behaviour. Signed-off-by: Matthew Gill <[email protected]>
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.
Haven't gone through the code with a fine-toothed comb, but passes the OpenAPI TCK and seems to work.
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.
Partial review as Andrew got there before me.
No required changes, but some cleanup suggestions. There's a lot of superfluous null checking going on.
...rofile/openapi/src/main/java/fish/payara/microprofile/openapi/impl/model/ComponentsImpl.java
Show resolved
Hide resolved
...rofile/openapi/src/main/java/fish/payara/microprofile/openapi/impl/model/ExtensibleImpl.java
Show resolved
Hide resolved
...rofile/openapi/src/main/java/fish/payara/microprofile/openapi/impl/model/ExtensibleImpl.java
Outdated
Show resolved
Hide resolved
...roprofile/openapi/src/main/java/fish/payara/microprofile/openapi/impl/model/OpenAPIImpl.java
Outdated
Show resolved
Hide resolved
...pi/src/main/java/fish/payara/microprofile/openapi/impl/model/parameters/RequestBodyImpl.java
Outdated
Show resolved
Hide resolved
The server add function had reasonably high complexity, which has been reduced. ExtensibleImpl had been missed in the mass collection fix, so this has been kept consistent with the rest of the collection methods. Signed-off-by: Matthew Gill <[email protected]>
ContentImpl merge function was being used in creation of Contents, which causes the code to be entangled and difficult to debug. There was no reason to merge them, so they've been replaced with simpler add functions. Signed-off-by: Matthew Gill <[email protected]>
jenkins test please |
FISH-663 MicroProfile OpenAPI 2.0 (MP 4.0)
FISH-663 MicroProfile OpenAPI 2.0 (MP 4.0)
Description
This is an improvement, upgrading our implementation of MicroProfile OpenAPI to version 2.0
Changes include:
mp.openapi.schema.*
MicroProfile Config property has been added to allow the schema for a specific class to be specified. This property would typically be used in cases where the application developer does not have access to the source code of a classThe TCK has been upgraded in various places, meaning that not all of the changes here are strictly due to new behaviour.
Important Information
HK2 has received a patch to now parse exception types when creating MethodModels. This was needed as exception mappers are now supported in OpenAPI (they may have been expected before, but not implemented).
Patched source: payara/patched-src-hk2#19
Patched artifact: payara/Payara_PatchedProjects#352
Testing
New tests
TCK Upgrade: payara/MicroProfile-TCK-Runners#132
Testing Performed
Ran the new TCK. OpenAPI is reasonably isolated, so there shouldn't bean affect on many other tests.
Notes for Reviewers
I've disabled a TCK test and raised an upstream issue for it. I don't believe it's intended, and it shouldn't affect or compatibility.
This PR also fixes #4955 (FISH-760)