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

[bug]: Length attribute with maxLength not filled generates incorrect OpenApiSpec #741

Open
melchor629 opened this issue Apr 3, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@melchor629
Copy link

Describe the bug

When creating a CRD entity, the Length attribute has -1 as default value for minimum and maximum length. These values are then converted to null when read from the property. But when serializing the constraint into a Kubernetes resource, not filled values are rendered as -1.

See below a sample of [Length(minLength: 1)] public string Name { get; set; } = string.Empty; gets rendered:
image

I suspect not filling minLength will render to something similarly wrong...

To reproduce

  1. Generate a new empty operator
  2. Create a new custom kubernetes entity having its spec something like public class EntitySpec { [Length(minLength: 1)] public string Name { get; set; } = string.Empty; }
  3. Compile the project
  4. Check the generated resource yaml

Expected behavior

The generated spec for the property should look like:

name:
  minLength: 1
  nullable: false
  type: string

Screenshots

No response

Additional Context

No response

@melchor629 melchor629 added the bug Something isn't working label Apr 3, 2024
@melchor629 melchor629 changed the title [bug]: Length attribute with maxLength not filled generates incorrect yaml [bug]: Length attribute with maxLength not filled generates incorrect OpenApiSpec Apr 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant