-
Notifications
You must be signed in to change notification settings - Fork 1.5k
feat(crd-generator): introduce @JSONSchema
annotation
#7000
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
base: main
Are you sure you want to change the base?
Conversation
Still a work-in-progress, needs lots of testing and feedback/comments on whether this seems generally viable :) |
aec0e41
to
1cb2781
Compare
Signed-off-by: Michael Edgar <medgar@redhat.com>
Signed-off-by: Michael Edgar <medgar@redhat.com>
Signed-off-by: Michael Edgar <medgar@redhat.com>
Signed-off-by: Michael Edgar <medgar@redhat.com>
Signed-off-by: Michael Edgar <medgar@redhat.com>
Signed-off-by: Michael Edgar <medgar@redhat.com>
|
Thanks @MikeEdgar this looks promising. It does seem highly related to SchemaSwap - at least for the usage of implemenation or type. SchemaSwap could be altered to work at a field level, but one of the usage models it supports is for Keycloak, and maybe other projects, where the classes are defined in some other module and don't need or want CRD related annotations - so you are forced to define the swaps at a higher level than directly on the intended fields. cc @andreaTP I know you have mentioned in the past wanted to see a general schema option - did you think of it working vis SchemaSwap or a separate annotation? |
Yes, I think the |
That is correct, you can't specify an arbitrary type in string form. I also forgot to mention SchemaFrom (the localized limited form of SchemaSwap). So instead of:
You could do either:
or
With a similar comparison for implementation. |
Description
Closes #6999
This is a POC to demonstrate the idea behind #6999 (it may also close several other issues related to the CRD generator's capabilities). The new
@JSONSchema
annotation may be used on a class or property to short-circuit other schema scanning for the target. The exception is when the annotation'simplementation
is used. In that case, theimplementation
class will be scanned as normal, then the@JSONSchema
annotation attributes will be used to override those from the scan.The annotation also includes a
structural
boolean attribute that enables certain handling for structural schemas. This includes copying properties fromallOf
,anyOf
,oneOf
, andnot
to the schema with the annotation, and also removing the restricted attributes without those sub-schemas.Several of the attributes of the annotation may not actually be valid for a Kube CRD schema. However, the intent here is simply to expose the CRD schema model entirely to give that control to the user.
Type of change
test, version modification, documentation, etc.)
Checklist