question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TCK error - OASConfigExcludeClassesTest$testExcludedClasses requires incorrect OpenAPI document to pass

See original GitHub issue

TL;DR

To pass this TCK test (and perhaps others), the server must generate an OpenAPI document that conflicts with the conventional behavior as described in the JAX-RS spec and as implemented by at least some MicroProfile-compliant servers.

Specifically, the test requires that the OpenAPI document declare endpoints that the server does not, in fact, expose. This is a problem in that the TCK requires servers to produce incorrect OpenAPI documents.

Details

In the TCK test in the issue title, JAXRSApp$getSingletons returns four JAX-RS resource class instances:

  • AirlinesResource
  • AvailabilityResource
  • BookingResource
  • ReviewResource

The class does not override getClasses so the superclass implementation returns the empty set.

The JAX-RS spec https://jakarta.ee/specifications/restful-ws/3.0/jakarta-restful-ws-spec-3.0.html#servlet describes how servlet implementations must handle this:

if both Application.getClasses and Application.getSingletons return an empty collection then all root resource classes and providers packaged in the web application MUST be included

It continues (importantly):

If either getClasses or getSingletons returns a non-empty collection then only those classes or singletons returned MUST be included in the published JAX-RS application.

Of course, MicroProfile neither refers to nor implements servlets, but it is very reasonable for our users to expect MP-compliant servers to honor the JAX-RS semantics described there. Two server implementations I checked (OpenLiberty and Helidon) do so and I suspect so do others.

In contrast, the subject TCK test as written requires 10 path elements in the returned OpenAPI document. Two of the resources returned from JAXRSApp$getSingletonsReviewResource and AvailabilityResource–are excluded by the mp.openapi.scan.exclude.classes config setting used in the test. For the document to contain 10 path elements it must include the endpoints not only from AirlinesResource and BookingResource but also those from UserResource which is not represented in the return values from JAXRSApp$getResources or getSingletons. Including the UserResource endpoints would be expected if JAXRSApp overrode neither getClasses nor getSingletons but it does override getSingletons.

This test seems flawed in that:

  1. It requires the server to produce an OpenAPI document which conflicts with the behavior described in the JAX-RS spec.
  2. For servers which follow the semantics as described in the JAX-RS spec, to pass the TCK they must, in some cases, produce OpenAPI documents which conflict with the endpoints they actually expose.

There might be other tests with similar behavior.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
Emily-Jiangcommented, Nov 12, 2021

@MikeEdgar I am afraid it is too late. It can be done after the release. We can do a service release straightaway after MP 5.0. Please don’t push the changes until the final release is staged.

0reactions
Azqueltcommented, Feb 22, 2022

There are other tests which explicitly look for /user paths (e.g. AirlinesAppTest.testOperationUserResource), so I’ve opened #510 to add the UserResource class to the set of singletons.

Read more comments on GitHub >

github_iconTop Results From Across the Web

response validation allows schema to pass that has ... - GitHub
when I change response schema in OpenAPI documentation to test, if response validation works, and I execute it in swagger ui, I get...
Read more >
Fix OpenAPI annotation problems for GitLab REST API
Problem The module that generates the OpenAPI specification for the GitLab rest API doesn't prevent invalid documents from being generated.
Read more >
OpenAPI Specification - Version 3.0.3 - Swagger
The OpenAPI Specification defines a standard interface to RESTful APIs which allows both humans and computers to understand service capabilities without ...
Read more >
OpenAPI Specification v3.1.0 | Introduction, Definitions, & More
An OpenAPI document compatible with OAS 3.*.* contains a required openapi field which designates the version of the OAS that it uses.
Read more >
Usage - OpenAPI Generator
Pass the -s/--short option if you would like a CSV output for easy parsing. ... openapi-generator-cli validate -i petstore-v3.0-invalid.yaml.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found