Skip to content
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

Fix SmallRye Health OpenAPI definitions #42480

Merged
merged 1 commit into from
Aug 14, 2024

Conversation

frne
Copy link
Contributor

@frne frne commented Aug 12, 2024

The quarkus-smallrye-health extension exposes an openapi definition for the health endpoints it provides. The current implementation exposes a wrong schema that doesn't reflect the actual structure of the returned JSON.

Problem Statement

Since the openapi schema does not match the implementation, a JSON object is returned that does not adhere to the interface documentation. Especially in code generation use cases, this leads to errors that are difficult to debug / understand for implementers.

Current schema

The schema exposed by the current implementation renders to something similar to:

{
  "data": {},
  "name": "string",
  "status": "DOWN"
}

Issues with the current schema:

  • The health response object only has statusand checks properties (source)
  • Properties name and data will not be used in the top-level response (source)
  • The checks property in the top-level response schema is missing completely (source, source)
  • The checks entries have a defined object schema of name, status and data, that is currently not reflected in the schema (source).
  • The exposed schema should comply with Eclipse Microprofile Health

New schema

The schema after the fix, renders to:

{
  "status": "UP",
  "checks": [
    {
      "status": "UP",
      "data": {},
      "name": "string"
    }
  ]
}

This fixes the exposed schema to actually match the JSON structure returned by the endpoints. Additionally, the filter implementation (io.quarkus.smallrye.health.deployment.HealthOpenAPIFilter) has been refactored to use a more fluid and readable schema definition instead of the many private methods.

The PR reflects a minimally functional implementation. Please provide input regarding missing features or tests.

Copy link
Member

@xstefank xstefank left a comment

Choose a reason for hiding this comment

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

LGTM, Thanks for a very detailed PR. Great work.

@quarkus-bot

This comment has been minimized.

@frne
Copy link
Contributor Author

frne commented Aug 13, 2024

I was unaware of the format validation, sorry. Fixing it anytime soon...

@frne frne force-pushed the smallrye-health/fix-openapi-schema branch from 512107e to e0d0ae0 Compare August 13, 2024 07:59
@quarkus-bot quarkus-bot bot added area/core area/dependencies Pull requests that update a dependency file area/devtools Issues/PR related to maven, gradle, platform and cli tooling/plugins area/documentation area/elasticsearch area/gradle Gradle area/graphql area/grpc gRPC area/hibernate-orm Hibernate ORM area/hibernate-search Hibernate Search / Elasticsearch area/hibernate-reactive area/infra-automation anything related to CI, bots, etc. that are used to automated our infrastructure area/logging area/maven area/mongodb area/panache area/persistence OBSOLETE, DO NOT USE area/picocli area/platform Issues related to definition and interaction with Quarkus Platform area/qute The template engine area/reactive-messaging labels Aug 13, 2024
@gsmet gsmet removed area/smallrye area/vertx area/scheduler area/testing area/reactive-messaging area/hibernate-orm Hibernate ORM area/mongodb area/platform Issues related to definition and interaction with Quarkus Platform area/hibernate-search Hibernate Search / Elasticsearch area/dependencies Pull requests that update a dependency file area/qute The template engine area/devtools Issues/PR related to maven, gradle, platform and cli tooling/plugins area/infra-automation anything related to CI, bots, etc. that are used to automated our infrastructure area/grpc gRPC area/hibernate-reactive area/elasticsearch area/graphql area/rest area/picocli triage/flaky-test labels Aug 14, 2024
@gsmet gsmet merged commit dc5f022 into quarkusio:main Aug 14, 2024
35 of 38 checks passed
@quarkus-bot quarkus-bot bot added this to the 3.14 - main milestone Aug 14, 2024
@gsmet
Copy link
Member

gsmet commented Aug 14, 2024

Thanks for your PR!

@frne frne deleted the smallrye-health/fix-openapi-schema branch August 14, 2024 13:15
@gsmet gsmet modified the milestones: 3.14.0.CR1, 3.13.3 Aug 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

3 participants