[crd-gen] Support openAPIV3Schema fields: minimum, maximum, pattern, nullable
See original GitHub issueIs your enhancement related to a problem? Please describe
(duplicate of #2959)
At the moment there is no way to auto generate a crd (with crd-gen tool) that contains properties with validation fields like minimum, maximum, pattern, nullable.
CRD example:
...
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: tenants.example.com
spec:
group: example.com
names:
kind: Tenant
plural: tenants
singular: tenant
scope: Namespaced
versions:
- name: v1
schema:
openAPIV3Schema:
properties:
spec:
properties:
kafka:
type: object
properties:
port:
type: integer
minimum: 0
maximum: 65535
nullable: false
hostname:
type: string
pattern: '^([A-Za-z0-9-]{1,63}\.)+[[A-Za-z0-9-]{1,63}$'
nullable: false
nullable: false
...
Describe the solution you’d like
I’d like to use javax annotation (like @min @max @pattern
) on a java model fields.
private String protocol;
@Pattern(regexp = "\\^\\(\\[A-Za-z0-9-]\\{1,63}\\\\\\.\\)\\+\\[\\[A-Za-z0-9-]\\{1,63}\\$")
private String hostname;
@Min(0)
@Max(65535)
private Integer port;
Currently @NotNull annotation generate the filed “required” on crd, but for “nullable” validation maybe we need of a new specific annotation.
Describe alternatives you’ve considered
No response
Additional context
version: 5.12.2
Issue Analytics
- State:
- Created a year ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
[java-gen] Support Min/Max/Pattern javax.validation.constraints ...
I have a CRD with openAPIV3Schema like this: .... kafka: type: object properties: port: type: integer minimum: 0 maximum: 65535 nullable: false hostname:...
Read more >CRD Validation - The Kubebuilder Book
specifies the minimum numeric value that this field can have. Negative numbers are supported. // +kubebuilder:validation:Minimum.
Read more >Future of CRDs: Structural Schemas - Kubernetes
Structural Schema · it has the core as defined above out of properties , items , additionalProperties , type , nullable , title...
Read more >openapi - How to specify a property can be null or a reference ...
In various places in my spec a property may be a reference to such an object OR be null. How do I specify...
Read more >Unsupported ESM URL Scheme error when importing bundleMDX ...
[crd-gen] Support openAPIV3Schema fields: minimum, maximum, pattern, nullable, 6, 2022-06-22, 2022-08-02. A version for notmuch, 5, 2022-03-31, 2022-08-10.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Closed in #4348
I’m about to go on vacation, but if no one picks it up earlier I might eventually take a look at this.