Skip to content

Conversation

@taole33
Copy link

@taole33 taole33 commented Dec 21, 2025

Description

This PR introduces support for the Jackson @JsonClassDescription annotation to provide a top-level description for generated Custom Resource Definitions (CRDs), addressing the request in #7375.

Previously, only property-level descriptions via @JsonPropertyDescription were supported. With this change, both v1 and v2 CRD generators can now extract and include the description at the root of the OpenAPI v3 schema when a Custom Resource class is annotated with @JsonClassDescription.

Changes

  • Modified AbstractJsonSchema in crd-generator-api (v1) and crd-generator-api-v2 to process class-level annotations.
  • Added a new dedicated test case in crd-generator/test using a sample Described resource to verify the output YAML across all supported CRD versions.
  • Ensured consistency between v1 and v2 generator engines.

Type of change

  • Feature (non-breaking change which adds functionality)

Checklist

Fixes #7375

Copy link
Contributor

@shawkins shawkins left a comment

Choose a reason for hiding this comment

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

Thank you for the PR, it looks very good.

Just wanted to add that it's not required to make changes to the older implementation. You can just add a v2 generator specific test.


private static final Map<TypeRef, String> COMMON_MAPPINGS = new HashMap<>();
public static final String ANNOTATION_JSON_FORMAT = "com.fasterxml.jackson.annotation.JsonFormat";
public static final String ANNOTATION_JSON_CLASS_DESCRIPTION = "com.fasterxml.jackson.annotation.JsonClassDescription";
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't appear to be used.

@taole33
Copy link
Author

taole33 commented Dec 21, 2025

@shawkins
I'll revert the changes in the v1 implementation to keep the legacy code base untouched and will update the PR to focus solely on the v2 generator and its specific tests. Thanks for the guidance!

@taole33
Copy link
Author

taole33 commented Dec 22, 2025

@shawkins
I have updated the PR to focus the @JsonClassDescription support exclusively on the v2 generator. The v1 logic has been reverted and restored to its original state.

@taole33 taole33 force-pushed the feat/7375-support-json-class-description branch from c62c2d0 to 254ec3b Compare December 23, 2025 07:24
@taole33
Copy link
Author

taole33 commented Dec 23, 2025

@shawkins
I have pushed the following updates to address the recent CI errors:

  • License Header Fix: Applied mvn -N license:format to ensure all new files comply with the project's license requirements.

  • Regarding the "Kubernetes Model Generator Build" failure, I have validated the same CI-test in my repository and confirmed it passes successfully.

All CI checks should be green now. Thanks for waiting.

Copy link
Contributor

@shawkins shawkins left a comment

Choose a reason for hiding this comment

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

This looks great. The only nit would be that the description annotation is used at any level, not just the top-level object.

Could the changelog and a doc entry in https://github.com/fabric8io/kubernetes-client/blob/main/doc/CRD-generator.md#features-cheatsheet be updated to reflect this?

@taole33
Copy link
Author

taole33 commented Dec 27, 2025

@shawkins

Could the changelog and a doc entry in https://github.com/fabric8io/kubernetes-client/blob/main/doc/CRD-generator.md#features-cheatsheet be updated to reflect this?

Sure, I’d be happy to update the changelog and documentation.
I also noticed the CI failure, so I will investigate the cause.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CRD Generator : Adding a top level description for a CRD

2 participants