You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(generator): expand CRD schema metadata support (#1201)
Adds attributes for defaults, examples, formats, and enum values in
generated CRD schemas, including structured JSON and class-level
defaults.Includes focused attribute validation and explicitly configures
the CRD conversion strategy based on registered conversion webhooks.
closes#1200
Copy file name to clipboardExpand all lines: docs/docs/operator/building-blocks/entities.mdx
+24-1Lines changed: 24 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -140,12 +140,22 @@ public class EntitySpec
140
140
-`[UniqueItems]`: **Rejected by the transpiler.** Kubernetes CRD schemas do not allow `uniqueItems: true`, so applying this attribute now fails transpilation. Use `[XListType(XListType.Set)]` for Kubernetes set semantics instead
141
141
-`[PropertyLimits]`: Specifies minimum and maximum number of properties for an object
142
142
-`[ValidationRule]`: Defines custom validation rules using CEL expressions. Can be applied to properties and to class types — in both cases it emits `x-kubernetes-validations` on the corresponding schema node. When applied to both a class and a property of that type, the rules are merged (class rules first, then property rules). Class-level rules are also collected across the **class inheritance chain**: a rule placed on a base class is inherited by every derived entity or nested type, and all rules found along the chain are merged onto the schema node
143
+
-`[EnumValues]`: Overrides the allowed string, integer, or floating-point values emitted as the OpenAPI `enum`.
144
+
Values must be non-empty, unique, and compatible with the generated string, integer, number, or
145
+
`IntOrString` schema
143
146
144
147
### Documentation Attributes
145
148
146
149
-`[Description]`: Adds a description to a property or entity
147
150
-`[Title]`: Adds a title to a property or entity
148
151
-`[ExternalDocs]`: Links to external documentation
152
+
-`[DefaultValue]`: Adds an OpenAPI default value to a property or class. Set `Json = true` on a string argument to
153
+
represent structured values such as objects or arrays instead of a literal string. A class-level default applies
154
+
wherever that type is used in the schema, including the `spec` or `status` subresource. Class-level defaults are
155
+
inherited
156
+
-`[Example]`: Adds an OpenAPI example. Set `Json = true` for structured JSON examples
157
+
-`[Format]`: Overrides the inferred OpenAPI format, for example `[Format("uri")]` or `[Format("email")]`.
158
+
Use `[Format(null)]` to suppress an inferred format such as `int32`; empty or whitespace-only formats are rejected
149
159
150
160
### Display Attributes
151
161
@@ -182,17 +192,30 @@ public class V1DemoEntity : CustomKubernetesEntity<V1DemoEntity.V1DemoEntitySpec
182
192
publicstringUsername { get; set; } =string.Empty;
183
193
184
194
[Description("Number of replicas to run")]
195
+
[DefaultValue(1)]
185
196
[RangeMinimum(1)]
186
197
[RangeMaximum(10)]
187
198
publicintReplicas { get; set; } =1;
188
199
189
200
[Pattern(@"^[a-z0-9-]+$")]
190
201
[Description("The namespace where resources should be created")]
`[ScaleSubresource]` and the status subresource are controlled independently. A `Status` property activates `status: {}` regardless of `[ScaleSubresource]`, and `[ScaleSubresource]` adds `scale:` regardless of whether a `Status` property exists.
0 commit comments